Repository navigation
Security
Treat every homework photo, PDF and web page as untrusted input: it can contain instructions aimed at the agent.
An injection becomes dangerous when one agent has all three of: private data, untrusted content, and a way to send data out (web fetch counts, since a URL can carry data). The target design gives no role all three.
Where the agent stands today. The agent has five roles (orchestrator,
general,math,writer,curator) in one actor per job. The orchestrator,generalandcuratorreach private data (the profile and memory docs) through the Context API, and the Context API shows them only that student's data. The orchestrator and the curator read only the student's own task and feedback and have no way out: the actor's egress policy allows only the Context API (on kind, through a relay that passes only its paths) andopenrouter.ai, and neither has web search.The three workers break the rule, as an accepted interim risk.
general,mathandwritercarry OpenRouter's web search. A worker reads untrusted web results, holds the student's task and notes (generalcan also read memory), and its search query is a way out, since it goes to OpenRouter's search provider. So the rule does not hold for the workers until a separateresearchrole replaces this. Limits that keep it small: no URL fetch and no code; at most 2 searches per model request, 5 results each; the worker prompts say to search only for facts needed, never to put the student's name, notes, the task verbatim or personal details in a query, and to treat results as material, not instructions; the curator, the only role that writes memory, has no web search, and neither has the orchestrator. The search runs at OpenRouter, so the actor's egress policy is unchanged. Roles are kept apart by fixed tool lists in the agent, not by separate actors.research(strict brief, no private data) and running code get their own actor and egress policy, reached through a Context API tool.
The first five roles are built and enforced; research and review are the target.
| Role | Private data | Untrusted content | Way out | Tools |
|---|---|---|---|---|
| orchestrator | task, notes | task, feedback, result previews | none | run_agent |
| general | task, notes, memory | task, feedback, web results | search query (OpenRouter) | web search, math tools, write_document, read_memory, search_memory, list_history
|
| math | task, notes | task, feedback, web results | search query (OpenRouter) | web search, the five math tools |
| writer | task, notes | task, feedback, web results | search query (OpenRouter) | web search |
| curator | profile, memory | task, feedback, answer | none | none (the harness calls update_memory) |
| research (target) | none | web pages | search, fetch |
web_search, web_fetch, write_artifact
|
| review (target) | task only | the draft | none | read_artifact |
-
Fixed tools per role. A tool missing from the list doesn't exist for that agent. For the built roles this is enforced and checked:
apps/agent/tests/test_roles.pycompares each agent's tool names with this table. - Only the workers have a way out. Their search query. No role fetches a URL or runs code, and egress is OpenRouter and the Context API only.
-
Only two roles write.
generalwrites drafts (write_artifact) and the curator writes memory (update_memory); the orchestrator,mathandwriterwrite nothing. -
One token, one client. The round's Context API token lives in one
ContextClientper round, shared in-process by every role throughDeps; a role reaches only what its tools wrap. It never enters a prompt or a log. All roles share its limits: one job, one round, one lease, 2 h, writes refused once the round is no longer the newest. - Worker input is material. An earlier result passed to a worker is fenced as material, not instructions, and the worker prompts treat search results the same way.
-
Strict research brief.
{topic, questions[], level, language, length}, with length caps. No free-text field where personal details could leak into search queries. - Research results stay out of the orchestrator. It sees artifact ids and statuses, not the summaries written after reading web pages.
- Notes are untrusted. The writer's prompt wraps research notes as source material, not instructions. The reviewer flags content that doesn't belong (links, odd instructions).
- Code runs in its own actor: no network, no token, no user data. The job is the trust boundary: one run can affect later runs of the same job, never another job.
Worst case for a successful injection: a bad answer that the reviewer and the student both see. It can't leak this student's data or anyone else's.
An answer is model output that has read homework photos and web pages, and a URL counts as a way out: an image that loads by itself could carry a student's data to any server. So the web app:
- Never loads images from an answer. Their alt text is shown instead, and a CSP (
img-src 'self' data:) backs this up. Keep this: the answer is built from worker text that has read the student's notes. - Shows the destination host beside every link, and opens links in a new tab without a referrer.
- Keeps KaTeX
trustoff and limits size and macro expansion, so a formula can't take over the page. - Shows an answer that can't be rendered as raw text, with the review actions still there.
Feedback is shown as plain text, never pasted into the answer's Markdown.
- Context API tokens are HMAC-SHA256 signed (
CONTEXT_TOKEN_SECRET, at least 32 characters; the API refuses to start with aCONTEXT_API_URLand no valid secret). One token covers one round of one job and lasts 2 h; the dispatcher mints a fresh one per claim. It travels inAgentRun.context, stays in the harness, and never appears in a prompt. Every query is filtered by the token's job and user, and writes are refused with 409 unless the job isprocessingand the token's round is the newest. - The API reaches Substrate with a short-lived token (on Cloud Run a Google ID token it fetches itself) and a client certificate, and its access policy
covers the
justpass-agentsatespace only. Locallydeploy/local/identity.shwrites both to a git-ignored folder; they last 24 hours. - The OpenRouter key is not added at the egress gateway (Substrate egress rules cannot do that). The API sends it with each round, and the actor keeps it in memory only. Egress allows openrouter.ai:443 as TLS passthrough when a key is set.
- CI authenticates to the cloud with workload identity federation, no JSON key files. Gitleaks runs on every PR.
- Firebase Auth Emulator mode skips signature checks, so it only starts with a
demo-*project ID.
- Users are mostly minors. Host in the EU. The agent routes to the cheapest provider without a ZDR filter, so a provider may retain prompts;
zdr=trueis the switch if that changes. - Every row and storage path carries
user_id, so deleting a user is one query plus one folder. - A "16+ or parental consent" checkbox and
consent_atfor now. Full GDPR/COPPA compliance before any paying users.