Repository navigation
Commit 3f423bf
fix(z3): close string-based evasions of the AST attribute denylist
QA probes found two solver-code escapes that pass the gate and execute:
z3.__dict__['__builtins__']['__import__']('os').system(...) and
z3.__getattribute__('__spec__').loader... — __dict__/__getattribute__
turn every denied attribute into a constant-string lookup, and a
module's __dict__ exposes its real __builtins__ (dir(z3) contains
__builtins__, so the namespace dump in execute_code_in_process()
already replaces the restricted builtins with the full ones).
getattr/setattr reach the same attributes via constant strings and
resolve at runtime.
- Deny getattr/setattr/delattr calls
- Deny __dict__/__getattribute__/__getattr__/__setattr__/__delattr__
attributes
- Add 6 regression tests (suite: 35 passed); allow-cases unchanged1 parent 81f02f3 commit 3f423bf
2 files changed
Lines changed: 22 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | | - | |
32 | | - | |
33 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
34 | 38 | | |
35 | 39 | | |
36 | 40 | | |
37 | | - | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
63 | 73 | | |
64 | 74 | | |
65 | 75 | | |
| |||
0 commit comments