← Miguel Jardines

Securing my AI assistant

The assistant on this site answers questions about my career. I built it the way I approach any launch: threat-model it, put layered controls in place, then test and attack it before it ships.

Architecture

Every layer assumes the one before it can fail. A jailbreak that gets past the model still hits the output checks, and an attacker who skips the widget still faces the origin, bot, session, and rate-limit checks.

OWASP Top 10 for LLM Applications (2025)

RiskControlsVerified by
LLM01 Prompt injection Visitor text is treated as a question, never an instruction; hidden and bidi characters are stripped; strict role order; the caller can't send a system prompt, tools, or model; length caps. Unit tests (input rules, hidden characters, field allow-list) · Eval: injection, role-play, encoding, and multi-turn attacks
LLM02 Sensitive information disclosure The knowledge file holds only public, employer-neutral facts; no personal data is requested or stored; logs keep metadata only, never visitor or model text. Unit test (knowledge has no confidential terms) · Eval: confidential-data probes
LLM03 Supply chain One runtime dependency (the official Anthropic SDK), pinned to an exact version with a lockfile; Wrangler pinned; no third-party scripts except Cloudflare's bot check, allowed by CSP. npm audit · lockfile review
LLM04 Data and model poisoning No retrieval from user input or the web; one version-controlled knowledge file, changed only through reviewed commits. Git history · knowledge unit test
LLM05 Improper output handling Replies are inserted with textContent, never HTML; the server strips tags and code fences and caps length; strict CSP with no inline scripts. Unit test (HTML stripped, length cap) · Eval: HTML/script injection
LLM06 Excessive agency No tools at all: the assistant can only chat. It can't send email, book meetings, or reach any system. Unit test (no tools sent to the model) · Eval: action requests
LLM07 System prompt leakage No secrets in the prompt; a canary marker and a verbatim-echo check block any reply that leaks it. Unit tests (canary, prompt echo) · Eval: extraction attempts, scored on the canary
LLM08 Vector and embedding weaknesses Not applicable by design: no vector store or retrieval, which removes this attack surface. Architecture review
LLM09 Misinformation Answers come only from the facts file; if a fact isn't there, the assistant says so and points to email. Eval: questions with no answer in the facts, scored for refusal to guess
LLM10 Unbounded consumption Bot check; 5 sessions and 10 chats per minute; 30-minute sessions; 6 questions per chat; 16 KB body, 600-character question, and 8,000-character conversation caps; capped output; a spend limit on the API account; fails closed if any secret is missing. Unit tests (rate limit, size caps, fail-closed)

Testing

Latest eval (Nov 3, 2026): 28/28 passed. 100% on prompt injection (6/6), system prompt leakage (5/5), sensitive information (4/4), misinformation (3/3), output handling (2/2), excessive agency (2/2), misuse (1/1), and functional answers (5/5).

The first run scored 27/28. The eval caught a false positive in my own output filter: it blocked a correct answer that quoted a public fact word for word. I narrowed the filter to protect only the instructions, added a regression test, and re-ran the suite.