Skip to content

fix(audit): show authenticated users for Gateway runs - #122484

Merged
joshavant merged 6 commits into
mainfrom
codex/agent-id-p0-local-user-ingress
Aug 12, 2026
Merged

joshavant merged 6 commits into
mainfrom
codex/agent-id-p0-local-user-ingress

Conversation

@joshavant

@joshavant joshavant commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Direct authenticated Gateway runs previously reached execution-identity admission as generic unknown API ingress even though the authenticated WebSocket boundary had already resolved durable user facts. Session creation and run inspection could therefore disagree.

Why This Change Was Made

Authenticated WebSocket attach now prepares one immutable, process-local ingress record for direct run admission. Session creation continues to read the live trusted canonical profile ID so profile linking cannot orphan ownership. Durable profiles may establish attribution-only person identity; paired devices remain device assurance, and shared credentials or ordinary profileless clients remain unattributed.

Maintainer correction for I1 revision 2: ordinary, default-retained session provenance continues to store only the durable profile actor ID. It does not store the profile display label. The sanitized label remains transient and may be retained only through the existing execution-identity audit when that storage is explicitly enabled.

The existing F1C/F1P admission owner and persistence contract remain unchanged. This adds no protocol, config/default, compatibility, storage, public SDK, authority, represented-subject, account-linking, or enrollment surface.

User Impact

Operators can distinguish profiled, paired-device, trusted-proxy/Tailscale, shared-secret, and missing-profile Gateway runs in openclaw audit. Profileless paths remain explicitly unattributed. No credential, route, connection, session, or device identifier is promoted to a person, and no new profile display label is retained by default.

Evidence

  • New regression reproduction before the production correction: src/gateway/server-methods/session-creation-provenance.test.ts failed 2/7 because both ordinary and create-on-run session actors persisted label.
  • Correction-focused suites: 106/106 passed across session provenance, execution-identity admission, the Gateway admission bridge, profile-link ownership siblings, and persisted sessions.create behavior.
  • Exact committed full I1 scenario: passed in 214.434s at 8195100c46a84753fa57290790ccb47ca51fffc8.
    • Profiled run b079c6ed-0694-4c81-aec4-7719607a98c6: attribution-only with durable-profile, Tailscale, and device assurance; audit context SHA-256 d4a3f669166920cd04f9d98f487efaf78a2a32b43abcf8c34757dc495faaa1e3.
    • Profileless run 49f94034-41dd-4c4f-b0aa-69f4088c0642: unattributed; context SHA-256 8ef1a96fa03a605616ecd86b0835b9676742949207b7f036f87ef9c2fc4bee59.
    • Direct SQLite readback proved the profiled session persisted the authenticated profile ID and no createdActor.label; profileless persisted no actor. sessions.list still projected the current profile display at read time.
    • Opt-in execution-identity inspection retained the bounded/redacted label, text/JSON inspection agreed, neither path fabricated a represented subject, and persisted context bytes were identical after Gateway restart.
    • Fresh-install and upgrade-style default-off storage, global audit disable, two distinct repeated executions with exact selection, direct persisted-byte equality, and restart equivalence all passed.
    • Repeated execution IDs: 55c0eedd-d3a6-45f4-9a09-3d85d4f3ef5a and 136542f1-8e45-4da1-a9c0-1ff862837024.
    • QA evidence SHA-256: cd66461acd04562769b91c875d0d735f034e5f1966002fb704ad48ff9dd60a50; scenario summary SHA-256: f91221df8ec1b80e33e7ae1d9fff3951762d50f00b13db675c6eeccd5ac548ce.
  • Exact-branch autoreview at 8195100c46a84753fa57290790ccb47ca51fffc8: clean, TruffleHog clean, no accepted/actionable findings, correctness 0.97.
  • The first local ClawSweeper race found that the frozen audit snapshot could regress session ownership after a profile merge. The fix restores the pre-I1 live canonical session actor ID, adds merge coverage, and keeps the immutable snapshot only at the audit boundary. Its bounded QA cleanup and partial-proof findings were also applied; the partial --i1-only pass mode was removed.
  • Exact changed-files gate: passed in 27m18.725s on Blacksmith Testbox tbx_01kztf8cxee0545nhe6jfacbkz; run https://github.com/openclaw/openclaw/actions/runs/31575729817.
  • Exact-head hosted ClawSweeper: first qualifying race result, no actionable findings, security clear, real behavior verified, proof sufficient, patch/overall 4/6; run https://github.com/openclaw/clawsweeper/actions/runs/31575815550.
  • Exact-head local ClawSweeper completed seconds later. Its direct-run patch review was corroborating; the chat.send item is dispositioned below as a separate owner/scope follow-up. Its CLI-label and transcript-wording observations are non-blocking presentation clarifications, not changed retention behavior.

