Pensar - auto fix for Path Traversal Vulnerability in Tweet Data File Operations#21
Open
pensarappstaging[bot] wants to merge 1 commit into
Open
Pensar - auto fix for Path Traversal Vulnerability in Tweet Data File Operations#21pensarappstaging[bot] wants to merge 1 commit into
pensarappstaging[bot] wants to merge 1 commit into
Conversation
…perations (CWE-22)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Security Issue Fixed:
There was a critical CWE-22 (Path Traversal) vulnerability in the way file paths were constructed throughout the
Profileclass, particularly increate_social_profile_tweepy()andcreate_social_profile_sns(). Attacker-controlled parameters (outdiranduser) were used directly in file paths without sanitization, potentially allowing arbitrary file reads/writes.How It Was Fixed:
safe_filename()to sanitize theuservalue, restricting it to [a-zA-Z0-9_.-] and replacing other characters with_to prevent malicious input from altering file paths._safe_join(base, *paths)to ensure the constructed file path is always located within the intended (sanitized) output directory, blocking directory traversal attempts.outdirat the start of each relevant method using absolute paths for additional protection.Result:
All reads/writes to tweet and cluster label files are now protected from path traversal attacks via both filename sanitization and path boundary enforcement. The remainder of the code and its formatting is unchanged.
More Details
outdiranduser(see also lines 74 – 85). No sanitisation or normalisation is performed. An attacker can supply traversal sequences such asoutdir="../../"oruser="../../etc/passwd", causing the code to read from or write to arbitrary locations on the host. This classic path-traversal issue (CWE-22) can lead to disclosure of sensitive files, overwriting of application files, or privilege-escalation through malicious file placement.