Skip to content

[BUG] undo_last() is not session-scoped and can undo actions belonging to other active sessions #266

@Ridanshi

Description

@Ridanshi

Summary

undo_last() operates on a global in-memory action stack and does not filter actions by session.

As a result, one session can undo actions that belong to another session.

Affected Files

  • core/hybrid/action_logger.py
  • api/routes/actions.py

Root Cause

undo_last() simply pops the most recent action from the global stack.

The API endpoint does not provide session context when invoking undo operations.

This causes the most recently logged action to be undone regardless of ownership.

Reproduction

  1. Create Session A.
  2. Create Session B.
  3. Log an action in Session A.
  4. Log an action in Session B.
  5. Trigger undo from Session A.
  6. Observe that Session B's action is undone.

Expected Behavior

Undo operations should only affect actions belonging to the requesting session.

Actual Behavior

Undo operations can affect foreign sessions.

Why This Is Difficult To Detect

Single-session tests never expose ownership violations.

The bug only appears with concurrent sessions.

Production Impact

  • Cross-session corruption
  • Unexpected undo behavior
  • Ownership violations
  • Loss of user trust

Severity

High

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions