Repository navigation
Commit 051dc80
fix: CI failures on 3.8 and on spawn platforms, plus a spawn-side pickle sink
Three issues surfaced in CI (3.8 ubuntu, 3.12 windows/macos):
1. Fraction encoding used int.__int__, which only exists on 3.11+. Replaced
with int() plus an exact-type check, so Decimal/Fraction round-trip on 3.8+.
2. test_result_is_never_pickled asserted assertNotIsInstance (3.9+). Replaced
with isinstance on the captured exception.
3. The result-boundary tests defined helper classes/functions inside test
methods, which cannot be pickled to a spawned child, so every spawn-platform
test errored before exercising anything. Moved them to module level.
While fixing (3) I found a real sink on the spawn path: Process.start() pickles
the whole Process object - arguments included - in the CALLER, so everything in
allowed_vars/allowed_builtins is reduced with pickle before any sandbox exists.
An object with a hostile __reduce__ runs during the call, in the host process.
Mitigation:
- When fork is available and the host has not pinned a start method, select
fork so the child inherits these objects and nothing is pickled on the way
in. (Verified: four consecutive calls under 3.11, start method resolves to
fork, and the module-level ReduceBomb's __reduce__ never fires.)
- On Windows (no fork), or when the host pins spawn, this is inherent to
multiprocessing. It is not reachable from the expression: allowed_vars is
host-supplied, and an expression cannot add to it. Documented in the
safe_eval docstring so integrators know these dicts carry a pickle-trust
requirement there.
The result boundary itself is unaffected: the 0.0.6 RCE payload is still
blocked and no marker file is produced.
Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>1 parent 701c9eb commit 051dc80
2 files changed
Lines changed: 91 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
137 | 138 | | |
138 | 139 | | |
139 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
140 | 151 | | |
141 | 152 | | |
142 | 153 | | |
| |||
195 | 206 | | |
196 | 207 | | |
197 | 208 | | |
198 | | - | |
199 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
200 | 228 | | |
201 | 229 | | |
202 | 230 | | |
| |||
408 | 436 | | |
409 | 437 | | |
410 | 438 | | |
411 | | - | |
412 | | - | |
413 | | - | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
414 | 446 | | |
415 | 447 | | |
416 | 448 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
23 | 46 | | |
24 | 47 | | |
25 | 48 | | |
| |||
687 | 710 | | |
688 | 711 | | |
689 | 712 | | |
690 | | - | |
| 713 | + | |
691 | 714 | | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | | - | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
698 | 722 | | |
| 723 | + | |
699 | 724 | | |
700 | | - | |
701 | | - | |
| 725 | + | |
702 | 726 | | |
703 | 727 | | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
708 | 740 | | |
709 | | - | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
710 | 744 | | |
711 | 745 | | |
712 | 746 | | |
| |||
814 | 848 | | |
815 | 849 | | |
816 | 850 | | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | 851 | | |
821 | | - | |
| 852 | + | |
822 | 853 | | |
823 | 854 | | |
824 | 855 | | |
| |||
857 | 888 | | |
858 | 889 | | |
859 | 890 | | |
860 | | - | |
| 891 | + | |
| 892 | + | |
861 | 893 | | |
862 | 894 | | |
863 | 895 | | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
871 | 896 | | |
872 | | - | |
| 897 | + | |
| 898 | + | |
873 | 899 | | |
874 | 900 | | |
875 | 901 | | |
| |||
893 | 919 | | |
894 | 920 | | |
895 | 921 | | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | 922 | | |
901 | | - | |
| 923 | + | |
902 | 924 | | |
903 | 925 | | |
904 | 926 | | |
| |||
0 commit comments