Repository navigation
Commit e75f7e6
fix(safe_eval): remove parent-side deserialization sink (v0.0.7)
Reported by Juan Lucas Armendares (Sunplace Solutions): in 0.0.6 the child
serialized its evaluation result with cloudpickle and the parent called
cloudpickle.loads() on it with full builtins. The AST checker only guarded
what ran inside the sandboxed child, never the value sent back, so an
expression could return a __reduce__ gadget that executed arbitrary code in
the calling process. Distinct root cause from CVE-2026-133467.
Result boundary
- No pickle on the evaluation path at all: the child encodes the result as
plain primitives over a multiprocessing.Pipe and the parent rebuilds it with
a non-executable decoder.
- Results are plain data (None, bool, int, float, complex, str, bytes,
Decimal, Fraction); containers are opt-in via the new allow_objects flag.
Lambdas, classes, modules, generators and user types now raise RuntimeError
instead of being serialized.
- Exceptions cross as (builtin type name, message); SystemExit /
KeyboardInterrupt / GeneratorExit arrive as catchable RuntimeError and
user-defined exception types are never reconstructed in the parent.
- Bounded results (depth, node count, byte size) and a per-call int->str
digit cap keep a returned value from burning CPU in the caller.
- The Pipe is drained by a reader thread so a result larger than the OS pipe
buffer cannot deadlock the parent; timeout latency tightened.
- cloudpickle dependency removed.
AST checker hardening (same audit)
- Format/format_map templates that name attributes or keys are rejected
('{0.__init__.__globals__}'.format(obj) is an invisible attribute read).
- Rebound safe-builtin names may only be called when explicitly allowlisted
((len := f)(), [f() for len in [..]], (lambda len: len())(f)).
- Callables passed to builtins that invoke them (sorted(key=...), iter(f, None))
follow the same allowlist; allowed_vars entries are data, not call grants.
- __builtins__ and the other reserved names are never resolvable or rebindable.
- file_access/network_access are enforced after allowed_builtins is merged, so
re-introducing open through allowed_builtins no longer bypasses the flag.
Tests: 108 passing (29 new in TestResultBoundaryV007 plus updated result-policy
assertions). Docs, SECURITY.md and the advisory draft updated for 0.0.7.
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>1 parent d2ff49d commit e75f7e6
7 files changed
Lines changed: 1126 additions & 119 deletions
File tree
- .github/workflows
- codesafe
- security-advisories
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
53 | 55 | | |
54 | | - | |
| 56 | + | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
0 commit comments