Skip to content

security(auth): transcriber routes authenticate no one -- every caller resolves to DEFAULT_USER #15758

Closed

Description

@mrveiss

Found while delivering #15745's fifth acceptance criterion (the repeatable router-auth guard). transcriber_router (api/transcriber.py, aggregating transcriber/routes/*.py) was rejected as a finding in #15745 itself ("routes and auth live in nested sub-routers not separately registered"). Building the guard's classifier required actually tracing that claim, and it does not hold up.

What the code does

Every transcriber route resolves the caller through transcriber/routes/recordings.py's _user_id(request) (and its siblings in projects.py/transcripts.py):

def _user_id(request: Request) -> str:
    user = getattr(request.state, "user", None)
    return user.id if user else DEFAULT_USER

DEFAULT_USER = "default" is defined in transcriber/deps.py, whose own comment calls it a "Placeholder user ID for routes without real authentication. Replaced by real auth in future milestone." Ownership is then checked via can_access(row, caller_id), which allows access when owner == caller_id -- including the "default" == "default" case for every unauthenticated caller.

transcriber/routes/ai.py:25 and export.py:22 both carry the comment "Development fallback — auth middleware populates request.state.user in production", i.e. the code was written assuming something sets request.state.user before these handlers run.

Nothing sets it

Repo-wide grep -rn "state\.user\s*=" (excluding tests) finds request.state.user assigned only inside three unrelated handlers' own bodies -- api/files.py, api/conversation_files.py, api/sandbox_files.py -- each scoped to that same request's own handler, which cannot help a transcriber request. No add_middleware(...) registered in initialization/middleware.py sets it either; middleware/audit_middleware.py and user_management/middleware/rbac_middleware.py both only read request.state.user, and initialization/middleware.py:287's own comment says the audit middleware assumes it "is already populated" by something upstream -- there is no upstream.

Consequence

Every real request to a transcriber endpoint (upload, list, delete recordings; read/edit transcripts; project CRUD) resolves caller_id to "default" with no login check anywhere in the call path. Since can_access treats every default-owned row as accessible to every default-resolved caller, this is not narrower than the #9968 IDOR it claims to guard against -- it is the same class of exposure, just reached with zero credentials instead of a second account's.

Test coverage (transcriber/tests/test_multiuser_authz.py et al.) does not catch this because its fixture manually injects request.state.user via a test-only dependency ("header-driven request.state.user identity") that does not exist in app_factory.py's real router assembly.

Suggested fix (for the repo owner to decide, not performed here)

Either wire a real Depends(get_current_user) (or equivalent) into transcriber/deps.py::get_db or each route, resolving request.state.user the same way api/transcripts.py::_resolve_user_id already does from an authenticated principal -- or, if transcriber is intentionally single-tenant/local-only, document that explicitly the way api/chat_embed.py:190 documents its own open-by-design posture, so the next reader does not have to re-derive this from four files the way this issue did.

Related

