Skip to content

[P0] [security] User CRUD/GRANT/REVOKE go through execute_query — no read_only, no audit, no transaction #429

Closed

Description

@EVWorth

[P0] [security] User CRUD / GRANT / REVOKE / DROP USER all go through execute_query — no read_only enforcement, no audit trail, no parameterized SQL

Context

DESIGN_REQUIREMENTS FR-7.1 promises dedicated CREATE USER, ALTER USER, DROP USER, GRANT, REVOKE commands. The implementation routes every user/admin mutation through api.executeQuery.

Problem

Per docs/audits/admin.md F1.

(a) read_only profile flag is not enforced in QueryExecutor::execute_owned — a user who enabled Read-only mode on a production profile can still create/drop accounts or grant SUPER to themselves. (b) execute_query accepts raw SQL with no parameterization. (c) tracing::instrument records SQL preview but not actor identity. (d) applyChanges runs GRANT, REVOKE, FLUSH PRIVILEGES as separate awaits; partial failure leaves DB in inconsistent state. (e) dbScope built with raw backticks (UserManagement.tsx:760) — unescaped.

Files

  • src/components/admin/UserManagement.tsx:111-125, 591-624, 715-789
  • src/components/admin/CreateUserDialog.tsx:59-72
  • src/components/admin/ChangePasswordDialog.tsx:31-46
  • src/components/admin/userPrivileges.ts:62-64

Repro (if applicable)

Static analysis only.

Expected

Dedicated typed commands create_user, drop_user, grant_privileges, revoke_privileges in mas-admin that (1) check profile.read_only, (2) wrap in a single transaction, (3) emit audit logs with actor identity.

Proposed fix

Scope L. Add typed Tauri commands in mas-admin/src/lib.rs; reject via CoreError::ReadOnlyViolation if read_only=true; wrap multi-statement changes in sqlx::Transaction.

Acceptance

Connecting with read_only=true and attempting CREATE USER returns CoreError::ReadOnlyViolation at the backend. Multi-statement revoke+grant either fully applies or rolls back. tracing logs show actor/target/grants spec.

Needs human verify

Yes

Labels: audit, area/admin, severity/p0, kind/security

Activity

  1. added
    audit
    severity/p0
    kind/security
    area/admin
    on Jul 31, 2026
  2. EVWorth commented on Aug 29, 2026

    @EVWorth
    OwnerAuthor

    Largely done in #522, with two parts deliberately not done.

    Done:

    • (a) read_only is enforced in the executor for every path, not just EXPLAIN ANALYZE. Two bypasses a leading-keyword check would have missed are covered: WITH ... DELETE is a DELETE, and EXPLAIN ANALYZE <write> executes the write — via the Run button its leading EXPLAIN looked harmless. The verb list is an allowlist, so an unrecognised statement is refused rather than waved through.
    • (c) Writes carry the account they ran as in the log line.
    • (e) dbScope was fixed in fix(admin): quote passwords as string literals, and names as identifiers #521.

    Not done, because they are not possible as described:

    The dedicated typed commands the issue proposes were not added. Enforcing in the executor gives the security property for every caller — the editor, designer and import paths too — rather than only the admin ones, which seemed the better trade. Reopen if you want the typed commands for their own sake.

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

    area/adminauditkind/securityseverity/p0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions