T09 · Insecure Skill Coding Practices
- Location
scripts/chan_extractor.py:99- Finding
Unsanitized Path Components Permit Output Directory Escape
- Content
View full analysis
4: # Check if arg4 is a digit (word_limit) or a directory if sys.argv[4].isdigit(): word_limit = int(sys.argv[4]) else: out_root = sys.argv[4] if len(sys.argv) > 5 and sys.argv[5].isdigit(): word_limit = int(sys.argv[5]) get_thread(board, thread_id, out_root, word_limit) ``` ### Technical Analysis The caller-controlled `board` and `thread_id` values are incorporated into filesystem paths without validation, normalization, or a containment check. `os.path.join()` does not guarantee that the resulting path remains beneath `output_root`. Traversal components such as `..` may resolve outside the intended directory. An absolute path component may also cause preceding path components to be discarded. The program subsequently creates directories with `os.makedirs()` and opens the destination in write mode, which truncates an existing file. The intended output layout is `/_/.txt`, but the implementation does not enforce that boundary. Exploitation is constrained because the file-writing logic runs only after the constructed 4chan re ...[truncated 1768 chars]- Remediation
View remediation
