Skip to content

Python: Add Django safe_join as path injection sanitizer#15

Open
mrigankpawagi wants to merge 1 commit into
mainfrom
improve-py-path-injection-safe-join
Open

Python: Add Django safe_join as path injection sanitizer#15
mrigankpawagi wants to merge 1 commit into
mainfrom
improve-py-path-injection-safe-join

Conversation

@mrigankpawagi

Copy link
Copy Markdown
Owner

Fix

Adds django.utils._os.safe_join as a sanitizer for the py/path-injection query.

Problem

Django's safe_join function validates that the joined path stays within the base directory by raising a SuspiciousFileOperation exception if traversal is detected. The current query flags code that uses safe_join as vulnerable to path injection, which is a false positive.

Validation

MRVA on top-100 Python repos showed FPs in django/views/static.py and similar Django view code that correctly uses safe_join.

django.utils._os.safe_join validates that the resulting path stays
within the base directory, preventing path traversal. This eliminates
false positives when safe_join is used (e.g., in django/views/static.py).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants