Repository navigation
fix: critical gateway-only audit writers raise; pin origin consumers - #39243
chenmingwei23 wants to merge 4 commits into
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: Notes
[DESIGN-REVIEWED] 8c6c4f4 Description read[DESCRIPTION-READ] 9e4280a79a86a846192ca93bde996deaa9f213d84e6a917c0d5567a6215fe58b That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: the fix is one branch at the mechanism that ignored Notes
What this change shipsInventory (3 items) — 2 justifiedIntent: when an app backend asks for a critical audit row and the gateway can't take it, the action is refused instead of going ahead unaudited. FIX.
[FIRST-PRINCIPLES-REVIEWED] 8c6c4f4 Description read[DESCRIPTION-READ] 359f8d011fac4216f39146436a9962a75f86b0c0dbc0225a47f674abb913cf4d That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
d1aa2f6 to
5b59d52
Compare
416300d to
d06c324
Compare
…rmalized operation Spawned app backends hold no SEL key, so their audit rows reach the log through the gateway's _sel route and a client that only holds the per-app secret. These tests pin: - the route and the client write the row as app:<name> with the operation kept under the app's namespace; - the operation is normalized and the row is kept: 'Publish Doc' is stored as 'Publish_Doc', a newline or control character becomes '_', a 300-character operation is clipped to 64 and an empty one is stored as 'unnamed'; - a backend has no SEL key, and the builtin backends' own operation names are stored as written; - a critical write the gateway did not take refuses the action.
…nnot read the SEL key
A spawned app backend now holds only its per-app secret. Its audit rows go to the
gateway's POST /api/apps/{name}/_sel route through apps/sel_client.py, and the gateway
signs and appends them as app:<name>. The backend's sel() is that client, the SEL key
is masked from the backend, and the built-in security callers log through sel().
The operation is normalized by one function, sel_client.normalize_operation, that the
client and the route both call: every character outside [A-Za-z0-9_.-] becomes '_',
the result is clipped to 64 characters, and an empty one is stored as 'unnamed'. The row
is kept, so no newline or control character reaches a text view of the log. Credentials
are redacted before the operation is normalized, including a tool name.
The client posts the row as UTF-8 rather than ASCII escapes, so three 500-character
fields of astral characters stay under the route's 16 KiB body cap, and a lone surrogate
in a field is replaced instead of raising.
A critical write waits (bounded, as the exit drain does) for the rows queued before it, so
it cannot land ahead of an earlier row.
The docs describe the route, the client and the normalized operation.
5b59d52 to
186ec81
Compare
d06c324 to
8c6c4f4
Compare
186ec81 to
f856349
Compare
8bf494a to
894d554
Compare
b399a28 to
045e1ed
Compare
Stacked on #38807 (base: mkt-app/sel-gateway-client).
Problem / Motivation
Goal: A critical audit call to a gateway-only writer in an app backend refuses the action instead of passing silently.
In
SelClient, a call such aslog_sel_rotation(..., critical=True)only logged a warning and returned. The module sayscritical=Truemeans the caller refuses the action it could not audit, so the action went ahead with no audit row.Why it matters
An app backend that asks for a critical row from a writer the route does not take lost the row and still proceeded. This is a LOW finding from the #38807 review.
Not a goal
_selroute accepts.What changed (motivation -> approach -> change)
apps/sel_client.py: the gateway-only writer stub raisesSelClientErrorwhencritical=True, and the docstring says so.apps/backend.py: a comment on the no-marker spawn. The spawn dropsKIROCREW_GATEWAY_ORIGINthere. Every reader of that variable (the SEL client and the Dev Fleet pointer broker) trades the app secret atPOST /api/apps/<app>/token, andvalidate_app_secretrefuses that without the marker, so no consumer is lost. Comment only, no behaviour change.test/test_sel_backend_no_origin.py: a pin test that lists the origin readers and the token exchange they use, and checksvalidate_app_secretrefuses without the marker.Backwards compatibility
Compatible: only a
critical=Truecall to a gateway-only writer changes, from a warning toSelClientError; non-critical calls and every accepted writer behave as before.Removes nothing: no path, row, key or function is hidden, renamed or deleted.
Tests
test_a_critical_call_to_a_gateway_only_writer_raises: raises oncritical=True, still one warning for non-critical calls.test_every_origin_consumer_needs_the_app_token_a_no_marker_app_cannot_mint: pins the origin readers and the marker requirement.Proof: not provable -- other: no Python test environment on the authoring crew, CI runs the tests
Manual verification
N/A -- unit coverage sufficient; the change is one branch in a client stub.
Real-machine verification
N/A -- the diff runs only in unit tests; no service or real machine path changes.
Screenshots / video
N/A -- no user-visible UI change.
Related Issues
Follow-up to #38807.
Sibling sweep
Swept: grep -n "gateway-only" src/kiro_crew/apps/sel_client.py
Siblings: none -- the stub in getattr is the only place a gateway-only writer is handled
Pattern harvest
Not generalizable: a one-off stub that ignored the critical flag its sibling writers honour.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.