T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/generate.py:410- Finding
Entity Name Path Traversal Allows Writes Outside the Flutter Project
- Content
View full analysis
- Remediation
View remediation
Path: base = base.resolve() destination = (base / relative).resolve() try: destination.relative_to(base) except ValueError: raise ValueError(f"Output path escapes destination directory: {destination}") return destination ``` 4. Apply containment checks to both `model_file` and `repo_file`, rather than relying solely on input validation. 5. Avoid calling `mkdir()` until after containment validation succeeds. 6. Add regression tests covering `../`, nested traversal, absolute paths, backslashes, mixed separators, encoded or Unicode separator variants, and valid PascalCase names. ]]>
