Pensar - auto fix for Unsanitized Path Traversal in Social Profile Creation#16
Open
pensarappdev[bot] wants to merge 1 commit into
Open
Pensar - auto fix for Unsanitized Path Traversal in Social Profile Creation#16pensarappdev[bot] wants to merge 1 commit into
pensarappdev[bot] wants to merge 1 commit into
Conversation
…tion (CWE-400, ML08, 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.
Directory Traversal Fix in
Profile.create_social_profile_snsandProfile.create_social_profile_tweepy:outdiranduserparameters directly from input and concatenated them with other path fragments to create file paths for both reading and writing data—without any validation. This allowed for potential path traversal attacks by supplying malicious values for either parameter.self.safe_outdir_base,self.safe_embedding_base) for allowed storage locations._safe_join(base_dir, *paths)to securely join path fragments and verify the result stays within the intended base directory._sanitize_username(user)to reject usernames containing path separators, traversal, or other suspicious input._sanitize_outdir(outdir)to ensure the output directory is a subdirectory of the designated safe base._sanitize_embedding_path(embedding_path)to guarantee embeddings are .npy files inside the embeddings directory and forbid path traversal/absolute paths.Other Key Points:
More Details
outdiranduseroriginate from external input and are concatenated directly into file-system paths without any sanitization or normalization. An attacker could supply values such asoutdir="../../../../etc"oruser="../malicious"and cause the program to read from or write to arbitrary locations on the host. This enables directory traversal, overwriting critical files, or exfiltrating sensitive data.