Repository navigation
fix(pwntools): let callers widen the artifact input bound - #2486
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
The pwntools adapters rejected every artifact over 32 MiB before any analysis ran, and nothing in configuration, environment, CLI or MCP could raise that bound, so real recorded core dumps stayed unanalyzable. Resolve the bound from REA_PWNTOOLS_MAX_INPUT_BYTES in front of the shipped default. An absent value keeps 32 MiB, and a value outside 1..1073741824 bytes is refused as unusable provider configuration before the artifact is read instead of falling back silently.
eecc0a7 to
848082f
Compare
|
TL;DR: The fix works on Linux x64. All 21 tests from this PR pass on Node 22, 24 and 26, and the 3 admission cases ran. A real core dump now opens through the CLI when the variable is set. Thanks, NIU-123370, for the clear write-up and the mutation table. You asked for a Linux run, so here it is. Results
On head, none of the 3 admission cases were skipped. On base bb54082, I copied in your two test files. The unit file cannot import the new module. Admission case 1 passes and cases 2 and 3 fail, as expected. Through the CLI, with real pwntools 4.15.0 on Node 24:
Base refuses with Two small notes. The line in docs/recorded-crashes.md says a bad value gives an invalid request, but head gives Not run
CommandsI built the ELF files from a small system ELF and extended each with truncate. There were 41 cases per side per command, and I read every exit code. Test setup🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
|
@greptileai review |
|
An unusable REA_PWNTOOLS_MAX_INPUT_BYTES travelled through the shared engine-absence helper, which always stamped configuration_key REA_PWNTOOLS_PYTHON, so a caller following that field was pointed at the Python executable instead of the bound it had just set. The guide also described the refusal as an invalid request while the decoder reports provider_unavailable. Let the failure context carry the key under review and pass the bound's own name at that call site, then state the code callers actually receive in the guide. Assert the key on the projected rejection so the engine default and the bound override each stay attributed to the right setting.
|
Both P2 findings are addressed in 5bb5de7.
Guards added so neither side can drift back silently:
Verification on this box (macOS, Node 26.11.1): The three admission cases are
Both temporary edits were reverted before committing and the pushed tree contains no gate changes; One note left as is on purpose: the |
The
|
| Tree | Scanned files | Clones | Duplicated lines | npm run jscpd |
|---|---|---|---|---|
bb540826 — this PR's base |
2321 | 1427 | 2.98% | exit 0 |
20f51d72 — main when this push was checked |
2361 | 1475 | 3.01% | exit 1 |
b1e17363 — refs/pull/2486/merge |
2364 | 1475 | 3.01% | exit 1 |
The merge tree and current main report the same clone count, so the two commits here add none of it; main crossed 3.0% on its own. 4276aaf1 is 1474 clones / exit 1 on that same check, and the main run for it had already concluded failure at 06:58Z, before this push. Rebasing onto current main would inherit the identical number, so I did not rebase to chase this red.
The other checks in the CI range are green locally on 5bb5de73: tsc --noEmit, knip, oxfmt --check, oxlint (0 errors), docs:check, scan:todos, and the 19 pwntools unit cases. The three Linux-only admission cases passed with the host gate temporarily disabled, as described above.
Summary
The pwntools adapters rejected every artifact above 32 MiB before any analysis ran, and no configuration surface could raise that bound, so ordinary recorded core dumps (the report's own 165 MiB example) were unanalyzable.
This adds
REA_PWNTOOLS_MAX_INPUT_BYTESin front of the shipped default, which is the first option in #2446 — the default stays at 32 MiB so the existing protection is not weakened for anyone who does not opt in.Fixes #2446
What changed
src/native/pwntools/PwntoolsInputLimit.ts(new) — one owner for the bound.undefinedkeepsPWNTOOLS_LIMITS.inputBytes; anything else must be a decimal integer from 1 to 1073741824. The ceiling is tied to the child's existing 3 GiB address-space reservation: the artifact is read into one in-memory buffer and staged again as a private snapshot, so one third of that reservation is the widest bound that still leaves the decoder room.src/native/pwntools/PwntoolsDecoder.ts— resolves the bound from the adapter's own environment, after the existingREA_PWNTOOLS_PYTHONvalidation and before the artifact is read, then passes it toreadStableArtifact. An unusable value is refused asprovider_unavailablewith the constraint text instead of silently falling back to the default. The other budgets (outputBytes,timeoutMs,diagnosticBytes) are untouched.docs/recorded-crashes.md,docs/binary-diagnostics.md— the two places that stated the 32 MiB input bound now say it is raisable and what stays fixed.What this deliberately does not do
Raising the input bound alone does not raise the reply, diagnostic or deadline budgets, so a core that needs more than 64 MiB of reply or 30 s of decoder time now fails at the decoder stage rather than at admission. That is the interaction #2446 describes. I kept the reply/deadline knobs out of this change because widening them is a different decision (it changes what the owned bridge may consume); if you want them configurable too, the same resolver shape extends to them directly.
Verification
src/native/pwntools/PwntoolsInputLimit.test.ts(18 cases, runs on any host) pins: the shipped default and its 32 MiB value; accepted values1, 64 MiB, the report's 172879872, and the ceiling; and rejection of"",0,-1,33554432.0,1e8, a leading space,67_108_864,0x2000000, one above the ceiling, and an integer beyondNumber.MAX_SAFE_INTEGER.tests/boundary/binaryDiagnostics/pwntoolsInputBoundAdmission.test.ts(3 cases) drivesPwntoolsLayoutProviderwith a 33,554,433-byte sparse regular file and asserts the projected caller-visible failure:invalid_request, detail containsSelected artifact exceeds 33554432 bytesREA_PWNTOOLS_MAX_INPUT_BYTES=33554433unreadable_outputwith the owned process'sno replycaptured — admission passed and the bridge really ranREA_PWNTOOLS_MAX_INPUT_BYTES=0provider_unavailable, detail contains the constraint, and no artifact-size text — refused before readingRead this before reviewing those three cases: they are gated with
it.runIf(!unsupportedHost)because the adapter itself refuses non-Linux/x64 hosts before reaching admission. I am on macOS, so to prove the wiring and the mutants I temporarily (a) commented out the adapter's host check and (b) flipped the test'sunsupportedHosttofalse, ran the cases, then reverted both — the committed files contain the original gate and no bypass. On Linux/x64 they run unchanged; if they fail there I will fix them in this PR.Mutation arms, each run, each killed by exactly one case:
inputLimit.bytes→ default)""rejection caseStatic gates on the rebased commit:
tsc --noEmitclean;oxfmt --checkclean;npx knipclean;oxlint0 errors with 3 warnings that are byte-identical to the same file on untouchedorigin/main;vitest --project adapters171 files / 1981 tests passed, 4 skipped.Known collision surface
src/native/pwntools/PwntoolsDecoder.tsis also touched by #2281, #2282, #2284 and #2436. My edit there is one import, one validation block inserted beforephase = "artifact-read", and one argument change, all inside the same guard sequence, so it should rebase cleanly; I will rebase again if it lands first.docs/binary-diagnostics.mdis touched by #2331 — a two-sentence prose edit.Base:
2c7240cf. Head: 1 commit, 6 files.