-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The patch adds a check at the wrong layer\n\nThe 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.\"\n\nThe 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`:\n\n```diff\n async def assign_user_to_session(\n session_id: str,\n user_id: str,\n ) -> ChatSessionInfo:\n session = await get_chat_session(session_id, None)\n if not session:\n raise NotFoundError(f\"Session {session_id} not found\")\n+ if session.user_id is not None and session.user_id != user_id:\n+ logger.warning(\n+ f\"[SECURITY] Attempt to claim session {session_id} by user {user_id}, \"\n+ f\"but it already belongs to user {session.user_id}\"\n+ )\n+ raise NotAuthorizedError(f\"Not authorized to claim session {session_id}\")\n session.user_id = user_id\n session = await upsert_chat_session(session)\n return session\n```\n\nSix 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.\n\nRead 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.\n\n## `user_id=None` is admin mode, by default\n\n`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:\n\n```python\nasync def get_chat_session(\n session_id: str,\n user_id: str | None = None,\n) -> ChatSession | None:\n \"\"\"Get a chat session by ID.\n\n Checks Redis cache first, falls back to database if not found.\n Caches database results back to Redis.\n\n Args:\n session_id: The session ID to fetch.\n user_id: If provided, validates that the session belongs to this user.\n If None, ownership is not validated (admin/system access).\n \"\"\"\n # Try cache first\n try:\n session = await _get_session_from_cache(session_id)\n if session:\n # Verify user ownership if user_id was provided for validation\n if user_id is not None and session.user_id != user_id:\n logger.warning(\n f\"Session {session_id} user id mismatch: {session.user_id} != {user_id}\"\n )\n return None\n return session\n ...\n```\n\nThe 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.\n\nThe 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.\n\nThe 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.\n\n## The same admin-mode call exists in a second caller\n\n`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.\n\nThe first is `service.py:297`, the one named in the CVE. The patch puts a fence behind it.\n\nThe second is `model.py:574`, in `append_and_save_message`:\n\n```python\nasync def append_and_save_message(session_id: str, message: ChatMessage) -> ChatSession:\n \"\"\"Atomically append a message to a session and persist it.\"\"\"\n lock = await _get_session_lock(session_id)\n\n async with lock:\n session = await get_chat_session(session_id)\n if session is None:\n raise ValueError(f\"Session {session_id} not found\")\n\n session.messages.append(message)\n ...\n```\n\n`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.\n\n`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.\n\n## The endpoint exists for a reason, and the reason is at the wrong layer\n\nThe `session_assign_user` route's docstring explains its purpose:\n\n```python\nasync def session_assign_user(\n session_id: str,\n user_id: Annotated[str, Security(auth.get_user_id)],\n) -> dict:\n \"\"\"\n Assign an authenticated user to a chat session.\n\n Used (typically post-login) to claim an existing anonymous session\n as the current authenticated user.\n \"\"\"\n await chat_service.assign_user_to_session(session_id, user_id)\n return {\"status\": \"ok\"}\n```\n\nThe 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.\n\nThe semantics the developer intended: \"claim this session if it is currently unclaimed.\"\n\nThe semantics the code implemented before the patch: \"reassign this session to me, regardless of who currently owns it.\"\n\nThere 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.\n\nThat 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.\n\n## This is `safe-mode-was-opt-in` inside one codebase\n\nPrior posts have traced `safe-mode-was-opt-in` at library/consumer boundaries. [EspoCRM's email template](/posts/espocrm-cve-2026-33657-triple-brace-was-correct) called `Michelf\\Markdown::defaultTransform` and inherited the parser defaults that left HTML and entities unescaped. [DeepSeek-TUI's `task_create` schema](/posts/deepseek-tui-cve-2026-45374-defaults-were-doing-the-work) 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`](/posts/vm2-cve-2026-44004-fix-is-off-by-default) 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.\n\nIn 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.\n\nAutoGPT 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.\n\nThe 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.\n\n## What the advisory does not say\n\nGHSA-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.\n\nThis 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.\n\nPoC: [ZeroPathAI/autogpt-CVE-2026-30950-poc](https://github.com/ZeroPathAI/autogpt-CVE-2026-30950-poc)","closing_line":"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.","hook_md":"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.","post_id":383,"slug":"autogpt-cve-2026-30950-admin-bypass-is-a-default-argument","title":"CVE-2026-30950: AutoGPT's Admin Bypass Is a Default Argument","type":"initial","unreadable_sentence":"The default value of the function unlocks admin mode. Forgetting to pass `user_id` is admin access."} -----BEGIN PGP SIGNATURE----- iHUEARYIAB0WIQRf0htP5+SjynlxywneZjl4jgkQJgUCalfDgAAKCRDeZjl4jgkQ JmCoAQDtPa7GKIw9fKPM0ikCodu0z5KJ2FLs+1yeDPQ6gNQUbwD/UBvKSZEWuMs3 495CQhv/+VZoC3/2rvBhGEBAIjqrvwA= =SH8F -----END PGP SIGNATURE-----