[Codex] fix: harden AST sandboxing in logic executor to prevent sandbox escapes#528
Open
Micsi wants to merge 1 commit into
Open
Conversation
Collaborator
Author
|
Zusatzupdate aus dem Security-Review (TDD-basiert):
|
a093901 to
02baecd
Compare
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.
Source PR
Motivation
eval/execwhich enabled attribute-traversal sandbox escapes and authenticated RCE.Description
GraphExecutor._validate_formula_astwhich allows only a constrained set of expression AST node types and blocks attribute access except safemath.<name>lookups.GraphExecutor._validate_script_astwhich blocks dangerous script constructs (imports, defs, class/async/lambda/with/try/global/nonlocal/raise/delete/yield/await) and disallows attribute traversal except safemath.<name>access._safe_eval(validate parsed formula AST beforeeval) and_run_script(validate parsed script AST andcompilebeforeexec).tests/unit/test_executor.pyto assert attribute traversal is blocked instead of documenting the previous unsafe behavior.Testing
pytest -q tests/unit/test_executor.pyand the test file passed with all tests green (192 passed, 1 warning).obs/logic/executor.pyand the associated unit test update intests/unit/test_executor.py.Codex Task