T09 · Insecure Skill Coding Practices
- Location
scripts/editorconfig-linter.py:349- Finding
Fix Mode Follows Symbolic Links and Can Overwrite Files Outside the Requested Directory
- Content
View full analysis
list: """Discover checkable files in path.""" files = [] if os.path.isfile(path): return [path] for root, dirs, fnames in os.walk(path): # Filter excluded dirs dirs[:] = [d for d in dirs if d not in excludes and not d.startswith('.')] for fname in fnames: _, ext = os.path.splitext(fname) if ext.lower() in CHECKABLE_EXTENSIONS or fname in ('.editorconfig', 'Makefile', 'Dockerfile'): files.append(os.path.join(root, fname)) if len(files) >= max_files: return files return files ``` ```python if modified: encoding = 'utf-8' if eol == 'crlf': raw_out = content.encode(encoding).replace(b'\n', b'\r\n') else: raw_out = content.encode(encoding) if charset == 'utf-8-bom': raw_out = b'\xef\xbb\xbf' + raw_out with open(filepath, 'wb') as f: f.write(raw_out) ``` ```python for filepath in files: rel_path = os.path.relpath(filepath, os.path.dirname(ec_path)) props = match_file(rel_path, sections) if props: fixes = fix_file(filepath, props) ``` ### Technical Analysis File discovery accepts directory entries based on their displayed filename and extension without checking whether the entry is a symbolic link. The discovered path is subsequently opened using `open(filepath, 'wb')`, which follows symbolic links by default. The implementation neither resolves candidate paths and verifies that they remain beneath the requested scan root nor uses no-follow file-opening semantics. Consequently, a repository-controlled symbolic link can redirect a write operation to a file ...[truncated 1776 chars]- Remediation
View remediation
