The patch for CVE-2026-30950 in AutoGPT is six lines of new code in one function in backend/copilot/service.py. The line that calls get_chat_session(session_id, None) is not one of them. That call still passes the second argument as None, and the docstring of get_chat_session still explains what that means: "If None, ownership is not validated (admin/system access)." Significant Gravitas added a manual ownership check after the function returned. The function itself was not changed. The default argument that turns the ownership filter off is still in the signature.
CVE-2026-30950: AutoGPT's Admin Bypass Is a Default Argument
vendor
patterns
cve
proof of concept
The patch adds a check at the wrong layer
The CVE record describes CVE-2026-30950 as Authenticated Session Hijacking via IDOR in AutoGPT versions 0.6.36 through 0.6.50, CWE-862, CVSS 7.1. The PATCH /sessions/{session_id}/assign-user endpoint authenticates the caller via JWT and then reassigns ownership of an arbitrary session to that caller, with no check that the caller currently owns the session. The advisory names the mechanism in one clause: "the service layer invokes the session lookup with user_id=None, which the data access layer interprets as a privileged/system call that bypasses the ownership filter."
The fixing commit is eca7b5e7, authored by Reinier van der Leer on 2026-03-08, titled "Merge commit from fork." It changes two files. One change removes a redundant status_code=200 from a FastAPI decorator. The substantive change is in autogpt_platform/backend/backend/copilot/service.py:
async def assign_user_to_session(
session_id: str,
user_id: str,
) -> ChatSessionInfo:
session = await get_chat_session(session_id, None)
if not session:
raise NotFoundError(f"Session {session_id} not found")
+ if session.user_id is not None and session.user_id != user_id:
+ logger.warning(
+ f"[SECURITY] Attempt to claim session {session_id} by user {user_id}, "
+ f"but it already belongs to user {session.user_id}"
+ )
+ raise NotAuthorizedError(f"Not authorized to claim session {session_id}")
session.user_id = user_id
session = await upsert_chat_session(session)
return sessionSix new lines. The fix asks, after the session has already been returned, whether the session belongs to someone other than the caller. If it does, refuse. If it does not, proceed.
Read the line above the diff. get_chat_session(session_id, None) is unchanged. The second argument is still None. The bypass that the advisory names as the bug is still in the call.
user_id=None is admin mode, by default
get_chat_session lives in autogpt_platform/backend/backend/copilot/model.py. Both the vulnerable 0.6.50 release and the patched 0.6.51 release ship the same signature:
async def get_chat_session(
session_id: str,
user_id: str | None = None,
) -> ChatSession | None:
"""Get a chat session by ID.
Checks Redis cache first, falls back to database if not found.
Caches database results back to Redis.
Args:
session_id: The session ID to fetch.
user_id: If provided, validates that the session belongs to this user.
If None, ownership is not validated (admin/system access).
"""
# Try cache first
try:
session = await _get_session_from_cache(session_id)
if session:
# Verify user ownership if user_id was provided for validation
if user_id is not None and session.user_id != user_id:
logger.warning(
f"Session {session_id} user id mismatch: {session.user_id} != {user_id}"
)
return None
return session
...The function's second parameter is declared user_id: str | None = None. The default value is None. The ownership-mismatch check is gated on user_id is not None. When the caller accepts the default, the conjunction short-circuits, the mismatch warning never fires, and the session is returned regardless of who it belongs to.
The docstring is explicit about what this means. "If None, ownership is not validated (admin/system access)." That sentence is in the source tree of the patched release. The author of the function understood the contract and wrote it down. The contract is that the function has two modes, an ownership-checked mode and an admin mode, and the way callers select the admin mode is by not passing the second argument.
The line in the service layer that triggers the CVE is await get_chat_session(session_id, None). The line passes None explicitly. It did not have to. The same effect is available by writing await get_chat_session(session_id). The function's default parameter is admin mode.
The same admin-mode call exists in a second caller
get_chat_session is called in nine places inside autogpt_platform/backend/backend/copilot/. Seven of those calls pass a real user ID through to the second argument: routes.py:71, routes.py:288, routes.py:828 (health check, with a system-owned user ID), baseline/service.py:134, sdk/service.py:582, plus two test files. Two callers do not.
The first is service.py:297, the one named in the CVE. The patch puts a fence behind it.
The second is model.py:574, in append_and_save_message:
async def append_and_save_message(session_id: str, message: ChatMessage) -> ChatSession:
"""Atomically append a message to a session and persist it."""
lock = await _get_session_lock(session_id)
async with lock:
session = await get_chat_session(session_id)
if session is None:
raise ValueError(f"Session {session_id} not found")
session.messages.append(message)
...get_chat_session(session_id) here is the same admin-mode call as get_chat_session(session_id, None). The default argument is None. The lookup bypasses the ownership filter. This function is called from routes.py:468 inside stream_chat_post, which earlier in the request lifecycle calls _validate_and_get_session(session_id, user_id) to enforce ownership for the read. The earlier validation does not propagate. By the time append_and_save_message runs, the function it reaches for is the one whose contract says ownership is not validated.
append_and_save_message is not the CVE. The message it appends is the authenticated user's own. The bounded surface area means a directly attacker-useful primitive is not obvious from the function alone. The point is not that this function is exploitable today. The point is that this is the second caller in the same module that reached for the admin-mode default and accepted it, in a project where the admin-mode contract has just been the load-bearing piece of a 7.1 CVE.
The endpoint exists for a reason, and the reason is at the wrong layer
The session_assign_user route's docstring explains its purpose:
async def session_assign_user(
session_id: str,
user_id: Annotated[str, Security(auth.get_user_id)],
) -> dict:
"""
Assign an authenticated user to a chat session.
Used (typically post-login) to claim an existing anonymous session
as the current authenticated user.
"""
await chat_service.assign_user_to_session(session_id, user_id)
return {"status": "ok"}The legitimate flow is anonymous-session claim. A user opens AutoGPT without logging in. The platform creates a chat session with user_id=None in the database row. The user types into the session. Then the user logs in. The frontend wants to attach the now-authenticated identity to the session that was already started. It calls PATCH /sessions/{session_id}/assign-user with the authenticated JWT.
The semantics the developer intended: "claim this session if it is currently unclaimed."
The semantics the code implemented before the patch: "reassign this session to me, regardless of who currently owns it."
There is a version of this fix that lives in the data access layer. Remove the user_id: str | None = None default. Make user_id mandatory. Add a separate function for the admin-mode lookup, named _get_session_unfiltered, with no second parameter at all and a docstring that says "do not call this from a request handler." The service layer's assign_user_to_session would then either (a) pass the caller's user_id and accept that re-claim of an already-owned session is permitted, or (b) read the session through _get_session_unfiltered and apply the anonymous-claim policy explicitly. Either way, the bypass primitive lives in a function that nobody can reach by default.
That is not the version of the fix that shipped. The version that shipped retains the admin-mode default and the dual-purpose function, and adds a per-caller authorization check at the service layer.
This is safe-mode-was-opt-in inside one codebase
Prior posts have traced safe-mode-was-opt-in at library/consumer boundaries. EspoCRM's email template called Michelf\Markdown::defaultTransform and inherited the parser defaults that left HTML and entities unescaped. DeepSeek-TUI's task_create schema accepted JSON from a language model that omitted the allow_shell and auto_approve flags, and unwrap_or(true) filled them in. vm2's bufferAllocLimit defaulted to Infinity and the regression test the maintainer shipped with the fix asserts that a default sandbox can still allocate 64 MB host buffers.
In each of those, a library exposed a safety flag and the default was the unsafe value. The fix was either to flip the default or to wire the consumer through a wrapper that set the flag.
AutoGPT 0.6.50 exhibits the same shape with the library and the consumer in the same git repository. backend/copilot/model.py exposes get_chat_session(session_id, user_id=None). The second parameter is the ownership-check toggle. The default selects no check. backend/copilot/service.py is the consumer. The fix did not flip the default. It put a guard around one call site and left the toggle in place.
The reason that matters is that "the library and the consumer live in the same codebase" is not a mitigation. Anyone who writes a new function in backend/copilot/service.py or backend/api/features/chat/routes.py next quarter, who needs to look up a chat session, who reads the IDE autocomplete and sees get_chat_session(session_id: str, user_id: str | None = None), who knows the system has Redis caching and JWT authentication and FastAPI dependencies and does not have time to read the docstring, will write get_chat_session(session_id). The function will return the session. The session will belong to whoever it belongs to. The default argument is the bypass.
What the advisory does not say
GHSA-q58p-v9r9-7gqj names the vulnerability as Missing Authorization. The CVSS vector is AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:L. The fix is described as available in 0.6.51. The advisory does not mention that the data-layer function the vulnerable service relied on is unchanged in 0.6.51. It does not mention that the function's second parameter still defaults to a value the docstring identifies as admin/system access. It does not mention the other call site in append_and_save_message that reaches for the same admin mode by default.
This is what a design-debt driver looks like at function-signature granularity. The primitive is the dual-purpose lookup, the recurrence vector is the default argument, and the patch addresses the instance the CVE record names while the primitive sits in model.py waiting for the next caller to autocomplete past it. The CVE record is accurate about CVE-2026-30950. The CVE record is also a per-instance description of a primitive that the codebase still ships. The patch closes this instance.
The patch did not change get_chat_session. It changed one of its callers. The default argument that grants admin access is still there, the docstring still names it, and the next caller that reaches for get_chat_session(session_id) will get the same bypass that this CVE was filed for.