Repository navigation
[Aikido] Fix shell injection bypass in is_safely_encapsulated quote validation - #442
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
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 shell injection bypass vulnerabilities in the shell injection scanner's quote validation logic. The
is_safely_encapsulatedmethod previously used a naive character adjacency check that could be bypassed using empty quote pairs or escaped quote characters. The fix replaces this with a proper shell quote state parser that correctly tracks escape sequences and validates that user input is genuinely enclosed within active quote delimiters. Changes were made tolib/aikido/zen/scanners/shell_injection/helpers.rbwith corresponding test coverage added totest/aikido/zen/scanners/shell_injection_scanner_test.rbandtest/aikido/zen/scanners/shell_injection/helpers_test.rb.✅ 1 issue fixed by this PR
printf '';id #''with input;id #, the neighboring characters are both single quotes, but those quotes do not delimit the payload: the semicolon remains an active command separator. Similarly, escaped quote boundaries such asecho \";id;echo\"with input;id;echocan satisfy the adjacency check even though the quotes are literal shell characters.ShellInjectionScanner#attack?returns beforecontains_shell_syntax, so the pre-sink hook does not raise and the original single-stringKernel#system,Kernel#spawn, or backtick operation remains reachable.