[Codex] fix(logic): harden formula eval against sandbox escape#527
Open
Micsi wants to merge 2 commits into
Open
[Codex] fix(logic): harden formula eval against sandbox escape#527Micsi wants to merge 2 commits into
Micsi wants to merge 2 commits into
Conversation
Collaborator
Author
|
Ergänzung zur Nachvollziehbarkeit der letzten Änderung: Zusätzlich zum bestehenden Security-Fix wurde ein gezielter Unit-Test ergänzt, um einen bisher nicht explizit getesteten Guard-Branch abzudecken. Was wurde zusätzlich gemacht?
Warum war das wichtig?
Verifikation
Einordnung
|
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
value_formulastrings from user-editable datapoint nodes were evaluated viaGraphExecutor._safe_evaland could be abused to escape the Python sandbox and execute arbitrary code via object introspection.__builtins__, which is insufficient to prevent attribute traversal and other Python constructs from reaching import or OS primitives.Description
GraphExecutor._validate_formula_astwhich inspects the parsed AST and rejects disallowed node types and constructs before evaluation._validate_formula_astfromGraphExecutor._safe_evalto enforce an allowlist of safe AST nodes and permitted names.tests/unit/test_executor.pyto assert that attribute-based sandbox escape payloads are blocked (replacing the previous attribute-access expectation).Testing
pytest -q tests/unit/test_executor.py, which completed successfully with193 passedand no failures.obs/logic/executor.pyandtests/unit/test_executor.pyand preserve existing executor behavior for allowed math expressions.Codex Task