Skip to content

[Bug]: SQL engine flags all '--' line comments as injection β€” false positives erode boundary trustΒ #31

Description

QWED-MCP Audit Finding: LOW-03

Severity: 🟒 LOW
Component: sql_engine.py β€” INJECTION_PATTERNS
Audit ID: LOW-03
Re-audit of v0.2.1: Finding is NEW


Description

The injection pattern set includes:

r"--[^\n]*",

This flags every SQL line comment as a potential injection β€” including idiomatic, documented queries:

SELECT id, email FROM users  -- only fetch non-PII columns
WHERE active = 1

verify_sql_query returns verified=False for this query. Any developer schema that ships with inline comments (standard practice in migration files and ORM-generated SQL) is blocked wholesale.

False positives at the verification boundary are not harmless: repeated blocking of legitimate code trains consumers to distrust or bypass the guard β€” the same erosion dynamic documented in #13 for open().


Why This Violates QWED Philosophy

  • Principle 3 β€” Deterministic Decisions: A comment is not deterministic evidence of injection. The pattern encodes a heuristic ("comments are suspicious") that produces both noise and, conversely, no protection against actual comment-based bypasses in this architecture (the query never executes here β€” the engine only judges patterns).
  • Consistency with [Bug]: Code engine blocks open() causing false positives on legitimate QWED SDK usageΒ #13's lesson: guards that block safe code while missing dangerous alternatives are worse than no guard.

Expected Behavior

  • Remove the bare --[^\n]* pattern.
  • Retain genuinely dangerous comment-adjacent patterns only where they combine with injection structure (e.g., ' ; -- statement termination followed by comment is already covered by '\s*;\s*--).
  • Regression test: a commented legitimate query passes; ' OR '1'='1' -- still fails.

Environment

Field Value
QWED-MCP Version 0.2.1
Component SQL Verification Engine
File src/qwed_mcp/engines/sql_engine.py (L29–38)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions