Repository navigation
fix(server): Validate targets before binding authorization [SAO-20817] - #305
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
jasmine-ab-tea
approved these changes
Nov 18, 2026
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.
Problem
VictorOps incident 62266 included a
POST /api/v1/controls/{control_id}/clone-and-bindrequest with target identifiers only in the URL and no JSON body. Agent Control sent a missing target context to Orbit's binding-write authorization check; Orbit returned 400 and Agent Control surfaced 502. A sampled trace shows that 400-to-502 path. Review also reproduced the same 502 behavior for missing-target bodies on four other binding-write routes.Endpoint behavior
Previously fixed GET route: PR #297 was merged on 2026-11-05. It changed target-required
GET /api/v1/control-bindingsrequests with missing or incompletetarget_type/target_idfrom an Orbit 400 surfaced as 502 to a local422 VALIDATION_ERRORbefore the upstream call.control_idalone is insufficient; it is a filter inside an authorized target. The rule is enabled only for the relevant Orbit management-authorization deployment, so generic upstreams retain their namespace-wide list behavior. PR #305 does not introduce that GET behavior; it reuses the same target-pair predicate while preserving the flag and query contract.GET /api/v1/control-bindings(already fixed in #297)target_typeandtarget_idquery parametersbinding_list_requires_targetis enabled.control_idremains an optional filter within that target. PR #305 only refactors its target-pair check.POST /api/v1/controls/{control_id}/clone-and-bindtarget_binding.target_typeandtarget_binding.target_idPUT /api/v1/control-bindingstarget_typeandtarget_idPATCH /api/v1/control-bindings/by-keytarget_typeandtarget_idPUT /api/v1/control-bindings/by-keytarget_typeandtarget_idPOST /api/v1/control-bindings/by-key:deletetarget_typeandtarget_idThe four body-bearing binding-write routes are additional scope found during review. Eight HTTP/HTTPS regression cases reproduced their prior 502 behavior before the fix and returned 422 afterward. They share one
_binding_body_contextpath, so the same validation applies consistently.Reuse and preserved behavior
complete_target_context()is the shared, side-effect-free check for a nonblank string pair. Each endpoint still extracts fields from its own documented location and supplies its own 422 detail/hint. GET keeps its deployment flag and existing query-field length behavior; JSON-body routes keep their 255-character model limit. The optional control-list attachment target uses the same pair check. Public binding models and attachment filter query parameters now express the nonblank rule with a\Spattern, without trimming opaque identifiers. Valid targets still reach Orbit, and an Orbit permission denial remains 403. Clone-and-bind may perform its separate control-create/read authorization checks before local target rejection; this change prevents the invalid binding-write check.FastAPI rejects malformed
application/jsonbefore binding authorization. It does not pre-parse an empty body or malformedtext/plainbody, so the body context builder catchesValueErrorfromrequest.json()and returns local 422. An Astra dry-run review caught the missing fallback as a real 500 regression; 16 HTTP/HTTPS cases across all four body-bearing binding routes failed before the fix and passed afterward. The caller still needs a separate correction to send the documented nested clone-and-bind body.Review note: The four body-bearing binding routes intentionally report an invalid target as 422 before their authorizer runs, including with header auth. HTTP tests pin that order and confirm that a complete target still requires credentials (401 without them).
The UI CI job is pinned to Ubuntu 24.04 because Playwright 1.57 cannot install Chromium on the
ubuntu-latestUbuntu 26.04 image.Ticket: SAO-20817
Validation
make checkpassed on Python 3.12, including 1,093 server tests, lint, and type checks. Focused auth-order and attachment-filter tests passed; the OpenAPI spec generated with the nonblank pattern. Local UI ESLint, TypeScript type check, and Prettier check passed. The local TypeScript SDK generation check requires a Speakeasy login, so the hosted SDK CI remains the generation gate.main; GitHub reportsverified=true/reason=validfor every commit. Astra's third dry-run round on476bd42returnedapprovewith no remaining findings; it was not posted to GitHub. Exact-head server, SDK, UI, build, title, and Codecov checks all pass. Human review is still required.The exact bodies of the other incident requests and the deployed US1 revisions remain unverified. No production change or live US1 test was performed.