Skip to content

[P1] [bug] Production safety regex misses GRANT/REVOKE/RENAME/KILL + conditional comments #415

Closed

Description

@EVWorth

[P1] [bug] Production safety regex misses GRANT/REVOKE/RENAME/KILL/LOCK/SET PASSWORD + conditional comments

Context

DESTRUCTIVE_PATTERN = /\b(DROP|DELETE|TRUNCATE|ALTER)\b/i is the production guard for SQL execution.

Problem

Per docs/audits/results.md F20.

Misses: RENAME TABLE (irreversible), GRANT ALL, REVOKE ALL, SET PASSWORD FOR, LOCK TABLES WRITE, KILL. MySQL conditional comment /*! DROP */ TABLE users bypasses because the JS regex doesn't strip comments. DR'op' TABLE users (string-split identifier) also bypasses.

Files

  • src/stores/resultStore.ts:8

Repro (if applicable)

Static analysis only.

Expected

GRANT ALL ON *.* TO 'alice'@'%' against a production connection shows the confirm dialog. RENAME TABLE users TO users_old shows the dialog. SELECT still goes through.

Proposed fix

Scope M. Extend regex to /\b(DROP|DELETE|TRUNCATE|ALTER|RENAME|GRANT|REVOKE|SET\s+PASSWORD|KILL|LOCK\s+TABLES)\b/i. Strip -- and /* */ comments before matching. Consider blocking multi-statement batches on production.

Acceptance

GRANT/REVOKE/RENAME/SET PASSWORD/KILL/LOCK trigger the dialog; SELECT still passes.

Needs human verify

Yes

Labels: audit, area/results, severity/p1, kind/bug

Activity

  1. added
    audit
    severity/p1
    kind/bug
    area/results
    on Jul 31, 2026
  2. EVWorth commented on Sep 4, 2026

    @EVWorth
    OwnerAuthor

    Fixed by #531 (commit b4297c1). The four-verb regex was replaced with src/lib/sql-safety.ts, which strips string literals and comments before matching — and specifically unwraps MySQL conditional comments (/*!50000 DROP ... */) rather than stripping them, because the server executes their contents. GRANT, REVOKE, RENAME and KILL are in the verb set, and CTE-prefixed writes resolve through statement_after_cte.

    Not auto-closed because the PR body wrote Refs #415 rather than a closing keyword.

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/resultsauditkind/bugseverity/p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions