Skip to main content
Glama

Detectar riesgo de path traversal / acceso arbitrario a archivos

detect_path_traversal_risk

Analiza el código fuente de una herramienta MCP que lee, escribe o borra un archivo a partir de una ruta que le pasa el agente (abrir un documento, guardar un adjunto, exportar un reporte) en busca de señales de riesgo de path traversal: una operación de archivo (fs.readFile, fs.writeFile, open, shutil, send_file, y equivalentes) cuya ruta depende de una variable/entrada externa sin ninguna validación reconocible contra secuencias de escape ("../") cerca, una referencia directa a una ruta sensible del sistema (/etc/passwd, una llave SSH, un archivo de credenciales) dentro de la propia operación, y ausencia de rechazo explícito de rutas absolutas (aunque sí se filtren las secuencias "../", una ruta absoluta directa puede seguir escapando del directorio permitido). Motivada por ser la categoría MÁS GRANDE de vulnerabilidades reales encontradas en un censo de 2026 sobre 9.695 servidores MCP escaneados: acceso arbitrario a archivos fue el 17.7% de los 4.982 problemas encontrados (880 casos) — más grande que denegación de servicio, inyección de comandos o SSRF. Caso real: CVE-2026-40576 (CVSS 9.4, crítico) en un servidor MCP de Excel, donde su función de rutas permitía tanto rutas absolutas como secuencias "../" sin resolverlas contra el directorio permitido. Es un análisis estático por patrones de texto (no ejecuta el código) — mismo enfoque que detect_ssrf_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_path_traversal_risk"
  }
}

Input Schema

NameRequiredDescriptionDefault
codigoYesEl código fuente de la función/herramienta que lee, escribe o borra un archivo, 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.9/5.0
Behavior4/5

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

With no annotations supplied, the description carries the burden and does well: it discloses the analysis is static text-pattern matching that does not execute code, that detection is heuristic ('sin ninguna validación reconocible', 'cerca'), and that an access key with free uses or credits is required. It omits what the response actually contains (findings, severity, confidence) and any rate-limit or cost specifics, which are the remaining behavioral gaps.

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 purpose is front-loaded and the detection criteria are useful, but the single dense paragraph also carries promotional material — census statistics (9.695 servers, 17.7%, 880 cases) and a CVE anecdote with CVSS score — that do not change how the agent calls the tool. The core content could be stated in roughly half the length.

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 two-parameter static analyzer with no annotations and no output schema, the description covers what the tool does, its inputs, prerequisites, and limits of the technique. However, it never describes the shape of the result an agent will receive, which is the notable missing piece given there is no output schema to fall back on.

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%, so both parameters are already documented, including that 'lenguaje' is informational and does not change results. The description adds only a restatement of what 'codigo' should contain, with no extra syntax, size limits, or guidance on how much code to submit. Baseline 3 applies when the schema does the heavy lifting.

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: static analysis of MCP tool source code that reads/writes/deletes files from an agent-supplied path, looking for path traversal signals. It enumerates the exact patterns sought (fs.readFile, open, shutil, send_file, unvalidated external path, sensitive-path literals, missing absolute-path rejection), which distinguishes it clearly from the many other detect_*_risk siblings.

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?

Gives a clear trigger condition — submit code for a function that opens, saves, or deletes a file based on an agent-passed path — plus concrete examples (abrir un documento, guardar un adjunto, exportar un reporte) and a prerequisite (valid access key / credits). It names detect_ssrf_risk as the same approach but never states when NOT to use this tool or which sibling to pick for adjacent file-related risks.

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