Skip to content

fix(domain_fronter): prevent panic when brace positions are inverted in fallback JSON extraction#1229

Open
CaptainMirage wants to merge 3 commits into
therealaleph:mainfrom
CaptainMirage:fix/parse-relay-json-inverted-brace
Open

fix(domain_fronter): prevent panic when brace positions are inverted in fallback JSON extraction#1229
CaptainMirage wants to merge 3 commits into
therealaleph:mainfrom
CaptainMirage:fix/parse-relay-json-inverted-brace

Conversation

@CaptainMirage
Copy link
Copy Markdown

three fallback sites in finalize_tunnel_response, finalize_batch_response,
and parse_relay_json use text.find('{') and text.rfind('}') to pull a JSON
object out of a messy response, when the response body is binary garbage,
those bytes can appear in any order, rfind might find '}' at byte 84 while
find finds '{' at byte 157. The slice &text[start..=end] then panics with
"begin > end" and a SIGILL core dump

Added a bounds check at all three sites: if start > end return a structured
BadResponse error instead of slicing and promptly thanos snapping itself

Reproducible whenever Apps Script returns a binary or non-JSON response body,
which happens under quota pressure, transient errors, or when the exit node
returns unexpected content (sometimes managed to reproduce with huge amounts of ping)

…in fallback JSON extraction

In three error-path fallback sites (finalize_tunnel_response,
finalize_batch_response, parse_relay_json), the code uses text.find('{')
and text.rfind('}') to extract a JSON object from a messy response. When
the response body is binary garbage, those byte values can appear in any
order, causing start > end. The subsequent &text[start..=end] slice then
panics with 'begin > end' and a SIGILL core dump.

Add a bounds check at all three sites: if start > end, return a structured
BadResponse error instead of slicing. Reproducible whenever Apps Script
returns a non-JSON binary response body.
@github-actions github-actions Bot added the type: fix fix: PR — auto-applied by release-drafter label May 16, 2026
@CaptainMirage
Copy link
Copy Markdown
Author

welp i somehow managed to pull from the main repo and did this, hold on im gonna fix it

@CaptainMirage
Copy link
Copy Markdown
Author

CaptainMirage commented May 16, 2026

if you may please ignore those 2 commits of trying to merge into the main branch, i somehow managed to run the pull command from an older command and did git pull upstream main and so ii rewired all branch tracking to the main repo and i was running around the problem for an hour, pardon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix fix: PR — auto-applied by release-drafter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant