Repository navigation
Description
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_USERDEFAULT_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
- security(auth): ten registered routers have no authentication, six of them exposing write operations #15745 -- the sweep this contradicts (rejected transcriber_router as "auth lives in nested sub-routers")
- security(transcriber): can_access grants every authenticated user access to DEFAULT_USER legacy rows — IDOR in multi-user mode (PR #9955) #9968 -- the IDOR this pattern reintroduces without authentication
Activity
fix(auth): make the ungated-core-router sweep repeatable (#15745) (#1…
test(auth): drop knowledge_cognition from the tracked exemptions now …
fix(security): the cognition-store seed admin gate now actually execu…
security(auth): enumerate router gating by mechanism, before fixing a…
mrveiss commentedon Sep 10, 2026
Verified independently, and confirmed by the merged router sweep
api.transcriberis inKNOWN_UNGATEDon merged base (#16170) — reached bymechanism, not by grep, and confirming this issue from a second direction.
The
request.state.userclaim holds. Repo-wide, excluding tests, it is assignedin exactly three files:
None is a transcriber route, and
transcriber_routeris mounted atcore_routers.py:407. So_user_id(request)falls through toDEFAULT_USER = "default"on every real request.The ownership check is not broken — the identity is
Worth stating precisely, because
deps.pylooks like it has a mitigation and doesnot.
can_access(transcriber/deps.py:21-41) is a strict policy:Its docstring is explicit that
DEFAULT_USERrow + real caller → DENY, andcalls 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)". Whenevery caller resolves to
"default", strict ownership grants everyone access toeverything, 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
Depends(get_current_user)intotranscriber/deps.py::get_dbor each route. The canonical dependency, 112 importers. Breaks any unauthenticated local use of the transcriber, if that is a supported mode.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.pysays "futuremilestone" 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.
security(auth): authenticate every transcriber route, and stop anonym…
fix(transcriber): seed the legacy row directly now that every route a…
test(guards): drop the transcriber from the core guard exemptions now…
mrveiss commentedon Sep 11, 2026
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_usergives 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/askand thekbroutes, and one end-to-end anonymous 401) are filled.security(transcriber): reserve the legacy owner id, make PATCH /provi…
mrveiss commentedon Sep 11, 2026
Owner ruling, 2026-09-11, asked in the #16259 implementing session:
PATCH /api/transcriber/providersis 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 /providersstays 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.fix(transcriber): hide the admin-only provider setting from non-admin…
test(user-management): give the reserved-username tests a deliverable…
test(user-management): drop the literal password from the reserved-us…
security(auth): admin-gate the open routers, settings, teams and user…
security(auth): authenticate every transcriber route, and stop anonym…
mrveiss commentedon Sep 13, 2026
Post-merge closure audit: verified on
mainat 0abe0d4. This issue has no checkbox ACs, so this comment maps each stated problem to the fix. Fixed by PR #16259, merge commit 9ad9359.main_user_id(request)→DEFAULT_USERdef _user_idremains underautobot-backend/transcriber/. Callers go throughtranscriber/deps.py:61caller_id_of, which raises 401 at:65("Fails closed: never falls back to DEFAULT_USER").request.state.usertranscriber/deps.py:46authenticaterunsDepends(get_current_user). Thetranscriber/routes/tree has 7 route modules, and each one mounts it throughAPIRouter(..., 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 asapi/transcriber.py:25-31's 7include_routercalls. The second mount path,middleware/builtin/transcriber_extension.py:40-45, imports the same router objects, so it inherits the gate.can_accesslets every default-resolved caller reach every default-owned rowdeps.py:86can_access: only an admin can reach aDEFAULT_USERrow (:111).resolve_user_idreturns 403 for any principal that resolves toDEFAULT_USER(:41-42).transcriber/tests/test_multiuser_authz.py:345covers the admin reachingDEFAULT_USERrows and nothing else.:353covers the no-identity case, which returns 401.repo_tests/router_auth_coverage_test.pyhas notranscriberentry inKNOWN_UNGATED(0 matches).The PR also makes
PATCH /providersadmin-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.