The Answer Sheet

More and more products run code they did not write: AI agents, scripts that customers upload, third-party plugins. Every piece of that code runs on your servers, next to your data. If it manages to reach a place it was never meant to reach, the damage hits what your customers trust you with.

A few months ago I mentored a team that built a machine learning competition platform for a cloud provider. Participants submit a solution, the system runs it and scores it against secret test data, and the scores go up on a public leaderboard. When the team planned their final presentation, one of the engineers put the whole thing in one sentence: a benchmark is only worth something while its data has not leaked. The moment anyone has seen the answer sheet, every score on the leaderboard means nothing.

When you run strangers' code, you have to decide where the line runs. Between the foreign code and your system, every layer of protection is worth its price. Inside your own system, one more layer costs upkeep and adds no safety.

Start from the attacker

In the second week I shared with the team a write-up of attacks on AI coding agents, and wrote: "This is why we should think like an attacker. The creativity is actually endless".

We defined one threat scenario and measured every decision against it: malicious code running inside the evaluation run. The isolation followed from there. Every submission runs on its own, on dedicated servers that run nothing else. The participant's code has access to no password at all. Its network access is open only to what the current stage needs. And one of the engineers split the scoring into two steps: the participant's model runs under a restricted user that cannot read the answers file, and the score is calculated afterwards, separately.

None of this required new technology. Looking back, it is very close to what the Kubernetes community now describes for running AI agents in isolation. Whoever builds a product like this does not need to invent the isolation. They need to know what they are defending against.

Where the line runs

The important arguments were about the edge of the isolation: where exactly it runs.

One engineer wrote that the evaluation service holds the database and message queue passwords anyway. I answered that the component that runs the participant's code must not hold any of them: "the evaluator worker should not be exposed for any of them. Not to the Db and not to the RabbitMQ". She clarified that she meant the service that manages the evaluations, not the component that runs them. To that I answered that it was fine: "It's OK for this pod to get such permissions. The only risk is coming from the worker pod". That service is ours, and it is allowed to hold passwords. The risk comes only from the place where the participant's code runs.

A week earlier, another engineer asked whether to give every service its own database user, with access only to its own tables. It is safer if one service is breached, but it means more configuration to maintain. I answered: "Don't do that. We can assume that if we have 1 compromised service we will have them all compromised together".

Both answers say the same thing. All our services sit on the same side of the line, and the participant's code sits on the other side. Security effort that separates our own services from each other costs time and maintenance, and it does not protect against the scenario we defined.

A check that looks like protection

The opposite danger is a check that gives a feeling of safety without actually stopping an attacker.

When the team proposed letting the participant's code reach a few specific addresses on the network, I asked: "What is our main goal in creating network policies? Does the suggested allowed egress access is really preserve it or maybe it make it actually a wolf in sheep's clothing?" Every open address is also a way out for the data.

And when an engineer added an automatic check that scans the participant's code and rejects dangerous calls, I wrote: "I am not sure about this ast", and showed her one line that passes the check and still runs exactly what the check was meant to block: getattr(__builtins__, "eval"). We kept the check as a basic gate that catches innocent mistakes, and we did not rely on it against an attacker.

Both of these checks look good in a design review. The question is what they stop when someone is really trying to get past them.

Takeaways

  1. Define one threat scenario and test every decision against it. "What happens if this code is malicious?" settles most arguments quickly.
  2. Foreign code gets no passwords. Everything it needs is handed to it from outside, and everything it does not need simply does not exist for it.
  3. Invest in security where the line runs. One more layer between your own services costs upkeep and does not protect against the real scenario.
  4. Test every defense against an attacker, not against a mistake. A check that one line of code can get around is a basic gate, not a defense.

A platform like this sells trust. Most of the work behind it is an explicit decision about whom you trust, and with what.