Prompt Injection and the AI Bill: Give the Agent Less to See
One line in an issue can make an agent send your secrets out, and a long session bills the same conversation many times. Break one leg of the lethal trifecta, make secrets unreadable, and clear context between tasks.
Key takeaways
- Indirect prompt injection hides instructions in issues, web pages, logs or docs the agent reads.
- An agent with private data, untrusted content and a way to send data out can be turned against you; remove at least one.
- If a secret reached a prompt or a commit, rotate it; deleting it is not enough.
- Every turn re-sends the whole conversation, so context size times turns drives most of an AI coding bill.
- Clearing the session between tasks costs nothing and cuts both the bill and what an attacker can reach.
Contents
FAQ
Is my code used to train the model?
It depends on the plan. Business and API tiers of the major vendors do not train on your data by default; several consumer tiers can, depending on a setting. Check the setting, not the marketing.
What does a developer typically spend?
Claude Code's documentation puts the enterprise average at about $13 per developer per active day, with 90% of users under $30. Far above that, check context habits first.
Do more API keys raise my rate limit?
No. Rate limits apply per organisation, so rotating keys inside one org gains nothing. Back off on 429 responses and queue work.
Sources
Only you and the owner see your answer and rating. Send private feedback
Enjoyed it? Support fx-blog with a coffee.
Related posts
Your LLM Proxy Retries the Wrong Errors
What an LLM proxy has to decide on every failure: limits are per organization, which statuses to retry, why nothing is retried after the first streamed byte, and the headroom headers the API already sends.
Your LLM Demo Works. What Every Call Needs in Production
One timestamp in the system prompt and every call misses the cache. Pricing each call, making failures loud, logging per feature, and treating outside text as untrusted.
RAG That Works: Why Retrieval Matters More Than the Prompt
Most bad RAG answers are retrieval problems. How RAG works end to end, the three parts of the grounded prompt, how to measure retrieval alone, and when long context is enough.
Comments
Oldest firstNo comments yet. Start the conversation.
Part 4 proved the rate-limit tests go red at 50 and left two doors open: an issue filed against the auth service that tells the agent to post
.envto a URL, and a session whose token count keeps climbing. Both are about what the agent sees.The issue reads like a bug report, with one extra line. The agent working on the login rate limit reads it for context. If it can also read
.envand reach the internet, nothing more is needed.No exploit, no malware. Just text the agent took as an instruction.
AI Practices for Engineers, in 6 parts:
Three legs, and you only need to break one
Prompt injection is number one on the OWASP Top 10 for LLM applications. For coding agents the kind that matters is indirect: instructions hidden in a README, an issue, a web page or a log line. Simon Willison named the combination that makes it dangerous, the lethal trifecta:
Secrets it never sees can't leak
In about 20,000 repos with GitHub Copilot active, GitGuardian found 6.4% had leaked at least one secret, 40% above the 4.6% baseline for public repos. Run secret scanning in pre-commit and in CI, and deny the agent read access to
.envand secret folders.Where the code goes matters too. Business and API tiers of the major vendors don't train on your data by default; several consumer tiers can. A personal Pro account is a consumer surface, so company code goes only into company-approved, business-tier tools.
Every turn pays for the whole conversation
The window that holds the poisoned issue is also the one you pay for. A session holding 100K tokens that runs 40 more turns sends about four million input tokens. Nobody typed them; the conversation re-sent itself forty times.
The login rate limit session went wrong the ordinary way: after the fix landed, it moved on to the Redis bug and a review, carrying the whole history along. Context times turns drives most of the bill; model tier, effort and rework come after.
The habits that cut it cost nothing
/clearor a new chat when you switch tasksThey also stop the context rot from part 3. The smaller session is cheaper, better, and has less to leak.
Try it
The agent can't read
.envnow, and you clear between tasks. But one correction comes back in every fresh session that writes the login API tests: "reuse the fixtures, don't create a raw HTTP client". You pay for it each time, and your teammates type it too. Part 6, Turn Repeated Fixes into Skills, makes the repo and the team remember it.Read this with your AI