Evidence Map

Cell Evidence
Changed surface Authenticated Gateway connection facts, direct agent RPC admission, session creator stamp
Entry point src/gateway/server/ws-connection/connect-session.ts authenticated attach
Owner boundary src/gateway/local-user-ingress.ts prepares the frozen connection fact once
Caller Gateway agent request execution captures and transfers the connection principal
Callee Existing prepareAgentRunAdmission validates, redacts, bounds, pseudonymizes, and persists the opt-in audit context
Session owner Session creation reads the live trusted canonical profile ID and persists no label
Sibling surfaces Local CLI, channel, system, recovery, public Plugin SDK, device-only, shared-secret, and missing-profile paths remain unchanged
Tests Profiled, paired-device, shared-secret, trusted-proxy/Tailscale, missing-profile, redaction/bounds, session persistence, direct admission, restart/readback

Owner Boundary and Best-Fix Judgment

Root cause: authenticated attach resolved profile, device, locality, and auth-method facts, but discarded them before direct run admission. The best audit fix is at that producer boundary: prepare one private immutable record and carry it via lifecycle-owned weak maps to the existing admission owner. Session ownership intentionally remains separate: it follows the live canonical trusted profile ID because profile linking can change that ID after attach. Downstream sender inference, credential-specific branches, a second admission path, or a public protocol field would duplicate policy and widen the privacy surface.

No legacy/public path was retained or added. The generic unknown ingress remains only for callers without the authenticated Gateway fact.

Tagged Behavior and Sibling Analysis

  • Resolved durable profile: invoker=present, kind=person, attribution-only; session actor persists only the durable profile ID.
  • Trusted proxy or Tailscale with resolved profile: person attribution plus boundary assurance.
  • Expected authenticated user whose durable profile fails to resolve: invoker=unknown.
  • Paired device: device assurance only; never a human invoker.
  • Token, password, auth-none, or ordinary profileless client: invoker omitted/unattributed.
  • Represented subject: always absent for this change.
  • Local CLI, channel ingress, system ingress, recovery admission, and public Plugin SDK sanitization keep their existing contracts.

Privacy

  • Raw identity references remain transient, non-enumerable process-local weak-map data until the existing hardened admission boundary validates and HMAC-pseudonymizes them.
  • Tokens, passwords, headers, IP addresses, fingerprints, routes, connection IDs, and session keys are never captured as identity facts.
  • Device IDs contribute assurance only and are not projected as people.
  • Profile display labels are secret-redacted and UTF-16-safe capped at 128 characters in the transient prepared fact and again at audit admission.
  • Ordinary session provenance persists no profile display label. The current profile display may still be projected at read time without being copied into session storage.
  • Only explicitly enabled execution-identity audit storage may retain the bounded/redacted label.

