You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[P0] [security] User CRUD/GRANT/REVOKE go through execute_query — no read_only, no audit, no transaction #429
[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.
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.
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.
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.
Activity
fix(admin): enforce read-only connections, and stop the app killing i…
EVWorth commentedon Aug 29, 2026
Largely done in #522, with two parts deliberately not done.
Done:
read_onlyis enforced in the executor for every path, not just EXPLAIN ANALYZE. Two bypasses a leading-keyword check would have missed are covered:WITH ... DELETEis a DELETE, andEXPLAIN 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.dbScopewas fixed in fix(admin): quote passwords as string literals, and names as identifiers #521.Not done, because they are not possible as described:
GRANT/REVOKEforce an implicit commit and cannot be rolled back. Verified: a GRANT inside START TRANSACTION survives ROLLBACK. The partial-failure problem is real and stays open as [P1] [bug] applyChanges runs statements as separate awaits — partial failure corrupts DB #439 with a workable remedy.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.