Sistema RAG de la Guía de Pruebas de Seguridad Web de OWASP con ChromaDB, MCP para Claude Code
Un sistema de Generación Aumentada por Recuperación (RAG) que indexa la OWASP Web Security Testing Guide (WSTG) en una base de datos vectorial, proporcionando acceso instantáneo a metodologías de pruebas de seguridad a través de API REST y MCP (Model Context Protocol) para la integración con Claude Code.
WSTG-INPV-05)| Categoría | ID de WSTG | Descripción |
|---|
| Recopilación de información | WSTG-INFO | Huella digital, enumeración, mapeo |
| Configuración | WSTG-CONF | Pruebas de configuración del servidor/plataforma |
| Gestión de identidades | WSTG-IDNT | Registro de usuarios, aprovisionamiento de cuentas |
| Autenticación | WSTG-ATHN | Pruebas de inicio de sesión, política de contraseñas, MFA |
| Autorización | WSTG-ATHZ | Escalada de privilegios, IDOR, control de acceso |
| Gestión de sesiones | WSTG-SESS | Tokens de sesión, cookies, fijación de sesión |
| Validación de entrada | WSTG-INPV | SQLi, XSS, inyección de comandos, SSTI |
| Gestión de errores | WSTG-ERRH | Mensajes de error, trazas de pila |
| Criptografía | WSTG-CRYP | TLS, cifrado, hash |
| Lógica de negocio | WSTG-BUSL | Omisión de flujos de trabajo, carga de archivos |
| Lado del cliente | WSTG-CLNT | DOM XSS, clickjacking, WebSockets |
| Pruebas de API | WSTG-APIT | REST, GraphQL, seguridad de API |
cd RAG_runner
pip install -r requirements.txt
python3 build_database.py
Este proceso:
python3 -m server.http_server
El servidor se ejecuta en http://localhost:5004
# Health check
curl http://localhost:5004/health
# Search for SQL injection testing
curl -X POST http://localhost:5004/search \
-H "Content-Type: application/json" \
-d '{"query": "SQL injection testing methodology"}'
# Get specific WSTG test case
curl http://localhost:5004/wstg/WSTG-INPV-05
| Endpoint | Método | Descripción |
|---|---|---|
/health | GET | Comprobación de estado |
/info | GET | Estadísticas de la base de datos |
/list | GET | Listar todos los documentos |
/categories | GET | Listar categorías e IDs de WSTG |
/doc/{id} | GET | Obtener documento por ID |
/wstg/{id} | GET | Obtener todos los fragmentos para un ID de WSTG |
/search | POST | Búsqueda semántica |
{
"query": "SQL injection testing",
"n_results": 5,
"category": "input_validation",
"wstg_id": "WSTG-INPV-05"
}
Añade a ~/.claude.json:
{
"mcpServers": {
"owasp-wstg-rag": {
"command": "python3",
"args": ["/path/to/OWASP_WSTG_Rag/RAG_runner/server/mcp_client.py"],
"env": {
"WSTG_RAG_URL": "http://localhost:5004"
}
}
}
}
| Herramienta | Descripción |
|---|---|
search_wstg | Buscar en WSTG metodologías de pruebas |
search_test_methodology | Buscar guías de pruebas paso a paso |
search_test_objectives | Buscar objetivos de prueba |
get_wstg_test_case | Obtener caso de prueba completo por ID de WSTG |
get_wstg_document | Obtener documento por ID |
list_wstg_categories | Listar todas las categorías e IDs de WSTG |
wstg_health | Comprobación de estado |
wstg_info | Estadísticas de la base de datos |
# Search for SQL injection testing methodology
search_wstg("SQL injection testing methodology")
# Get specific test case
get_wstg_test_case("WSTG-INPV-05")
# Search within a category
search_wstg("authentication bypass", category_filter="authentication")
# Get test objectives for IDOR
search_test_objectives("IDOR insecure direct object reference")
OWASP_WSTG_Rag/
├── README.md
├── CLAUDE.md # Claude Code project guide
├── raw_data/ # OWASP WSTG HTML source files
│ ├── 01-Information_Gathering/
│ ├── 02-Configuration_and_Deployment_Management_Testing/
│ ├── 03-Identity_Management_Testing/
│ ├── 04-Authentication_Testing/
│ ├── 05-Authorization_Testing/
│ ├── 06-Session_Management_Testing/
│ ├── 07-Input_Validation_Testing/
│ ├── 08-Testing_for_Error_Handling/
│ ├── 09-Testing_for_Weak_Cryptography/
│ ├── 10-Business_Logic_Testing/
│ ├── 11-Client-side_Testing/
│ └── 12-API_Testing/
└── RAG_runner/
├── build_database.py # Main build pipeline
├── requirements.txt
├── parsers/
│ └── wstg_parser.py # HTML parser for WSTG
├── chunking/
│ └── chunker.py # Semantic chunking
├── server/
│ ├── vector_store.py # ChromaDB wrapper
│ ├── http_server.py # REST API server
│ └── mcp_client.py # MCP tools for Claude Code
└── data/
├── processed/ # Intermediate JSON files
└── chroma_db/ # Vector database
┌─────────────────────────────────────────────────────────────────┐
│ OWASP WSTG HTML Files │
│ (raw_data/*.html) │
└────────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ wstg_parser.py │
│ Parse HTML → Structured JSON │
└────────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ chunker.py │
│ Create Semantic Chunks for RAG │
└────────────────────────────┬────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ ChromaDB Vector Store │
│ (data/chroma_db/) │
└────────────────────────────┬────────────────────────────────────┘
│
┌──────────────┴──────────────┐
▼ ▼
┌──────────────────────────┐ ┌──────────────────────────┐
│ http_server.py │ │ mcp_client.py │
│ REST API :5004 │ │ MCP for Claude Code │
│ │ │ │
│ GET /health │ │ search_wstg() │
│ GET /info │ │ get_wstg_test_case() │
│ GET /wstg/{id} │ │ search_test_methodology │
│ POST /search │ │ list_wstg_categories() │
└──────────────────────────┘ └──────────────────────────┘
Integra con Claude Code para obtener acceso instantáneo a las metodologías de pruebas de OWASP durante evaluaciones de seguridad:
User: "How do I test for SQL injection?"
Claude: [Queries WSTG RAG]
→ Returns WSTG-INPV-05 methodology with:
- Test objectives
- Step-by-step testing procedures
- Example payloads
- Tools to use
Usa la API REST para integrar metodologías de WSTG en pipelines de seguridad automatizados:
import requests
# Get testing methodology for current test
response = requests.post('http://localhost:5004/search', json={
'query': 'session fixation testing',
'n_results': 3
})
methodology = response.json()['results']
Referencia rápida para metodologías de pruebas de seguridad durante formaciones o retos CTF.
Este proyecto utiliza contenido de la OWASP Web Security Testing Guide, que está bajo la licencia Creative Commons Attribution-ShareAlike 4.0.