Risks and Review Metrics

  • Main risk: incorrect attribution or unintended personal-data retention at an authentication boundary. Mitigation: only durable profiles create a person, session storage keeps only the existing ID, missing promised evidence is unknown, omission stays absent, and deterministic tests cover each tag and the SQLite bytes.
  • Config/default surfaces: 0 added, 0 changed, 0 removed.
  • Protocol/SDK/schema/new-storage/compatibility surfaces: 0 added, 0 changed, 0 removed.
  • Full branch production LOC before move/rename discount: +190/-7, net +183. The positive delta is the authenticated-ingress capability and private owner-boundary carrier; the retention/ownership corrections simplify the session owner and add no capability surface.
  • Full branch tests/test-support: +865/-33. Docs: +24/-0.

Named Follow-up Outside I1 Scope

  • Authenticated chat.send currently enters the shared auto-reply runner with its existing generic/channel ingress and therefore does not gain this direct-agent attribution. The immutable I1 packet explicitly owns direct run admission and forbids crossing another unplanned owner boundary. This should be evaluated as a separate auto-reply/chat admission follow-up rather than silently folded into this PR.

ClawSweeper Rank-up Moves

  • Record the owner decision on authenticated-profile attribution and labels — applied with the independent-audit correction. The maintainer decision is now explicit: retain the existing durable profile actor ID in ordinary session provenance, retain no new display label there, and permit only the bounded/redacted transient label to reach explicitly enabled execution-identity audit storage. @openclaw/openclaw-secops remains requested. The PR remains draft.

Release Note

Authenticated Gateway runs now expose durable user attribution in opt-in audit inspection without treating shared credentials or paired devices as people or newly retaining profile display labels in sessions.

AI Assistance

Codex implemented and validated this change from the I1 revision 2 maintainer coordination packet. The PR remains draft for independent owner review.

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 12, 2026
@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@joshavant
joshavant requested a review from a team August 12, 2026 06:21
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@joshavant joshavant added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 4:10 AM ET / 08:10 UTC.

ClawSweeper review

What this changes

The branch preserves authenticated Gateway profile facts for direct agent-run audit admission while keeping ordinary session provenance limited to the live canonical profile ID.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for a named security-owner decision: the patch is a coherent fix for current-main audit attribution, with no concrete correctness finding found.

Priority: P2
Reviewed head: 8195100c46a84753fa57290790ccb47ca51fffc8
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch and stated end-to-end proof are strong; merge readiness depends on the unresolved security-owner privacy decision.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR body supplies exact-head Gateway/WebSocket execution, audit inspection, and SQLite readback evidence for the changed path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body supplies exact-head Gateway/WebSocket execution, audit inspection, and SQLite readback evidence for the changed path.
Evidence reviewed 6 items Current-main gap: Current main resolves a durable Gateway profile, but the direct-run phase creates a new delivery context and dispatches without carrying it; admission therefore receives generic unknown API ingress.
Authenticated profile producer: Current main resolves and stores the authenticated profile at WebSocket attach, establishing the authoritative producer that the patch uses.
Proposed owner-boundary bridge: The PR freezes profile-derived facts at authenticated attach, distinguishes present, unknown, and absent invokers, and keeps them process-local in a WeakMap until admission.
Findings None None.
Security None None.

How this fits together

Gateway authentication produces trusted connection facts that feed direct agent runs and session creation. This patch carries a frozen attribution record to opt-in audit inspection while session ownership continues to read the current canonical profile.

flowchart LR
A[Gateway authentication] --> B[Prepared connection facts]
B --> C[Direct agent run]
C --> D[Audit admission]
C --> E[Live session owner]
D --> F[Opt-in audit inspection]
E --> G[Session provenance]
Loading

Decision needed

Question Recommendation
Should opt-in execution-identity audit retain pseudonymized authenticated-profile attribution and a bounded redacted display label for direct Gateway runs? Approve the documented audit boundary: Accept durable-profile attribution and bounded redacted labels only when existing execution-identity recording is explicitly enabled.

Why: Repository policy requires an explicit decision before changing retained execution-identity fields, and this PR deliberately expands that sensitive audit context.

