T09 · Insecure Skill Coding Practices
- Location
SKILL.md:191- Finding
MCP write operations lack an enforced authorization and approval gate
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:191-202
Vulnerability Type: Missing authorization enforcement for state-changing MCP operations
Risk Level: HighVulnerable documentation segment:
text ## Governance & Safety The skill delivers reads and writes and records them; it does **not** decide whether a write is permitted. That is your agent's judgement, or the permission of the account you connect it with (point it at a MySQL/MariaDB account granted only SELECT / PROCESS / REPLICATION CLIENT and no write privileges (no INSERT/UPDATE/DELETE/DDL) — writes then fail at the server). There is no read-only switch, policy file, or approval gate. - **Audit is the guarantee, and it is not bypassable.** Every operation — MCP and CLI alike — is logged to `~/.mysql-aiops/audit.db` (relocatable via `MYSQL_AIOPS_HOME`): params, result, status, duration, and the risk tier. The CLI writes the same row the MCP path does. - `MYSQL_AUDIT_APPROVED_BY` / `MYSQL_AUDIT_RATIONALE` are optional annotations recorded on the audit row (who/why); they are never required and never block. - **Runaway guard** — a safety backstop, not authorization: the same call looped in a tight window trips a circuit breaker. Disable with `MYSQL_RUNAWAY_MAX=0`. - Writes support `--dry-run` / `dry_run=True` and double confirmation at the CLI.Related documentation in
references/capabilities.md:58-69identifies write-capable MCP tools includingkill_session,kill_query,drop_index,optimize_table,analyze_table,create_index,set_global_variable, andreset_query_stats.Technical Analysis
The Skill explicitly states that no read-only switch, policy file, or approval gate is enforced. Double confirmation is described only for the CLI layer, while the same write operations are exposed as MCP tools. Consequently, an MCP caller can request a state-changing operation with
dry_run=Falsewithout presenting an opera ...[truncated 2364 chars]- Remediation
View remediation
Remediation Suggestions
- Enforce authorization within every MCP write handler rather than relying on agent judgment or database privileges alone.
- Make MCP write operations default to dry-run and require an explicit transition to execution.
- Require a short-lived, cryptographically strong approval token bound to the exact target, operation, normalized parameters, and expiration time.
- Reject execution if any approved parameter changes between preview and execution.
- Apply confirmation requirements consistently to both CLI and MCP entry points.
- Provide and enforce a read-only operating mode that prevents registration or execution of write tools.
- Default onboarding to a least-privilege read-only database account and require an explicit administrative step to enable maintenance privileges.
- Keep audit logging and runaway protection as defense-in-depth controls, but do not treat them as substitutes for preventive authorization.
