Skip to content

fix(gateway): block unauthorized session lifecycle sources - #125889

Merged
steipete merged 2 commits into
mainfrom
steipete/priceless-joliot-906043
Aug 18, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/priceless-joliot-906043

Conversation

@steipete

@steipete steipete commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where multi-profile operators with write scope could apply session lifecycle operations to source sessions they were not permitted to participate in. Legitimate message-cut fork operations could also be rejected because their protocol target was read from the wrong field.

Why This Change Was Made

Session lifecycle authorization now uses method-specific protocol target extraction, includes recovery, and revalidates participation inside the exact SQLite create, fork, and recovery commit transactions after asynchronous work. Operator scopes, protocol shapes, storage schema, and compatibility behavior are unchanged.

This is AI-assisted work reviewed and understood by the author.

User Impact

Multi-profile operators can expect session create, fork, rewind, branch-switch, and recovery flows to honor the source session's participation boundary consistently. Authorized message-cut forks continue to work, while lifecycle writes stop if participation changes before commit.

Evidence

  • Real-behavior proof: an isolated dev Gateway accepted two distinct trusted-proxy profiles over real WebSockets with no production credentials. After the owner changed the source session to read-only, the outsider was denied for sessions.create, sessions.fork, and sessions.recover, while the owner reached each handler. One temporary proof test passed on Blacksmith Testbox tbx_01m0asx8fgmxt9t31cnwpqcd6c: https://github.com/openclaw/openclaw/actions/runs/32158334652. The temporary test was removed before publication.

  • Fresh focused Testbox proof passed 14 tests total (four changed-behavior cases plus all ten parent-fork storage tests) on tbx_01m0at51bg4gmw2za55mqwcrk8: https://github.com/openclaw/openclaw/actions/runs/32158747022.

  • After CI exposed two branch lint defects, Testbox tbx_01m0atjf37yhsjpb8d8639rk5r passed formatting, the exact check-lint-core-2 command, the same four focused behavior cases, and all ten parent-fork tests: https://github.com/openclaw/openclaw/actions/runs/32159438407.

    node scripts/run-vitest.mjs src/gateway/server-methods.authorization.test.ts src/gateway/session-sharing.test.ts src/gateway/server.sessions.recover.test.ts -t "authorizes lifecycle targets|extracts every message-cut|revalidates participation at the recovery writer commit"
    node scripts/run-vitest.mjs src/gateway/server.sessions.create.test.ts -t "revalidates parent participation before committing a fork transcript"
    node scripts/run-vitest.mjs src/config/sessions/session-accessor.parent-fork.test.ts
  • Earlier local focused proof passed 73 router/lifecycle tests and all 10 parent-fork storage tests.

  • git diff --check passed.

  • .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --stream-engine-output completed clean with no accepted/actionable findings on final head 6652b6e1881bb75dc5ec4d1ecd100d2ac320f7e0.

  • A broader earlier run of node scripts/run-vitest.mjs src/gateway/server.sessions.create.test.ts had one unrelated worktree fixture failure because that fixture's temporary workspace was not a Git checkout. The new create race test passes independently, as shown above.

  • Production LOC: +92/-51 (net +41). Tests: +406/-0. The production growth carries participation revalidation through distinct create, same-database fork, cross-database fork, transcript append, and recovery writer commit boundaries; collapsing those boundaries would weaken the transaction-local authority check.

  • Security-owner review is required before merge and will be requested from @openclaw/openclaw-secops for this authorization boundary.

  • No changelog edit: normal PR release-note context is captured here.

@clawsweeper

clawsweeper Bot commented Aug 18, 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 gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Aug 18, 2026
@steipete
steipete marked this pull request as ready for review August 18, 2026 16:12
@steipete
steipete requested a review from a team as a code owner August 18, 2026 16:12
@steipete steipete self-assigned this Aug 18, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Land-ready evidence for head 6652b6e1881bb75dc5ec4d1ecd100d2ac320f7e0:

The remaining mandatory gate is approval from a non-author security/session owner. Review is requested from @openclaw/openclaw-secops; ClawSweeper review is also in progress on this head.

@steipete
steipete merged commit 96d603f into main Aug 18, 2026
229 checks passed
@steipete
steipete deleted the steipete/priceless-joliot-906043 branch August 18, 2026 17:17
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 20, 2026
…125889)

* fix(gateway): enforce session participation at lifecycle commits

* refactor(gateway): simplify session target extraction
a-yeyang pushed a commit to a-yeyang/openclaw that referenced this pull request Aug 23, 2026
…ript-event file

Rebasing onto origin/main (which landed PR openclaw#125889's session-lifecycle
authority check) conflicted with this branch's prior commit that split
appendTranscriptEvent/appendTranscriptEventSyncCore out of
session-accessor.sqlite-transcript-write.ts into a new file. Resolving
that conflict by accepting the split-commit's deletion silently dropped
the options.beforeCommitInTransaction?.() invocation the upstream change
added inside the write-transaction callback, so the caller-supplied
authority/participation check (session-accessor.entry-mutation.ts's
commitGuard) would have silently no-op'd for every raw (non-message)
transcript event append.

Restore the call at the top of both transaction callbacks, matching
upstream's placement, so the check still runs synchronously inside the
transaction before the append proceeds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant