fix(ast): strip stack canary boilerplate from decompiled C output#172
Open
wizardengineer wants to merge 1 commit intomainfrom
Open
fix(ast): strip stack canary boilerplate from decompiled C output#172wizardengineer wants to merge 1 commit intomainfrom
wizardengineer wants to merge 1 commit intomainfrom
Conversation
Add is_stack_canary_operation() to FunctionBuilder that detects compiler-inserted stack protector patterns by checking: - Operations with inputs referencing __stack_chk_guard globals - CALL operations targeting __stack_chk_fail Detected operations are skipped during basic block creation, removing the canary entry load and fail call from the generated C. This is a temporary solution that handles the straightforward cases (entry guard load and fail call) by pattern-matching on global names and call targets. The exit comparison block (if guard == saved) is not fully removed because the AST structuring engine reorganizes it into an if-else before our filter can catch the individual operations. A complete solution would require value-level taint tracking — marking values derived from __stack_chk_guard and propagating that taint through copies, comparisons, and branches so the entire canary exit path can be identified and stripped. That approach is more invasive and should be discussed before implementing. Partial fix for #161 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Add is_stack_canary_operation() to FunctionBuilder that detects compiler-inserted stack protector patterns by checking:
Detected operations are skipped during basic block creation, removing the canary entry load and fail call from the generated C.
This is a temporary solution that handles the straightforward cases (entry guard load and fail call) by pattern-matching on global names and call targets. The exit comparison block (if guard == saved) is not fully removed because the AST structuring engine reorganizes it into an if-else before our filter can catch the individual operations.
A complete solution would require value-level taint tracking — marking values derived from __stack_chk_guard and propagating that taint through copies, comparisons, and branches so the entire canary exit path can be identified and stripped. That approach is more invasive and should be discussed before implementing.
Partial fix for #161