Repository navigation
Fail closed on malformed streamed fetch bodies - #48
Closed
cursor[bot] wants to merge 3 commits into
Closed
cursor[bot] wants to merge 3 commits into
cursor[bot] wants to merge 3 commits into
Conversation
Co-authored-by: Andre Schu <[email protected]>
Co-authored-by: Andre Schu <[email protected]>
Co-authored-by: Andre Schu <[email protected]>
1 of 3 tasks
Owner
|
Audit: write-failure preserve / temp-commit integrity covered by #60. Streamed-body and base64/leetspeak sanitizer extras were unique to this draft; not required to close the provenance/symlink gap and left for a later pass if still failing on main. Closing as superseded for the quarantine pile by #60. |
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.
Bug and impact
Malformed streamed fetch bodies from an allowlisted registry/Antigen host could escape the existing fail-closed error contract. Invalid UTF-8 in registry fetch raised a raw
UnicodeDecodeError; scalar JSON in Antigen fetch raised a rawTypeError; streamed non-200 and L402 responses were not closed before raising. In CLI/library paths this can crash fetch workflows, and repeated streamed error/challenge responses can leak HTTP resources.Root cause
http_body.read_response_json()decoded bytes outside the JSON error boundary, while Antigen payload extraction assumed decoded JSON was always a dict. The Antigen early-error branches also raised before closing streamed responses.Fix
json.JSONDecodeErrorso existing callers returninvalid_json/FetchError("invalid_json").FetchError("unrecognized_payload_shape").Validation
UnicodeDecodeError, rawTypeError, and missingclose()calls.PYTHONPATH=src python3 -m pytest tests/test_appsec_fetch_body_caps.py tests/test_antigen_p1_nostr.py tests/test_registry_fetch_r4.py tests/test_registry_ssot.py tests/test_registry_load_order_r5.py tests/test_appsec_antigen_mcp_gates.py tests/test_security_regressions.py -q-> 100 passed, 1 skipped.PYTHONPATH=src python3 -m compileall -q src/scp && git diff --check-> passed.PYTHONPATH=src python3 -m pytest tests/test_appsec_fetch_body_caps.py -q-> 12 passed.PYTHONPATH=src python3 -m pytest -q-> 358 passed, 3 skipped, 3 known baseline failures (test_vendored_scp_mcp_v1_contract_sha256,test_vendored_scp_mcp_v1_1_contract_sha256,test_rt11_authority_only_is_reversal).