Skip to content

fix(gateway): server-derived segment, grant ceiling, owner-only cancel, agent revoke - #29

Merged
abhay-codes07 merged 1 commit into
mainfrom
fix/self-asserted-inputs-and-session-auth
Sep 5, 2026
Merged

fix(gateway): server-derived segment, grant ceiling, owner-only cancel, agent revoke#29
abhay-codes07 merged 1 commit into
mainfrom
fix/self-asserted-inputs-and-session-auth

Conversation

@abhay-codes07

Copy link
Copy Markdown
Owner

Second security-review pass on the money and authorisation paths. I verified each draft finding against the current tree and fixed only the ones that still reproduce — several (discount floor, webhook status check, approve re-verify, ownership without tier-fallback, re-register tier reset) were already closed and are covered by existing tests.

Fixed

  • S-1 — segment was buyer-asserted. An unauthenticated caller could pass segment=b2b/new and make a gated offer applicable; the fairness ledger then logged a truthful predicate over a false input. server_segment() fixes the segment to facts Bazaar owns (b2b denied; new/returning from the agent's completed-order history; any untouched). The merchant's own admin-authenticated console — and the simulator, which runs with the admin token — may still set a segment, so generated results are unchanged.
  • S-3 — grant amount was unbounded. A T2 agent could self-issue a grant far above its per-order tier ceiling. issue_grant now rejects a grant above the agent's max_order_paise unless admin-issued.
  • S-5 — unsigned sessions had no owner. Any caller with the publicly-listed id could cancel a T0 session and release its hold. Cancel now needs the admin token for an unsigned session; a signed session still needs its owning key.
  • P1-4 — no way to cut off a compromised key. Added admin POST /agents/{keyid}/revoke; a revoked key fails signature verification on its next request.

Documented (fix is prod-scope or would shift committed results)

  • S-2human_present is a self-asserted flag in the demo; the buyer-signed / Razorpay-AFA production path is now named in the threat model.
  • S-4 — prose cannot instruct the ranker, but merchant-supplied aliases do feed relevance; the threat model now says so and names alias caps as the planned hardening.

Four new tests pin S-1, S-3, S-5 and the revoke route. 96 tests, ruff clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01BLrj9TWybDCNw1mWxZgAks

…nly cancel; agent revoke

Second security-review pass on the money and authorisation paths. Only
the findings that reproduced against the current tree are addressed here;
several from the draft (discount floor, webhook status check, approve
re-verify, ownership-without-tier-fallback, re-register tier reset) were
already closed and are covered by existing tests.

- Segment was buyer-asserted (S-1): an unauthenticated caller could pass
  segment=b2b or =new and make a segment-gated offer applicable, and the
  fairness ledger then recorded a truthful predicate over a false input.
  server_segment() now fixes it to facts Bazaar owns — a claimed b2b is
  denied, new/returning follows the agent's completed-order history, any
  is left as-is. The merchant's own admin-authenticated console (and the
  simulator, which runs with the admin token) may still set a segment
  directly, so generated results are unchanged.

- Grant amount was unbounded (S-3): a T2 agent could self-issue a grant
  far above its per-order tier ceiling and block that much against the
  Reserve Pay ledger. issue_grant now rejects a grant above the agent's
  own max_order_paise unless it is admin-issued.

- Unsigned sessions had no owner, so any caller with the (publicly
  listed) id could cancel one and release its hold (S-5). Cancel now
  requires the admin token for a T0 session; a signed session still
  needs its owning key.

- A compromised agent key could not be cut off without a restart
  (P1-4): added an admin POST /agents/{keyid}/revoke. A revoked key
  fails signature verification on its next request (agent_pub returns
  None), so pay-tag routes reject it immediately.

Threat model: documented human_present as a self-asserted flag in the
demo (S-2) with the buyer-signed / AFA production path, and made the
Branded Whisper note precise — prose cannot instruct the ranker, but
merchant-supplied aliases do feed relevance (S-4); alias caps are the
planned hardening.

Four new tests pin S-1, S-3, S-5 and the revoke route. 96 tests, ruff
clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BLrj9TWybDCNw1mWxZgAks
Copilot AI lite review requested due to automatic review settings September 5, 2026 12:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@abhay-codes07
abhay-codes07 merged commit ac7a192 into main Sep 5, 2026
2 checks passed
@abhay-codes07
abhay-codes07 deleted the fix/self-asserted-inputs-and-session-auth branch September 5, 2026 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants