Politica Cedar — protect.cedar
📄 protect.cedar
healthdata-prod-v1
// HealthData SL — RGPD Art. 9 Policy
// Generado: 2026-06-16 | v1.2.0
// Lectura permitida solo en rutas autorizadas
permit (
principal,
action in [Action::"Read", Action::"Glob", Action::"Grep"],
resource
) when {
context.path_starts_with in
["/data/anonimizados/", "/reports/"]
};
// Solo herramientas estadisticas en Bash
permit (
principal,
action == Action::"Bash",
resource
) when {
context.command_pattern in
["python3", "pandas", "matplotlib",
"ls", "cat", "pwd"]
};
// API interna autorizada
permit (
principal,
action == Action::"WebFetch",
resource
) when {
context.url_host == "api.healthdata.es"
};
// PROHIBICIONES — nivel critico
forbid (
principal,
action == Action::"Bash",
resource
) when {
context.command_pattern in
["rm", "curl", "wget", "ssh"]
};
// Sin escritura fuera de /reports/
forbid (
principal,
action in [Action::"Edit", Action::"Write"],
resource
) when {
context.path_starts_with != "/reports/"
};
// Sin acceso a internet externo
forbid (
principal,
action == Action::"WebFetch",
resource
) when {
context.url_host != "api.healthdata.es"
};
📋 Reglas activas
6 reglas | 2 permit + 4 forbid
| Herramienta | Condicion | Decision |
|---|---|---|
| Read/Grep | /data/anonimizados/ o /reports/ | ✓ permit |
| Bash | python3, pandas, ls, cat | ✓ permit |
| WebFetch | api.healthdata.es unicamente | ✓ permit |
| Bash | rm, curl, wget, ssh | ✗ forbid |
| Edit/Write | fuera de /reports/ | ✗ forbid |
| WebFetch | cualquier host externo | ✗ forbid |
⚙️ .claude/settings.json
hooks
{
"hooks": {
"PreToolUse": [{
"matcher": ".*",
"hook": {
"type": "command",
"command": "npx protect-mcp@latest
evaluate
--policy ./protect.cedar
--tool \"$TOOL_NAME\"
--input \"$TOOL_INPUT\"
|| exit 2"
}
}],
"PostToolUse": [{
"matcher": ".*",
"hook": {
"type": "command",
"command": "npx protect-mcp@latest
sign
--tool \"$TOOL_NAME\"
--input \"$TOOL_INPUT\"
--output \"$TOOL_OUTPUT\"
--receipts ./receipts/"
}
}]
}
}
Recibos firmados Ed25519 — ultimas llamadas
Read
✓ ALLOW
2026-06-16T09:14:32.041Z
receipt_id: rec_a7f3b29c | parent: rec_00000000
input_hash: sha256:3f8a9c2d4e6b1a7f...
sig: 4cde814b7889e987a23f19d3c1b50a29e6f40819b2c3d7e4f5a6b1c8d2e3f94a1b
input_hash: sha256:3f8a9c2d4e6b1a7f...
sig: 4cde814b7889e987a23f19d3c1b50a29e6f40819b2c3d7e4f5a6b1c8d2e3f94a1b
Bash
✓ ALLOW
2026-06-16T09:14:35.187Z
receipt_id: rec_b9e4c1d5 | parent: rec_a7f3b29c
input_hash: sha256:9d2e7f1a3b5c8e4d...
sig: 8b3a29cd17e4f560a91b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4
input_hash: sha256:9d2e7f1a3b5c8e4d...
sig: 8b3a29cd17e4f560a91b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4
Write
✓ ALLOW
2026-06-16T09:14:58.832Z
receipt_id: rec_c3a7d2f1 | parent: rec_b9e4c1d5
input_hash: sha256:7c1f4a9e2b6d8f3a...
sig: 2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a
input_hash: sha256:7c1f4a9e2b6d8f3a...
sig: 2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a8b9c0d1e2f3a
Bash
✗ BLOCK
2026-06-16T09:18:11.445Z
receipt_id: rec_d8b2e5a7 | parent: rec_c3a7d2f1
input_hash: sha256:4a7f2e9b1c3d6f8a...
sig: 9e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f
input_hash: sha256:4a7f2e9b1c3d6f8a...
sig: 9e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f
WebFetch
✗ BLOCK
2026-06-16T09:22:03.009Z
receipt_id: rec_e1f9c3b8 | parent: rec_d8b2e5a7
input_hash: sha256:6b3d1f9a7e2c4b8d...
sig: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b
input_hash: sha256:6b3d1f9a7e2c4b8d...
sig: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b
Verificacion offline — sin servidor
Cualquier tercero (AEPD, auditores) puede verificar la cadena completa de recibos sin acceso a los sistemas de HealthData SL.
$ npx @veritasacta/verify receipts/*.json
✔ 247/247 receipts valid — chain intact
✔ 247/247 receipts valid — chain intact
Cadena de hash — trazabilidad inmutable
rec_00000000
GENESIS
inicio sesion
hash-link
rec_a7f3b29c
Read
✓ allow
hash-link
rec_b9e4c1d5
Bash
✓ allow
hash-link
rec_c3a7d2f1
Write
✓ allow
hash-link
rec_d8b2e5a7
Bash rm -rf
✗ deny
hash-link
rec_e1f9c3b8
WebFetch ext.
✗ deny
hash-link
rec_...
+242 mas
cadena viva
Cada recibo contiene el hash SHA-256 del anterior — cualquier modificacion rompe toda la cadena subsiguiente — Ed25519 + JCS (RFC 8785)
Cumplimiento normativo
RGPD Art. 9 — Datos de salud
Evidencia criptografica de cada acceso a datos de categoria especial. Auditoria verificable por AEPD sin acceso a sistemas internos.
NIS2 — Registro de incidentes
Los intentos de acceso no autorizado quedan firmados y encadenados. Imposible borrar sin invalidar toda la cadena posterior.
ISO 27001 — Control A.12.4
Trazabilidad completa de acciones del agente IA. Los recibos cumplen el requisito de logs de auditoria inmutables.
EU AI Act — Art. 13 Transparencia
Documentacion automatica de decisiones del sistema IA. Cadena de evidencia para sistemas de alto riesgo (sector sanitario).
ENS — Esquema Nacional de Seguridad
Registro de auditoria firmado digitalmente. Compatible con nivel ALTO segun Real Decreto 311/2022.
Verificacion offline — sin vendor lock-in
Cualquier tercero verifica los recibos con npx @veritasacta/verify sin depender de los sistemas del operador.
Antes vs. despues de protect-mcp
❌ Sin gobernanza
| "Confia en nosotros, el agente solo leyo archivos anonimizados" |
| El log de sesion es editable por cualquiera con acceso al sistema |
| La auditoria AEPD requiere acceso completo a la infraestructura |
| No hay forma de probar que el agente no accedio a datos identificativos |
✅ Con protect-mcp
| Prueba criptografica: cada Read firmado y hash-encadenado |
| Ed25519 + JCS: el recibo es inmutable una vez emitido |
| AEPD verifica offline: npx verify receipts/*.json en su maquina |
| Cedar policy prohíbe fisicamente el acceso a datos no anonimizados |