Activity

  1. mrveiss commented on Sep 10, 2026

    @mrveiss
    OwnerAuthor

    Verified independently, and confirmed by the merged router sweep

    api.transcriber is in KNOWN_UNGATED on merged base (#16170) — reached by
    mechanism, not by grep, and confirming this issue from a second direction.

    The request.state.user claim holds. Repo-wide, excluding tests, it is assigned
    in exactly three files:

    api/conversation_files.py:107,623
    api/files.py:234,682,745,800,1058,1165,1226
    api/sandbox_files.py:80
    

    None is a transcriber route, and transcriber_router is mounted at
    core_routers.py:407. So _user_id(request) falls through to
    DEFAULT_USER = "default" on every real request.

    The ownership check is not broken — the identity is

    Worth stating precisely, because deps.py looks like it has a mitigation and does
    not. can_access (transcriber/deps.py:21-41) is a strict policy:

    owner = row.get("user_id")
    return bool(owner) and owner == caller_id

    Its docstring is explicit that DEFAULT_USER row + real caller → DENY, and
    calls that the IDOR from #9968. That check is correct and I could not fault it.

    The defect is upstream of it. Line 27 records the consequence in passing:
    "owner == caller_id → allow (includes the "default" == "default" case)". When
    every caller resolves to "default", strict ownership grants everyone access to
    everything, because they are all genuinely the same principal. The check is doing
    its job on an identity that carries no information.

    This is a documented placeholder, not an oversight

    deps.py:12-13: "Placeholder user ID for routes without real authentication.
    Replaced by real auth in future milestone."

    So the honest framing is not "someone forgot auth" — it is an unfinished
    migration whose marker is still in place while the router is mounted in
    production
    . That changes what the decision is about.

    The decision, which the issue correctly reserves

    • A. Wire Depends(get_current_user) into transcriber/deps.py::get_db or each route. The canonical dependency, 112 importers. Breaks any unauthenticated local use of the transcriber, if that is a supported mode.
    • B. Keep the placeholder and unmount the router until the migration lands. Removes the exposure without deciding the auth model.
    • C. Keep both, and gate the router behind a deployment flag so multi-user installs require auth while single-user installs do not.

    Recommendation: A, unless unauthenticated local use is a supported mode — in
    which case C. Not B, because an unmounted router is unfinished work that will
    be re-mounted by whoever needs it next without re-reading this thread.

    What I need to know to proceed: whether the transcriber is expected to work
    without authentication in a single-user install. That is a product question, not a
    code one, and I could not answer it from the tree — deps.py says "future
    milestone" without saying which mode it is for.

    The one thing that should not happen is the placeholder staying while the router is
    mounted, because #9968 already fixed an IDOR here and this reintroduces its
    precondition by a different route.

  2. added
    needs-decisionBlocked on an owner decision; options and a recommendation are on the issue
    on Sep 10, 2026
  3. mrveiss commented on Sep 11, 2026

    @mrveiss
    OwnerAuthor

    Owner decision, 2026-09-11: option A. Every transcriber route requires login, through the canonical get_current_user, and legacy "default"-owned recordings become admin-only.

    Option A's precondition holds. Installs with auth disabled keep working, because get_current_user gives them a stable admin identity (auth_middleware.py:733-735). The #16259 review verified this.

    The implementation is #16259. It can close this issue once its two test gaps (cross-user tests for ai/ask and the kb routes, and one end-to-end anonymous 401) are filled.

  4. removed
    needs-decisionBlocked on an owner decision; options and a recommendation are on the issue
    on Sep 11, 2026
  5. mrveiss commented on Sep 11, 2026

    @mrveiss
    OwnerAuthor

    Owner ruling, 2026-09-11, asked in the #16259 implementing session: PATCH /api/transcriber/providers is admin-only.

    The question put to the owner: "PATCH /api/transcriber/providers switches the active cloud speech-to-text provider for the whole process, and any logged-in user can call it, so one user can route everyone's audio to a different cloud provider. Should it be admin-only?" The owner answered: "Admin-only PATCH (Recommended)". GET /providers stays login-only, because it returns provider metadata and never keys.

    This supplements option A, which covers legacy rows. It is implemented in #16259 (81b80d0) through transcriber.deps.require_admin.

  6. added this to the v0.9.0 milestone on Sep 12, 2026
  7. mrveiss commented on Sep 13, 2026

    @mrveiss
    OwnerAuthor

    Post-merge closure audit: verified on main at 0abe0d4. This issue has no checkbox ACs, so this comment maps each stated problem to the fix. Fixed by PR #16259, merge commit 9ad9359.

    Stated problem Fix on main
    Every route resolves the caller via _user_id(request) → DEFAULT_USER No def _user_id remains under autobot-backend/transcriber/. Callers go through transcriber/deps.py:61 caller_id_of, which raises 401 at :65 ("Fails closed: never falls back to DEFAULT_USER").
    Nothing sets request.state.user transcriber/deps.py:46 authenticate runs Depends(get_current_user). The transcriber/routes/ tree has 7 route modules, and each one mounts it through APIRouter(..., dependencies=[Depends(authenticate)]): ai.py:22, export.py:19, kb.py:16, projects.py:14, providers.py:29, recordings.py:39, transcripts.py:25. That is the same set as api/transcriber.py:25-31's 7 include_router calls. The second mount path, middleware/builtin/transcriber_extension.py:40-45, imports the same router objects, so it inherits the gate.
    can_access lets every default-resolved caller reach every default-owned row deps.py:86 can_access: only an admin can reach a DEFAULT_USER row (:111). resolve_user_id returns 403 for any principal that resolves to DEFAULT_USER (:41-42).
    Tests inject identity the real app never sets transcriber/tests/test_multiuser_authz.py:345 covers the admin reaching DEFAULT_USER rows and nothing else. :353 covers the no-identity case, which returns 401. repo_tests/router_auth_coverage_test.py has no transcriber entry in KNOWN_UNGATED (0 matches).

    The PR also makes PATCH /providers admin-only (transcriber/routes/providers.py:61, dependencies=[Depends(require_admin)]).

    Not verified: a live authenticated request through the full app. The PR body states the same gap.

    The issue stays closed.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions