Skip to content

fix(auth): enforce role permissions on REST storage and settings mutations #60

Closed

Description

@spelech

Confirmed finding

With AUTH_ENABLED=true, a valid viewer API key can upload and delete managed files and write administrative settings through REST. Authentication is enforced, but these endpoints do not enforce the advertised role hierarchy.

Tested revision: 41ec093a745f1c0277893dc8f758b96b216c970f, isolated SQLite + embedded Qdrant deployment. All inputs were synthetic.

Reproduction

  1. Bootstrap an admin API key and issue a key with role=viewer.
  2. With the viewer key, POST /admin/api/storage/upload containing a harmless text file.
  3. DELETE that fixture through /admin/api/storage/file?path=viewer-write.txt.
  4. Read the current auto-sync interval and POST the same value to /admin/api/settings/auto-sync.

All three writes returned HTTP 200, not 403. Upload indexed the fixture and delete removed it. In contrast, the same viewer correctly received 403 from /admin/api/auth/keys, and anonymous requests received 401.

Relevant code

Expected outcome

  • Apply explicit least-privilege role policies to REST operations, consistent with the MCP role contract: viewers read, editors perform permitted content mutations, admins manage configuration/credentials/keys.
  • Validate the intended policy across repository/path/storage/settings endpoints rather than fixing only the three demonstrated routes.
  • Reject unauthorized operations before filesystem, vector-store, configuration, or relational side effects.
  • Add role-matrix regression tests including anonymous/invalid/revoked keys, viewer denials, editor content writes, and admin-only configuration.

No claim of a complete security audit is made; this records the reproduced role-policy failures.

Activity

  1. google-labs-jules commented on Oct 27, 2026

    @google-labs-jules
    Contributor

    Jules is on it. When finished, you will see another comment and be able to review a PR.

  2. spelech commented on Oct 27, 2026

    @spelech
    OwnerAuthor

    Triage & Implementation Brief

    1. Scope & Effort

    • Effort: Small (~40 lines of code + test suite)
    • Component: Security / REST RBAC

    2. Root Cause & Context

    While AuthMiddleware verifies token validity, individual REST router endpoints in app/api/routers/storage.py and app/api/routers/settings.py lack role check dependencies. As a result, API keys with role=viewer are able to upload/delete files and write administrative settings.

    3. Implementation Plan

    • Apply FastAPI role dependencies to all mutating endpoints:
      • Admin only (require_role("admin")): /admin/api/settings/*, /admin/api/auth/*, vector store test/config.
      • Editor (require_role("editor")): /admin/api/storage/upload, /admin/api/storage/file (DELETE), repo registration/sync.
      • Viewer (require_role("viewer")): Read-only operations (GET /admin/api/stats, GET /admin/api/repos, file reads, search).
    • Ensure unauthorized calls return HTTP 403 Forbidden before executing filesystem or database operations.
    • Add a comprehensive role matrix test suite.

    4. Acceptance Criteria

    • Viewer keys receive HTTP 403 on upload, delete, and settings mutations.
    • Editor keys can manage content but receive HTTP 403 on admin settings.
    • Admin keys retain full permissions.
    • Anonymous requests receive HTTP 401.
  3. google-labs-jules commented on Oct 27, 2026

    @google-labs-jules
    Contributor

    Ready for a review! A PR has been created.

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

    julesgoogle-jules-bot

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions