Skip to content

Clear session-scoped approval state on /resume and /branch - #14246

Closed
Es1la wants to merge 1 commit into
NousResearch:mainfrom
Es1la:fix/gateway-session-boundary-security
Closed

Clear session-scoped approval state on /resume and /branch#14246
Es1la wants to merge 1 commit into
NousResearch:mainfrom
Es1la:fix/gateway-session-boundary-security

Conversation

@Es1la

@Es1la Es1la commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Summary

This fixes a session-boundary state leak in the gateway.

Before this change, session-scoped dangerous-command approvals and /yolo
state were keyed by session_key, but they were not cleared when the user
switched conversations via /resume or /branch. That meant approval state
from the previous conversation could silently carry over into the newly
resumed or branched conversation.

What changed

  • added GatewayRunner._clear_session_boundary_security_state(session_key)
  • clear session-scoped approval state after a successful /resume switch
  • clear session-scoped approval state after a successful /branch switch
  • clear any stale gateway _pending_approvals entry for that session as part
    of the same boundary cleanup

Why this is correct

/resume and /branch are real conversation-boundary operations:
they switch the active transcript to a different session. Session-scoped
dangerous-command approvals should not survive that boundary.

This matches the existing isolation direction already applied to /new and
other session-boundary cleanup paths.

Tests

Added regression tests covering:

  • /resume clears session-scoped approval state
  • /resume clears session-scoped /yolo state
  • /resume clears only the active session’s pending approval cache
  • /branch clears session-scoped approval state
  • /branch clears session-scoped /yolo state
  • /branch does not affect other sessions

Validated with:

uv run pytest tests\gateway\test_session_boundary_security_state.py tests\gateway\test_resume_command.py tests\gateway\test_yolo_command.py -q -n 4

@alt-glitch alt-glitch added type/security Security vulnerability or hardening P1 High — major feature broken, no workaround comp/gateway Gateway runner, session dispatch, delivery labels Apr 23, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Related to #10702 (gateway /resume leaking cached agent state) and #10665 (clear approval state on /new and /reset). This PR extends the same cleanup pattern to /resume and /branch.

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #14266 with your original commit preserved (rebase merge — authorship intact in git log). Also extended the same fix to /new in a follow-up commit on top. Thanks @Es1la!

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

Labels

comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround type/security Security vulnerability or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants