Repository navigation
fix(rules): GraphQL probes fetch undecoded and inflate no further than their cap #722 - #765
Merged
Merged
Conversation
3 tasks
nc9
force-pushed
the
fix/graphql-probe-undecoded-722
branch
from
October 14, 2026 11:26
513f933 to
793aa27
Compare
nc9
marked this pull request as ready for review
October 14, 2026 11:26
|
Reviewed the diff and the
What I checked:
|
…n their cap #722 sendGraphqlProbe called globalThis.fetch, and Bun inflates a Content-Encoding body in full as it arrives, before the probe's capped read, so a probed endpoint could answer with a gzip or brotli bomb and cost the audit gigabytes. The probe now sends through fetchUndecoded (decompress: false plus the shared Accept-Encoding) and its capped read pulls from decodedBody, which decodes lazily, so GRAPHQL_RESPONSE_CAPS bounds the decoded body and the work to produce it. A body that does not decode fails the probe as an error, as a network failure does. Tests: 1 GiB gzip and brotli bombs read to the 1 MB cap under 256 MiB of RSS growth; a fetch spy shows decompress: false and the Accept-Encoding; a gzip-encoded schema parses, and the introspection rule reaches the same checks, as with the plain one. Existing GraphQL rule tests unchanged. Signed-off-by: Nik Cubrilovic <[email protected]>
…722 Cancelling a fetch body does not close the connection in Bun, which keeps downloading the rest until the request's signal fires, so a capped probe of an endless answer pulled bytes for the full 10 s timeout. The probe's signal now includes a controller aborted once the probe is done. A raw Bun.listen test shows the connection closing within 2 s of the probe returning (it stayed open past 5 s without the abort). Comments say the caps count decoded bytes. Signed-off-by: Nik Cubrilovic <[email protected]>
nc9
force-pushed
the
fix/graphql-probe-undecoded-722
branch
from
October 14, 2026 13:42
793aa27 to
f4d98c5
Compare
|
Reviewed the diff and the
Test coverage is good: bombs for both gzip and brotli, a spy on the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #722.
What changed
sendGraphqlProbe(packages/rules/src/security/graphql-probe.ts), which sends every request forsecurity/graphql-introspectionandsecurity/graphql-get-mutations, calledglobalThis.fetchand then read the body under its byte cap. Bun inflates aContent-Encodingbody in full as it arrives, before any reader runs, so a site with active probing on could answer a probe with a gzip or brotli bomb and cost the audit gigabytes of memory. Since #699 (squirrelscan/repo#2717), every other request the crawl and the audit send to a site avoids this.fetchUndecodedfrom@squirrelscan/utils/response-body, which setsdecompress: falseand the sharedAccept-Encoding: gzip, deflate, br, zstd, so the request still looks the same to the site. The URL, method, body, cookies (credentials: "omit"),redirect: "manual", the budget and the timeout are unchanged.decodedBody(res), which undoes the coding lazily, soGRAPHQL_RESPONSE_CAPS(1 MB introspection, 64 KB no-op mutation) bounds both the decoded body and the work to produce it. A body that does not decode fails the read, and the probe returns{ sent: true, error }, the same as a network failure.fetchUndecodedcalls the globalfetchat call time, so a runtime that wrapsfetchstill sees every probe, anddecompress: falsereaches it as long as the wrapper passesinitthrough (checked in review).Acceptance criteria
fetchUndecoded), and its body is read through the shared decoder no further thanGRAPHQL_RESPONSE_CAPS.Bun.serve, inpackages/rules/tests/graphql-probe-decoding-722.test.ts, modelled onpackages/utils/tests/fetch-undecoded.test.ts.decompress: falseand the shared Accept-Encoding. A gzip-encoded GraphQL answer parses to the sameparseGraphqlBodyresult as the plain one, andsecurity/graphql-introspectionreturns identical checks over gzip.security/graphql-introspectionandsecurity/graphql-get-mutationsfindings are unchanged on the existing rule tests (graphql-probe,graphql-introspection,graphql-get-mutations: 54 pass, untouched).Verification
bun test tests/graphql-probe-decoding-722.test.tsinpackages/rules: 6 pass, bombs included. The connection test uses a rawBun.listenserver with an endless body and requires the close within 2 s of the probe returning; without the abort the connection was still open at 5 s.tsgo --noEmitinpackages/rules: clean. The new test file passes oxfmt; oxlint is clean on both files.graphql-probe.tsalready had oxfmt drift on main, which I left alone.docs/:tangly check --strictpasses. Both rule pages now say the read limit counts the decompressed answer.Agent skill
No change needed.