Email alexgrom465@gmail.com with the subject [security] rag-assistant-reference. Please give a 90-day disclosure window before publishing details.
- PII masking —
src/privacy/pii.pymasks emails, phones, postcodes, NINO, NHS, credit cards, IBAN before retrieval and unmasks only in the final answer. - Tenant + classification RBAC —
src/auth/context.py+ filters insrc/ingestion/embedder.pyandsrc/retrieval/hybrid.py. Filters apply to ChromaDB and BM25 in two independent paths. - Prompt-injection defense — chunks wrapped in
<doc>tags and the system prompt forbids following instructions inside tags.is_suspicious_outputflags known leak patterns. - Audit log —
structlogJSON events with HMAC-hashed user ids; canary regex flags PII that slipped through masking. - GDPR endpoints —
DELETE /privacy/user/{id},GET /privacy/user/{id}/export,GET /disclosure. - Rate limiting —
slowapiat100/day, 10/minuteper IP on/chat. - Adversarial eval + regression gate —
python -m src.evaluation.evaluate adversarialplusgatemode that fails CI on>5ppcorrectness drop. - Secret hygiene —
.gitleaks.tomlwith custom rules for Groq / Gemini / Anthropic keys, run in pre-commit and CI. - Static analysis —
banditandpip-auditin CI.
User ids are HMAC-pseudonymised with a salt held outside the repo (AUDIT_HMAC_SECRET). Operational logs are kept 90 days, security logs one year. Delete and export endpoints cover Articles 17 and 20.
tests/test_prompt_guard.py covers ignore previous, system-prompt exfiltration, role hijacks (You are now ...), developer mode jailbreaks, and <tool_call> injections. For broader red-team coverage, garak is the recommended scanner.
This repo is a reference implementation. Production additionally needs: TLS at the proxy, encrypted storage (KMS or LUKS), real auth provider (UserContext is set by your JWT middleware), and a managed secret store (Vault / AWS Secrets Manager) with 90-day key rotation.