Before merge

  • Resolve merge risk (P1) - Merging expands the data captured by opt-in execution-identity audit to include durable-profile attribution and a bounded redacted display label retained for the existing 30-day audit window; a security owner must explicitly accept that privacy boundary.
Agent review details

Security

None.

PR surface

Source +183, Tests +832, Docs +24. Total +1039 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 7 190 7 +183
Tests 5 865 33 +832
Docs 2 24 0 +24
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 1079 40 +1039

Review metrics

Metric Value Why it matters
Production versus test delta production +190/-7 (net +183); tests/test support +865/-33; docs +24/-0 The production growth implements a new private authenticated-ingress carrier and is justified only if the security owner accepts its audit-retention boundary.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/server-methods/session-creation-provenance.test.ts, unknown-data-model-change: src/gateway/server-methods/session-creation-provenance.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Approve the privacy boundary (recommended)
    A security owner can accept the documented opt-in retention of pseudonymized profile attribution and bounded redacted labels.
  2. Pause for a narrower retention design
    Do not merge if the trusted audit domain should not retain display labels, even under the existing opt-in setting.

Technical review

Best possible solution:

Retain the private producer-to-admission handoff, but merge only after the security owner accepts durable-profile attribution and opt-in display-label retention for the trusted operator.read audit domain.

Do we have a high-confidence way to reproduce the issue?

Yes—source reproducible: current main resolves an authenticated profile but discards it before direct agent-run admission, which then uses generic unknown API ingress; no reviewer-side test was run.

Is this the best way to solve the issue?

Yes, technically: recording facts at authenticated attach and handing them privately to the existing admission owner is cleaner than downstream inference, subject to explicit approval of the retention boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b8a0fa2e7a94.

Labels

Label justifications:

  • P2: This improves operator audit attribution without evidence of an urgent runtime, delivery, or data-loss incident.
  • merge-risk: 🚨 security-boundary: The PR adds authenticated profile attribution and a bounded display label to opt-in retained audit context.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body supplies exact-head Gateway/WebSocket execution, audit inspection, and SQLite readback evidence for the changed path.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head Gateway/WebSocket execution, audit inspection, and SQLite readback evidence for the changed path.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Available blame attributes the central audit, Gateway, agent-dispatch, and session-provenance lines to the shallow-boundary commit; older history is unavailable locally. (role: recent current-main area contributor; confidence: medium; commits: f6459a325561; files: src/audit/execution-identity-admission.ts, src/gateway/agent-turn/agent-run-execution-phase.ts, src/gateway/server-methods/session-creation-provenance.ts)
  • openclaw/openclaw-secops: The PR body explicitly retains this group for review of the new opt-in attribution and label-retention boundary. (role: requested security reviewer; confidence: medium; files: src/gateway/local-user-ingress.ts, docs/gateway/audit.md)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Obtain an explicit security-owner decision on durable-profile attribution and bounded display-label retention.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-08-12T06:26:44.672Z sha 65bd7d2 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T07:18:26.466Z sha 1834105 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T08:02:16.955Z sha 8195100 :: needs maintainer review before merge. :: none

@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 12, 2026
@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@joshavant

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 12, 2026
@joshavant
joshavant marked this pull request as ready for review August 12, 2026 08:30
@joshavant
joshavant force-pushed the codex/agent-id-p0-local-user-ingress branch from 0a34658 to 5fb1c46 Compare August 12, 2026 08:38
@joshavant
joshavant enabled auto-merge (squash) August 12, 2026 08:39
@joshavant
joshavant merged commit 3b01ea7 into main Aug 12, 2026
120 checks passed
@joshavant
joshavant deleted the codex/agent-id-p0-local-user-ingress branch August 12, 2026 08:50
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 13, 2026
* fix(audit): show authenticated users for Gateway runs

* fix(audit): keep profile labels out of sessions

* test(qa): verify session label retention at storage

* fix(sessions): preserve canonical profile ownership

* test(qa): require full identity inspection proof

* docs(agents): preserve execution identity ownership boundary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant