Skip to content

fix(agent-ipc): record a granted session query in the SEL - #33269

Merged
KiroCrewCaptain merged 1 commit into
mainfrom
crew/slack/ipc-session-query-audit
Nov 8, 2026
Merged

KiroCrewCaptain merged 1 commit into
mainfrom
crew/slack/ipc-session-query-audit

Conversation

@buluoray

@buluoray buluoray commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A granted agent-socket session query is recorded in the operator's SEL, like every other capability grant.

GET /api/ipc/session (src/kiro_crew/dashboard/agent_ipc.py, agent_socket_gate) answers a verified capability holder with the session its stub token names, and returned before any audit call, so that granted capability decision wrote no SEL row. The redemption (_audit) and the internal-route grant (_log_auth) are both recorded. Found by GPT on the 0.12.1 backport #33177; the same code is on main.

Why it matters

Every enforced-harness kirocrew-core resolves its session through this query, so the operator's audit log was missing a permission decision on a common path.

Not a goal

  • Changing what the session query admits or answers.
  • Changing any other SEL row.

What changed (motivation → approach → change)

The session-query success path calls _log_auth(request, "agent-ipc", "granted", "session query <server>") before it answers, the same dashboard.token_auth grant row the internal-route path already writes. The docs spec docs/system-specs/modules/security.md (agent socket) lists it among the recorded decisions.

builder-security checked: no bind, listener, route or auth mechanism changes; this adds an audit write on an existing, already-gated unix-socket route.

Backwards compatibility

Compatible: one more SEL row on a granted session query; responses are unchanged.

Removes nothing.

Tests

Proof: PROVEN test/test_agent_ipc.py::test_a_granted_session_query_writes_one_granted_sel_row (head 246c23f)

  • New test_a_granted_session_query_writes_one_granted_sel_row (test/test_agent_ipc.py) redeems a capability over a real unix listener, makes one session query, and asserts exactly one granted row for /api/ipc/session. With the new line removed it fails (assert [] == [('/api/ipc/s...', 'granted')]). Determinism: 5 of 5 repeats.
  • test/test_agent_ipc.py, test/test_agent_ipc_client.py, test/test_agent_ipc_enforced_spawn_e2e.py: 50 passed.
  • black, isort, flake8, mypy (--platform linux), docs-lint, comment-history, brand and the flake-pattern ratchet pass.

Manual verification

N/A - the test drives the real listener.

Screenshots / video

N/A - no frontend file changes.

Related Issues

Refs #31016, #33177.

Sibling sweep

Siblings: none -- the session query was the only success return in agent_socket_gate without an audit call; redeem and the internal-route grant already write one.

Pattern harvest

Rule candidate: every success return of an auth gate writes its granted audit row before it answers, not only the denials.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

GET /api/ipc/session answered a verified capability holder without
writing any audit row, so a granted capability decision never reached
the operator's SEL. Every other grant on the agent socket is recorded.

The session-query success path now writes the same granted
dashboard.token_auth row as the internal-route grant.

Refs #31016, #33177
@buluoray
buluoray requested review from a team and KiroCrewCaptain as code owners November 8, 2026 15:59
@buluoray
buluoray requested a review from Zedmor November 8, 2026 15:59
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 8, 2026
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 246c23f35392660b1bb41c63044e3c86bbd5c0c7 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 246c23f35392660b1bb41c63044e3c86bbd5c0c7 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. This is a one-line audit write that reuses the existing _log_auth grant row, and the added test fails on base.

What this change ships

Inventory (3 items) — 3 justified

Intent: the operator's audit log should record every granted agent-socket session query, as it already records other capability grants. This is a FIX.

  1. A granted GET /api/ipc/session now writes one dashboard.token_auth granted row to the SEL — justified
  2. The security spec's agent-socket paragraph now lists granted internal-route requests and session queries as recorded — justified
  3. A new test checks that a granted session query writes exactly one granted row — justified

[FIRST-PRINCIPLES-REVIEWED] 246c23f

Description read

[DESCRIPTION-READ] 29d16b2a554d3aa231ceb5c944bda471665a8994903d534b9f97ebeefba74cb9

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 246c23f35392660b1bb41c63044e3c86bbd5c0c7 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the change adds one audit row on an already-gated success path. It reuses the same _log_auth grant row the internal-route grant writes, and nothing is taken away.

Notes

  • capability_session_key() can run on every identity lookup. If it does, each internal-route request may now write two grant rows, one for the query and one for the route. Check that SEL volume is acceptable, or log only the first query per binding.

[DESIGN-REVIEWED] 246c23f

Description read

[DESCRIPTION-READ] 6940bd5150fcae8ca5394f9f8624b1d760dd576bfefc16f2c69a2cec36ff66ed

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 246c23f35392660b1bb41c63044e3c86bbd5c0c7 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 246c23f

Verdict parsed from the review's SHA-scoped output markers for commit 246c23f35392660b1bb41c63044e3c86bbd5c0c7.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 246c23f35392660b1bb41c63044e3c86bbd5c0c7 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 246c23f35392660b1bb41c63044e3c86bbd5c0c7 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 246c23f

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 246c23f35392660b1bb41c63044e3c86bbd5c0c7 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 8, 2026
@KiroCrewCaptain
KiroCrewCaptain enabled auto-merge (squash) November 8, 2026 16:58

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Approved. The review checked these points on head 246c23f:

  • The only change in the gate is one _log_auth(..., "granted", ...) call. It sits on the session query's GET success path in dashboard/agent_ipc.py, after every admit check, and it matches the existing internal-route grant row.
  • The new test fails when that line is removed. It passes on the head.
  • The security.md sentence matches what the code now does.

Security: no admit or deny decision changes, and every refusal still goes through _refuse. _log_auth catches its own exceptions, and the SEL write is only added to a background queue, so a response cannot newly fail or block. The row records the server name the gateway issued. It does not contain the session key or the capability.

Done well: the test checks the exact list of audit rows. A stray denial or a duplicate grant would also make it fail.

Optional:

  • Under an enforced harness, capability_session_key() is not memoised, so each identity lookup adds one more dashboard.token_auth row. A short disposition on the Design note accepting that volume would close it.
  • The release backport #33177 does not carry this line yet and may need the same fix.

@KiroCrewCaptain
KiroCrewCaptain merged commit 8e4486f into main Nov 8, 2026
98 checks passed
@KiroCrewCaptain
KiroCrewCaptain deleted the crew/slack/ipc-session-query-audit branch November 8, 2026 16:59
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 8, 2026
buluoray added a commit that referenced this pull request Nov 8, 2026
GET /api/ipc/session answered a verified capability holder without
writing any audit row, so a granted capability decision never reached
the operator's SEL. Every other grant on the agent socket is recorded.

The session-query success path now writes the same granted
dashboard.token_auth row as the internal-route grant.

Refs #31016, #33177

(cherry picked from commit 8e4486f)

Original author: Ray Xu (#33269).
buluoray added a commit that referenced this pull request Nov 8, 2026
GET /api/ipc/session answered a verified capability holder without
writing any audit row, so a granted capability decision never reached
the operator's SEL. Every other grant on the agent socket is recorded.

The session-query success path now writes the same granted
dashboard.token_auth row as the internal-route grant.

Refs #31016, #33177

(cherry picked from commit 8e4486f)

Original author: Ray Xu (#33269).
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