Repository navigation
[Aikido] Fix path traversal bypass in normalized filepath comparison logic - #440
Closed
aikido-autofix[bot] wants to merge 1 commit into
Closed
aikido-autofix[bot] wants to merge 1 commit into
aikido-autofix[bot] wants to merge 1 commit into
Conversation
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.
This patch addresses a path traversal vulnerability in the path traversal scanner where attackers could bypass detection by providing exact dangerous directory paths. The vulnerability existed because the scanner was comparing raw user input against dangerous directory prefixes instead of comparing normalized filepaths. The fix normalizes both the resolved filepath and user input before comparison, ensuring consistent path validation. Changes were made to
lib/aikido/zen/scanners/path_traversal/helpers.rband corresponding test cases intest/aikido/zen/scanners/path_traversal_scanner_test.rbto properly detect path traversal attempts.✅ 1 issue fixed by this PR
PathTraversal::Helpers.start_with_unsafe_path?returns false when the raw payload equals a configured dangerous directory, without requiring the final normalized filepath to equal that directory. For a payload of/etcand a constructed filepath of/etc/passwd, the filepath is recognized as being beneath the dangerous prefix but line 74 takes the exact-prefix exemption. An application endpoint that combines this request-controlled directory with a trusted filename can therefore access a sensitive descendant despite the firewall's blocking mode. The one-character early return for/is a separate residual bypass and should be tracked independently rather than treated as necessary to establish this finding.