Repository navigation
Security audit: re-approve the four torch findings that 2.14.0 opened - #10233
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 588cf117bf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "evidence": "Obfusc: L1570: exec(compile(python_code, \"<precompile>\", \"exec\"), module_ns)\nExec: L967: # exec(open(\"this_file.py\").read(), ns) | L1174: # exec(open(\"this_file.py\").read(), ns) | L1570: exec(compile(python_code, \"<precompile>\", \"exec\"), module_ns)", | ||
| "evidence_hash": "ed7c7bfe07302200f8323e8f091a8f6ab06c9607410e31c4f036699fe7dee161" |
There was a problem hiding this comment.
Pin context-dependent exec approvals to reviewed files
For both this entry and the analogous standalone_compile.py entry below, the benign judgment depends on surrounding code establishing where python_code comes from and when it is executed, but the evidence hash covers only the unchanged exec(compile(...)) call. Without file_sha256, a future or compromised torch release can change that surrounding provenance while retaining these lines, causing _partition_baseline to suppress the finding and keep the security audit green. Add the reviewed 2.14.0 file digests to both entries.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Agreed on both, and pinned in 0f6f16d.
The reviewed 2.14.0 digests, computed the way check_py_file does at scan_packages.py:1211 (sha256(original.encode("utf-8", "replace")) over the wheel member, which round-trips identically for all three):
| file | file_sha256 |
|---|---|
torch/_precompile.py |
a8ab839be1e8b555c181a08a8c431185aaf67e8ac00e517590fc8092d0554e46 |
torch/_inductor/standalone_compile.py |
fe16758342f83ce0040a038648a371315bee8f3876f0da75a786562828cbb836 |
torch/_inductor/compile_worker/subproc_pool.py |
695b5c1df7d0ae710451aa8904c5ef101e0c93de26a591f3e995bb9151d4c0e3 |
Taken out of torch-2.14.0-cp312-cp312-manylinux_2_28_x86_64.whl itself, not from a GitHub tag, so they are the bytes the scanner actually reads.
Verified by running the scan rather than by reasoning about it:
$ python scripts/scan_packages.py torch==2.14.0
Summary: 22 MEDIUM
14 finding(s) suppressed by baseline scripts/scan_packages_baseline.json (8 CRITICAL, 6 HIGH, 0 MEDIUM)
=== EXIT 0 ===
and _load_baseline reports one pin per key rather than None, so _partition_baseline now reopens each of the three on any edit to the file, not just to the matched lines.
I left torch/testing/_internal/common_utils.py unpinned deliberately: its evidence already carries a span digest over the whole socket to subprocess region, and adding a file pin on top would only duplicate coverage that is, if anything, already too broad. That entry is the one this baseline has re-approved three times for exactly that reason, which is written up in the PR description.
The cost of these three pins is honest and worth stating: the next torch release edits all three files, so Security audit goes red on them and asks for a re-review. That is the control working, but it is the same treadmill the PR description argues about, and it is now three entries longer.
| "evidence": "Anti: L860: time.sleep(3600)\nSubprocess: L212: self.process = subprocess.Popen( sha256:62f622e5b17b6c6b1656b44c8ba27274f02c68c4f9d35502fb593f1d6a3af55d", | ||
| "evidence_hash": "f760ab1ce9c086051291c29ac4e486575db6f2dac2eddba2ac31ef5c434609d8" |
There was a problem hiding this comment.
Pin the control-flow-dependent anti-analysis approval
This approval is benign only because the long sleep is currently confined to a test helper and is unrelated at runtime to the worker-launching Popen, but the evidence hash records only the sleep and subprocess call text, not that control-flow separation. Without file_sha256, a later torch release can invoke or relocate the unchanged helper into the production worker path while retaining the same evidence, and _partition_baseline will suppress the resulting anti-analysis finding. Pin this entry to the reviewed 2.14.0 file digest.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pinned in 0f6f16d, to 695b5c1df7d0ae710451aa8904c5ef101e0c93de26a591f3e995bb9151d4c0e3. Your reading of the gap is exact: the sha256:62f622e5... already in that entry's evidence is the span digest over the 13-line Popen block only, so it records the call text and nothing about _ignore_sigterm_and_sleep_for_test being confined to the test path. Relocating the unchanged helper into the production worker would have kept the evidence hash intact. See the reply on the other comment for how the digests were derived and for the end-to-end scan that confirms all four now suppress at exit 0.
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Security review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
Security audithas been red on everymaincommit since2ecb19df7, onpip scan-packages :: studioandpip scan-packages :: extras, with the same 1 CRITICAL and 3 HIGH. All four are intorch, and no commit in this repo caused them.torch is not named in any scanned input.
grep -rn "torch" studio/backend/requirements/*.txtfinds onlytorchcodec,torch-c-dlpack-ext,pytorch_tokenizersandtorch-stoi; torch itself arrives transitively through--with-deps, which resolves to whatever PyPI serves that morning.hf-stackstays green because its inputs are deliberately torch-free.torch 2.14.0 was published at 2026-09-02T13:42:48Z. The last green
Security auditonmainstarted at 13:22, the first red one at 14:06. I pulled the last-green artifact rather than infer it:against the red run, which reports
torch-2.14.0-cp312-cp312-manylinux_2_28_x86_64.whl.The four findings
Three are new upstream code between
v2.13.0andv2.14.0, one is an existing entry whose span digest rotated.torch/_precompile.pyis a new file (pytorch/pytorch#189620,torch.compiler.precompile). Both halves of the finding are one line, L1570, in_make_inlined_forward, which execs an artifact the user produced and logs a loud warning first:The
Exec:half of the evidence also lists L967 and L1174, which look like comments the stripper missed. They are not: both sit inside_GENERATED_HEADER/_EAGER_GENERATED_HEADER, string constants assigned to a name, so the#is literal text baked into a generated file's header._strip_noncodeonly blanks bare docstrings, correctly.RE_EXEC_EVALmatched documentation prose.torch/_inductor/standalone_compile.pygainedload_from_python(pytorch/pytorch#187858,torch._inductor.compile_to_python). One line, L687, the counterpart tocompile_to_python, exec'ing a self-contained Inductor module the caller just generated. Same shape as the already-baselinedtorch/fx/graph_module.pyentry.torch/_inductor/compile_worker/subproc_pool.pygained a test helper (pytorch/pytorch#189290):RE_ANTI_ANALYSISpairs that long sleep withsubprocess.Popen(at L212, which is the pool's own worker launch, 650 lines away and unchanged since 2.13.0. Nothing conditions on a debugger, a VM or a tracer. The two halves never co-occur at runtime.torch/testing/_internal/common_utils.pyis not new code at all.import socketis at line 32 in both releases; this file+check has been reviewed benign twice already (89faaaa8...,ba439cbf...) and this is the third digest for the same thing.RE_REVERSE_SHELLisre.DOTALL, so the match runs from the firstsocketto the lastsubprocessand_renderdigests the whole bridged span. That span went from 6,270 to 6,595 lines, and the changed lines inside it are 381 added and 56 removed, of which zero match any IOC pattern in the scanner. It reopened on a newHardwareClassificationenum and thirty-odd unrelated test edits.The patch
Four additive, unpinned entries, matching how the two existing
common_utils.pyreverse-shell entries and #10187 are maintained. 223 entries to 227.I derived them with
scan_packages.py torch==2.14.0 --write-baselineand took only the delta, rather than regenerating the other 219, then recomputed everyevidence_hashindependently through the scanner's own_evidence_hashand confirmed all four agree.Reproduced end to end against a real 2.14.0 wheel:
The
beforeoutput is byte-identical to the CI evidence, including bothsha256:digests. A control run on 2.13.0 with--no-baselineshows 8 CRITICAL + 3 HIGH, all already committed, and none on the three new files.tests/security/test_scan_packages.pyis unaffected: 132 passed, with the one unrelated failure that #10206 fixes.Why this keeps happening
This is the fourth time a routine upstream release has turned
mainred on this workflow, after huggingface-hub (#9252, #8135), unsloth-zoo (#9674, #10187) and now torch. The mechanism is the same each time and it is worth writing down.58 of the 223 entries carry a span digest. 23 (package, file, check) triples hold more than one entry, 34 entries beyond the first, and 22 of those 34 exist purely because a span digest rotated: 4 for
huggingface_hub/utils/_http.py, 4 forunsloth_zoo/compiler.py, 2 fortorch/testing/_internal/common_utils.py, and so on. Every one of those four_http.pyentries covers about 650 lines to bind a 30-line retry loop.The cause is
.*greediness underre.DOTALL: a cross-line branch matches from the first atom in the file to the last, and_render's long-span fallback then digests everything it bridged. The entry is not pinned to the reviewed code, it is pinned to most of the file, so any refactor anywhere between the atoms reopens a CRITICAL.A fix I measured but am deliberately not folding in here: give each cross-line regex a companion line-level atom pattern and, when
_renderfalls back to a digest, digest only the atom-bearing lines. That collapsescommon_utils.pyto one stable digest across both releases and_http.pyto one across 1.26.1 / 1.27.0 / 1.28.0, while a spliced reverse shell, a spliced beacon loop and the scenario intest_the_hf_backoff_suppression_is_narrowall still reopen. The honest cost is that an edit inside a span carrying none of that check's atoms no longer reopens that entry, though it still raises its own finding if it trips any other check. And landing it rotates all 58 hashes at once, which needs its own PR with the code re-read entry by entry, not a--write-baselineregeneration bolted onto an urgent unblock.Smaller companion, worth having either way: the report cannot currently tell "a file+check nobody has ever reviewed" from "a file+check reviewed three times whose digest rotated".
torch/_precompile.pyandcommon_utils.pyprinted identically here, and they deserve different sentences. Classifying on the coarse(package, file, check)key, NEW versus REOPENED, with the superseded evidence printed alongside, would have made this triage minutes instead of an afternoon. Both still exit 1.