Skip to content
Alexandre Mahe
All posts

Running an unknown repo without exposing your machine

Fake technical tests are a documented attack. Two settings limit the damage; the rest takes an isolated environment, with no secrets, even disposable, whose configuration comes from you and not from the repo.

Category
Note
Published
Reading time
4 min read
Tags
#agents#security#devcontainers#supply-chain

TranslationTranslated by AI from the original in French.Read the original

A recruiter offers me a web3 contract. The rate is good, the company looks legitimate, and the next step never changes: clone this repo, run it, fix a bug.

Since 2023, the North Korean Contagious Interview campaign has followed exactly this script: fake recruiters, credible companies, and a coding exercise that ships with its own backdoor, whose mechanics Microsoft lays out in detail. More than 1,700 malicious packages have been tied to it since January 2025, and crypto developers, sitting on keys worth real money, are the primary targets.

The method is mundane, and that is why it works. An npm dependency runs code on install, a VS Code task launches when the folder is opened, a few encoded lines hide in otherwise clean code. Once it runs, it's over: trojan, ransomware, or a quiet sweep of .env files, SSH keys and the crypto wallet. With the competition out there, the temptation to say yes quickly to every technical test is real, and that is precisely what the attack exploits.

For a freelancer, isolation is not just a personal precaution: the client expects their data not to cross from one project to another and access to stay strictly to what is needed, down to the inference that generates their code. And with agents running commands on my behalf, the question comes up every session.

No code I didn't write runs on my machine.

A devcontainer whose configuration you writeLink to this section

VS Code's Restricted Mode and --ignore-scripts close the shortest paths. But as soon as the tests run, the code executes anyway: it has to execute somewhere else. In a devcontainer, the code runs inside and the machine stays outside.

On one condition: for an unknown repo, the devcontainer.json is written by the attacker, and its initializeCommand runs on the host before the container even exists. The configuration has to come from you.

Workstation: control planesupervision · costs and models · permissions Local devcontainersagent A · agent B Cloud agentsPi Durable · Claude Code cloud Remote git repository: the only shared surface

I run several agents in parallel, each in its own container. Locally, the code stays on my disk, which lets me work offline, but it only executes inside the container and only moves between agents through git. Other agents run continuously in the cloud, with Claude Code or Pi Durable. From my workstation, I manage their costs, their models and their permissions.

Closed network, no secrets, nothing automaticLink to this section

The network is closed by default. w3cj's firewall feature blocks everything except a few allowed hosts and, in verbose mode, reports every refused connection. You quickly find out that a "simple technical test" is very keen to talk to an unknown server. A backdoor that does run can only reach those hosts: the risk drops, but does not disappear.

Secrets are compartmentalised. For trusted code, the container gets a development API key and a GitHub token scoped to that one repository. Otherwise, nothing.

Nothing starts on its own: not the repo's tasks, not npm scripts outside an explicit allowlist. The container has access to neither the home directory nor the Docker socket, and the SSH agent, which devcontainers share by default, is cut off unless explicitly requested.

The agent itself reads the repo's files, which may contain instructions aimed at it. With no secrets and a closed network, a prompt injection has little to steal, and nowhere to send it.

A home-made tool, not a security productLink to this section

With agents, new projects multiply. So I vibe-coded bs, a small tool that clones a repo and opens it in a devcontainer, with the language tooling and the security already in place, without installing Rust or Node on my machine. Good specs cover at least 80% of my bootstrapping needs; the rest gets adjusted from inside the devcontainer itself.

bs secures nothing on its own: Docker, proven base images and a readable firewall do that. The tool only makes the safe path short enough that I am not tempted to skip it, and trusting a repo remains a human decision. If the repo already contains a devcontainer, bs rewrites it before opening: git will show a modified file, but the generated configuration is what runs.

It is an assembly of configurations, easier to specify than to write, that generates files I review. I wrote it in Rust without knowing the language, in a devcontainer generated by bs itself.

For a technical test, assuming such tests are even still necessary, my version fits in one command:

# --typescript : TypeScript tooling and the common security layer
# --remote     : temporary VM, destroyed afterwards. Nothing on the local disk, and
#                a container escape lands on an empty machine
# --omniroute  : key generated by OmniRoute, to try LLMs without authenticating
#                or exposing your own key to a prospect's repo
# --untrusted  : no environment variables or secrets from the host machine
bs --typescript --remote --omniroute --untrusted https://github.com/malevolent/test.git

A devcontainer changes nothing for colleagues who don't use one: the whole team can improve the shared configurations, and the same container runs identically in the cloud.

A starting configurationLink to this section

Without any tooling: don't trust a folder in VS Code before reading the code, and install dependencies without scripts.

npm install --ignore-scripts

In the devcontainer.json, written by you, the firewall takes a few lines; the feature's documentation lists the options:

"features": {
  "ghcr.io/w3cj/devcontainer-features/firewall:latest": {
    "githubDomains": true, "npmRegistry": true, "claudeCode": true, "verbose": true
  }
}

To open an unknown repo without using its configuration, the official CLI accepts a file you wrote yourself, kept outside the repo:

npx @devcontainers/cli up --workspace-folder . --config ~/devcontainers/untrusted.json
npx @devcontainers/cli exec --workspace-folder . bash

On sensitive client code, no LLM without the client's prior consent, let alone a free one. For a tool like bs, this post can serve as a starting point for a discussion with your own agent.

Next post: what happens to a client's data when an LLM reads their code, and how a freelancer stays compliant.