Skip to main content
Glama

Detectar riesgo de inyección SQL

detect_sql_injection_risk

Analiza el código fuente de una herramienta MCP que ejecuta una consulta SQL a partir de una entrada que le pasa el agente (un nombre de usuario, un filtro de búsqueda, un identificador cualquiera) en busca de dos señales de riesgo distintas: (1) el patrón clásico de inyección — una llamada que ejecuta SQL crudo (.query, .execute, .raw, .exec_driver_sql, mysqli_query, y equivalentes) con la consulta armada por concatenación o interpolación de una variable/entrada externa, en vez de un parámetro preparado, sin ninguna función de escape reconocible cerca; y (2) un patrón propio de Garita motivado por un caso real: el código (o su comentario/descripción) afirma que la herramienta es de "solo lectura", pero no hay ninguna señal de que eso se aplique de verdad a nivel de base de datos — exactamente lo que Datadog Security Labs encontró en el servidor MCP de referencia de Postgres de Anthropic, donde la restricción de "solo lectura" vivía únicamente en el texto que lee el agente, no como un permiso real. Motivada por un censo real de 2026 sobre 9.695 servidores MCP escaneados: inyección SQL fue el 4.2% de los 4.982 problemas encontrados (211 casos). También documentado en CVE-2026-7206 (sqlite-mcp) y CVE-2025-66335 (Apache Doris MCP Server). Es un análisis estático por patrones de texto (no ejecuta el código) — mismo enfoque que detect_ssrf_risk, detect_path_traversal_risk y detect_command_injection_risk. Requiere una llave de acceso válida (usos gratis o créditos) — ver POST /crear-llave.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "codigo": "<codigo>"
    },
    "name": "detect_sql_injection_risk"
  }
}

Input Schema

NameRequiredDescriptionDefault
codigoYesEl código fuente de la función/herramienta que ejecuta una consulta SQL, en texto plano.
lenguajeNoSolo informativo (ej. "javascript", "python") — la detección ya cubre varios lenguajes a la vez, este campo no cambia el resultado.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does disclose important behavior: static text-pattern analysis, multi-language coverage, and authentication requirements. However it never says what the tool returns, how many findings come back, what the severity/confidence signal looks like, or whether the two risk patterns are reported distinctly.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The core definition is front-loaded and precise, but the body is bloated with motivational material: 2026 census statistics, two CVE identifiers, and an extended anecdote about Datadog Security Labs and the Anthropic Postgres MCP server. Those do not help an agent decide to call the tool or fill its parameters.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 2-parameter tool with a fully documented schema this is mostly sufficient, but there is no output schema and the description never explains the shape of the result, which is the main remaining gap for an agent deciding how to consume the response.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and both parameters are already documented, including that lenguaje is informative and does not change the result. The description adds no parameter-level detail beyond what the schema states, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ("Analiza el código fuente de una herramienta MCP que ejecuta una consulta SQL") and then enumerates the two exact patterns it looks for: raw SQL execution with concatenated/interpolated input, and a "solo lectura" claim with no database-level enforcement. It also distinguishes itself from siblings by naming detect_ssrf_risk, detect_path_traversal_risk and detect_command_injection_risk as the same static-analysis family.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Makes clear this is pattern-based static analysis that does not execute the code, and states the prerequisite of a valid access key (free uses or credits) with a pointer to POST /crear-llave. It does not state a when-not condition or explicitly rank itself against the sibling detectors, but the applicable context is unambiguous.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources