Skip to content

Validate /asyncquery callbacks and bound query request bodies - #195

Merged
maximusunc merged 2 commits into
develfrom
claude/brave-tesla-5gs42a
Oct 29, 2026
Merged

maximusunc merged 2 commits into
develfrom
claude/brave-tesla-5gs42a

Conversation

@maximusunc

Copy link
Copy Markdown
Collaborator

Fixes #180 (callback SSRF): a callback must be http/https and resolve only to public addresses unless the host/network is in CALLBACK_ALLOWED_HOSTS; cloud metadata addresses are refused even when allowlisted. Checked at intake (422, nothing stored) and again in finish_query before delivery. compose.yml allowlists host.docker.internal and the docker bridge range so the local run_query.py --async flow keeps working.

Fixes #183 (unbounded query bodies): /query and /asyncquery read the body through _read_body_within_limit against QUERY_MAX_REQUEST_SIZE (default 100MB, 413 when over). A new REQUEST_BODY_IDLE_TIMEOUT_SEC (default 30s) drops a body that stops arriving with 408 on the query and callback paths, closing the lying-Content-Length slowloris a size cap can't catch.

Claude-Session: https://claude.ai/code/session_01S2yuRDzpv1Yxh7x7StsDVK

claude and others added 2 commits October 29, 2026 15:20
Fixes #180 (callback SSRF): a callback must be http/https and resolve only
to public addresses unless the host/network is in CALLBACK_ALLOWED_HOSTS;
cloud metadata addresses are refused even when allowlisted. Checked at
intake (422, nothing stored) and again in finish_query before delivery.
compose.yml allowlists host.docker.internal and the docker bridge range
so the local run_query.py --async flow keeps working.

Fixes #183 (unbounded query bodies): /query and /asyncquery read the body
through _read_body_within_limit against QUERY_MAX_REQUEST_SIZE (default
100MB, 413 when over). A new REQUEST_BODY_IDLE_TIMEOUT_SEC (default 30s)
drops a body that stops arriving with 408 on the query and callback
paths, closing the lying-Content-Length slowloris a size cap can't catch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S2yuRDzpv1Yxh7x7StsDVK
@maximusunc
maximusunc merged commit 210cdaf into devel Oct 29, 2026
2 checks passed
@maximusunc
maximusunc deleted the claude/brave-tesla-5gs42a branch October 29, 2026 15:49
@codecov

codecov Bot commented Oct 29, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.61644% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.09%. Comparing base (a2550f7) to head (bc0bc97).
⚠️ Report is 6 commits behind head on devel.

Files with missing lines Patch % Lines
shepherd_utils/callback_url.py 83.75% 12 Missing and 1 partial ⚠️
shepherd_server/base_routes.py 88.00% 6 Missing ⚠️
shepherd_server/aras/arax.py 50.00% 2 Missing ⚠️
Files with missing lines Coverage Δ
shepherd_utils/config.py 98.85% <100.00%> (+0.04%) ⬆️
workers/finish_query/worker.py 91.60% <100.00%> (+0.17%) ⬆️
shepherd_server/aras/arax.py 76.56% <50.00%> (-0.36%) ⬇️
shepherd_server/base_routes.py 87.50% <88.00%> (+0.11%) ⬆️
shepherd_utils/callback_url.py 83.75% <83.75%> (ø)

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5341885...bc0bc97. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

maximusunc pushed a commit that referenced this pull request Oct 29, 2026
…aps)

Callback URL validation (intake and again in finish_query) and the query
body size cap / idle timeout (413 / 408) come in as they are. Left out:
devel's TRAPI 2.0 query validation at intake (TRAPIRequestError -> 400, and
the ARAX route's validate_arax_query / parse_arax_query_body); finish_query
keeps 1.6's send_callback (no has_logs).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TtsBikU9y9AFQ5uu9tcioz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants