Skip to content

fix: stop managed artifact reads after session access is revoked - #174137

Merged
shakkernerd merged 1 commit into
mainfrom
fix/managed-artifact-authority
Oct 16, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
fix/managed-artifact-authority

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #174136.

What Problem This Solves

A reader could keep using a generated attachment's download URL after losing access to its conversation. Making a shared conversation draft stopped new artifact requests, but an already issued managed-media URL still served the original bytes until its five-minute ticket expired.

User Impact

Existing managed image, thumbnail, audio, video, and document URLs now require the issuing reader's current session access. URLs retain their five-minute lifetime, existing media routes, and continued use after an ordinary WebSocket disconnect. Current device, role, source, and session-access revocation stop reads. Admitted streams retain their source until completion and stop if the reader's authority is revoked.

Thumbnail sizing, media playback conversion, byte ranges, and the authenticated owner route for older clients are preserved. No configuration or data migration is required.

Why This Change Was Made

Managed downloads used a signed ticket that identified the attachment and expiry but did not retain the requesting reader. Both the stable artifact-ID path and legacy transcript-URL path now use the existing bounded artifact-download grant owner. Source preparation only identifies the transcript-backed media; the artifact RPC transfers its retained requester authority and current session-read facts into the grant. Each issuing connection retains at most 128 grants. Disconnected entries keep the five-minute expiry and are reclaimed by the existing maintenance sweep or Gateway teardown; this is a per-connection and time bound, not a global grant limit. Retained requester authority stays in the existing revocation index after its RPC returns, so profile-role changes still reach a disconnected issuer. Ordinary artifact-byte grants retain their existing connection lifetime.

The managed HTTP adapter keeps its established media behavior while checking the grant before disclosure and during streaming. It also rejects using the grant for another attachment or through the generic artifact-byte route. The separate stateless signing implementation is removed, and managed grant responses use private, no-store caching.

Evidence

The isolated RPC/HTTP regression reproduced the defect on the introduction base and again on target commit 7160e1a: correct original and thumbnail media were readable, then the retained original URL still returned HTTP 200 after committed shared-to-draft visibility. The attachment stayed in the transcript.

The fix passes that boundary for both issuing paths, including ordinary disconnect and committed visibility/profile-role revocation. Existing media Gateway E2E passes its full/thumbnail/range/expiry/archive/shared-owner controls (3 cases, 37.89 seconds). The focused media/lifecycle batch passed 383 cases in 23 files (540.10 seconds including required build preparation); affected source-authority consumers and compiler graphs also pass. Hosted CI passed on the published head.

An additional isolated runtime scenario uses a temporary variant of the existing HTTP fixture on production commit 4814d56. The production dispatcher issues the grants, and the client receives real HTTP body bytes before the fixture calls invalidateGatewayDeviceRevocation or invalidateGatewayPolicyClient with revokeSource: true. Both transfers abort with the correct partial bytes; subsequent full and thumbnail requests through both issuers return 404. Ordinary disconnect remains allowed. The complete scenario, response settlement, and grant-index cleanup passed in 47.95 seconds without a production-code change.

Redacted terminal output:

{"proof":"managed-final-effect","authority":"device","stage":"authorized-and-disconnected","variants":4,"status":200,"originalBytes":12588868}
{"proof":"managed-final-effect","authority":"device","stage":"revoked-during-transfer","status":200,"firstBytesBeforeRevocation":true,"expectedBytes":12588868,"receivedBytes":131072,"aborted":true}
{"proof":"managed-final-effect","authority":"device","stage":"subsequent-full-and-thumbnail","variants":4,"status":404}
{"proof":"managed-final-effect","authority":"source","stage":"authorized-and-disconnected","variants":4,"status":200,"originalBytes":12588868}
{"proof":"managed-final-effect","authority":"source","stage":"revoked-during-transfer","status":200,"firstBytesBeforeRevocation":true,"expectedBytes":12588868,"receivedBytes":131072,"aborted":true}
{"proof":"managed-final-effect","authority":"source","stage":"subsequent-full-and-thumbnail","variants":4,"status":404}

Independent source review completed without findings. ClawSweeper is being refreshed with the additional final-effect evidence.

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 4814d5642489a6f7cd12ddbe0ecde67b62c3b35a
  • Maintainer: @shakkernerd
  • Repository role: maintain

These security sensitive changes were made:

  • src/gateway/server/ws-connection/authenticated-request-dispatch.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: XL labels Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Bind managed attachment downloads to the issuing reader’s current authority and stop delivery when that authority is revoked.

Example: A reader obtains a managed image URL before its shared conversation becomes draft.

  • Before: The retained URL continues returning HTTP 200 until its five-minute ticket expires.
  • After: The URL returns HTTP 404 after access revocation, while ordinary WebSocket disconnection still permits authorized reads.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A complete, focused authority repair with real HTTP boundary evidence, passing exact-head checks, and no actionable findings; proof uses an isolated production-owner fixture.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Exact-head terminal output exercises production dispatcher issuance and real HTTP delivery in isolated state, preserving authorized disconnected reads and demonstrating device/source revocation aborting active transfers and denying subsequent requests through both issuers; the earlier boundary results cover committed visibility/profile-role changes, resolving the previous rank-up request.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A reader who loses conversation access can continue downloading its managed attachments through an already issued URL.
Reason: The maintainer-authored direction restores current-access enforcement without introducing configuration, persisted formats, or a competing authority owner.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current access-revocation defect with no actionable findings; the added runtime evidence resolves the previous authority-proof blocker.

Priority: P2
Reviewed head: 4814d5642489a6f7cd12ddbe0ecde67b62c3b35a

Before merge

None.

Findings

None.

Agent review details

How this fits together

The Gateway artifact RPC authorizes a transcript attachment and issues a download grant; the managed HTTP adapter consumes that grant, verifies current reader and session authority, and returns image, thumbnail, playback, or document bytes.

flowchart TD
Reader --> ArtifactRPC
ArtifactRPC --> SessionAuthority
ArtifactRPC --> DownloadGrant
DownloadGrant --> ManagedHTTP
SessionAuthority --> ManagedHTTP
ManagedHTTP --> ByteStream
ByteStream --> Reader
Loading

Technical review

Best possible solution:

Merge the shared grant-owner repair with retained reader authority and revocation checks throughout managed delivery.

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

Current-main ticket verification lacks issuing-reader authority, matching the linked report’s isolated shared-to-draft RPC/HTTP reproduction; this read-only review ran no target code.

Is this the best way to solve the issue?

The repair addresses the missing authority at the existing grant owner, removes the parallel signing implementation, and preserves established media adapters and ordinary disconnect behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9db9baeb763d.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Current-main defect remains: Fetched main still uses stateless managed tickets containing attachment, session, and expiry without retaining the issuing reader; the linked report establishes the corresponding isolated RPC/HTTP failure. (src/gateway/managed-image-tickets.ts:14, 9db9baeb763d)
  • Authority transfers into the existing grant owner: Both managed issuing paths retain request authority and selected session-read facts, transfer their release operations to the grant, and remove the former stateless signing implementation. (src/gateway/server-methods/artifacts.ts:288, 4814d5642489)
  • Final-effect enforcement: Managed delivery checks the grant before disclosure and checks retained authority before yielding each streamed chunk; failures destroy the transfer rather than completing a truncated response successfully. (src/gateway/http-byte-range.ts:220, 4814d5642489)
  • Disconnected authority remains revocable: The dispatcher retains source clients in the existing authority registry until their retained source subscription is released, preserving profile and origin revocation after RPC completion and transport loss. (src/gateway/server/ws-connection/authenticated-request-dispatch.ts:226, 4814d5642489)
  • Previous proof request addressed: The updated PR body supplies exact-head runtime output through the production dispatcher and real HTTP delivery: authorized disconnected reads succeed; device and source revocation interrupt a 12,588,868-byte transfer after 131,072 bytes; subsequent full and thumbnail requests through both issuers return 404. (4814d5642489)
  • Exact-head checks pass: The linked hosted run completed successfully on the reviewed SHA; live commit statuses report successful CI, dependency, and security-sensitive gates, and paginated check runs contain no failed or pending checks. (4814d5642489)

Likely related people:

  • Peter Steinberger: Raw commit f79a0e7 adds src/gateway/artifact-download-grants.ts:1 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f79a0e7ae99c; files: src/gateway/artifact-download-grants.ts)
  • Shakker: Raw commit 6b4ebc0 adds src/gateway/server/ws-connection/authenticated-request-dispatch.ts:178 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6b4ebc043bc8; files: src/gateway/server/ws-connection/authenticated-request-dispatch.ts)

PR surface

Source +99, Tests +318, Docs +5. Total +422 across 19 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 10 314 215 +99
Tests 8 432 114 +318
Docs 1 7 2 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 753 331 +422

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #174136
Summary: This PR directly repairs the linked report’s missing issuing-reader authority on retained managed attachment URLs.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The defect permits continued attachment reads after session-access revocation within a bounded ticket lifetime; no production incident or broader exposure is established.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-16T11:17:22.336Z sha 4814d56 :: needs real behavior proof before merge. :: none

Reviewed October 16, 2026, 8:13 AM ET / 12:13 UTC (Revision 2).

@shakkernerd shakkernerd self-assigned this Oct 16, 2026
@shakkernerd

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Oct 16, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@shakkernerd
shakkernerd merged commit 8bedee5 into main Oct 16, 2026
182 checks passed
@shakkernerd
shakkernerd deleted the fix/managed-artifact-authority branch October 16, 2026 12:18
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: Managed attachment URLs stop serving media after the issuing reader loses access while ordinary disconnects preserve authorized reads.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…nclaw#174137)

Keep managed attachment downloads bound to the issuing reader’s current session access, including thumbnail and active stream reads, while preserving authorized downloads across ordinary disconnects.

Fixes openclaw#174136.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. docs Improvements or additions to documentation gateway Gateway runtime 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. security-sensitive-changed 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.

Managed artifact URLs remain readable after session access is revoked

1 participant