Skip to content

[P0][security] RoutineViewer DROP routes through raw executeQuery with identifier string concat — no escape, no production-safety, no read-only #393

Closed

Description

@EVWorth

Context

Routine Viewer drop routine action.

Problem

src/components/routine/RoutineViewer.tsx:209-219 (handleDrop) calls api.executeQuery(connectionId, DROP ${routineType} `${database}`.`${routineName}`) with three identifier interpolations and no escape helper. Routine/database names cannot legally contain backticks in MySQL, but the helper-name pattern matches compare F4 (sync-generator.ts:5-7 escapeId unused) and admin F16 (escapeIdentifier mis-named). Concrete: (a) the DROP bypasses resultStore.executeQuery's production-safety check (DESTRUCTIVE regex would trigger confirm dialog — but api.executeQuery is called directly, skipping it). (b) No read_only enforcement (admin F1 pattern). (c) No routine-existence check first. (d) window.confirm is browser-native, not styled, not accessible.

Files

  • src/components/routine/RoutineViewer.tsx:209-219

Repro

  1. Connect to production DB
  2. Open Routine Viewer for sp_test
  3. Click Drop — confirm dialog appears (window.confirm)
  4. The DROP runs without production-safety check from resultStore

Expected

Drop on a non-existent routine returns CoreError::RoutineNotFound. Drop on read_only=true profile is rejected. The styled confirm dialog matches the app's design; ESC closes.

Proposed fix

(1) Add a Tauri command drop_routine(connection_id, database, routine_name, routine_type) -> Result<(), CoreError> in commands/mod.rs that (a) validates the routine exists via inspector.rs:get_routines, (b) checks ConnectionManager::get_profile(connection_id).read_only and rejects with CoreError::ReadOnlyViolation if true, (c) uses ? placeholder binding for the identifier (or server-side escaping), (d) emits a tracing::info!(actor=%connection_user, target=%routine_name) audit line. (2) Frontend handleDrop calls this single command. (3) Replace window.confirm with a styled confirm modal (matching the rest of the app) that shows the routine name and database. (4) Use escapeId from sync-sql-generator.ts (or a new src/lib/sql-quote.ts) at the IPC boundary. Scope: M.

Acceptance

Drop on a non-existent routine returns CoreError::RoutineNotFound. Drop on read_only=true profile is rejected. The styled confirm dialog matches the app's design; ESC closes.

Needs human verify

yes

Doc drift

no

Activity

  1. added
    audit
    severity/p0
    kind/security
    area/routine
    on Jul 31, 2026
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/routineauditkind/securityseverity/p0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions