Skip to content

Security Audit: SQL injection vulnerability in mcp-server-sqlite #3314

@starbuck100

Description

@starbuck100

AgentAudit Security Audit Report

Metric Value
Package mcp-server-sqlite
Version 2025.4.25
Risk Score 25/100
Result safe
Findings 1 total (1 critical, 0 high, 0 medium, 0 low)

Findings Summary

Severity Title File:Line
Critical SQL injection in describe_table via f-string mcp_server_sqlite/server.py:326

Details

SQL Injection in describe_table Tool

The describe_table tool constructs a SQL query using f-string interpolation without sanitizing the table_name parameter:

results = db._execute_query(
    f"PRAGMA table_info({arguments['table_name']})"
)

Attack Vector:
An attacker could provide a crafted table_name such as:

  • users); DROP TABLE users; --
  • users); SELECT * FROM sqlite_master; --

This would execute arbitrary SQL commands.

Recommendation:

  1. Validate table_name against the list of existing tables before using it
  2. Use parameterized queries where possible
  3. Sanitize the input to only allow alphanumeric characters and underscores

Example Fix:

# Get list of valid tables first
valid_tables = db._execute_query("SELECT name FROM sqlite_master WHERE type='table'")
table_names = [row['name'] for row in valid_tables]

if arguments['table_name'] not in table_names:
    raise ValueError(f"Table '{arguments['table_name']}' does not exist")

# Now safe to use
results = db._execute_query(f"PRAGMA table_info({arguments['table_name']})")

Full Report

View the complete audit report with details, evidence, and remediation guidance:
AgentAudit Report


This audit was performed automatically by AgentAudit, the security registry for AI agent packages. If you believe any finding is incorrect, you can dispute it on the platform.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions