CodePanel

A coding benchmark's hidden tests could be gamed by the code they test

Why running hidden unit tests in the same process as agent-written code can be spoofed, and how nonce-keyed FD frames plus an OS read sandbox close the hole.

The CodePanel teambenchmarkssecurityevaluation

When we first built CodePanel's coding agent benchmark, we judged each run by running hidden bun test files against the agent's committed branch. Three review rounds on the benchmark pull request exposed a structural flaw: any test runner that imports untrusted code runs that code inside the test process itself, so exit code 0, stdout JSON, or a JUnit file on disk can all be forged by the solution. We replaced hidden test execution with nonce-keyed observation frames over file descriptor 3 and an OS read sandbox around the probe.

Why in-process hidden tests fail

If a grading script imports the agent's module in the same process, the imported module executes with the same permissions and standard streams as the grader:

  • It can print a fake passing test summary to stdout and call process.exit(0) before any assertion runs.
  • It can read process.argv to locate a JUnit output file and write a passing XML report itself.
  • It can walk the filesystem as the same OS user and read the expected answers straight out of the benchmark source tree on disk.

None of those require exotic exploits; they are normal capabilities of code running inside a test process.

Parent-side grading over file descriptor 3

To separate untrusted code execution from verdict judgment, we split the grader into two processes:

  1. The probe (child process): Built from expressions alone, with no expected values anywhere in its source or inputs. It imports the agent's committed code inside a private temporary worktree (with scrubbed env, --no-env-file, and any committed bunfig.toml or .env* removed) and writes raw expression outputs as nonce-keyed frames to file descriptor 3, which the parent opened before spawn.
  2. The judge (parent process): Holds the expected values (fixtures/expected.ts), waits for the entire child process group to exit or time out, reads file descriptor 3 once, deletes it so a background process cannot write late, and compares each observation against the expected value.

The child's exit code, stdout, and stderr count for nothing. A forged frame must carry the exact expected output value, which requires actually solving the task.

Closing the filesystem read hole

During the next review round, the panel caught one remaining loophole: because the expected values file still sat in plain text in the checkout on disk, code inside the child process could read it by absolute path.

Wrapping the probe in an OS read sandbox (sandbox-exec on macOS, bwrap on Linux) closes that path. Reads are denied by default except the probe's own private worktree, the runtime binary, and system libraries, with no network access. The benchmark proves the sandbox works at startup and fails closed if no working sandbox is available unless --unsandboxed is passed (which marks every stored row sandboxed: false).

In tools/eval/coding/acceptance.test.ts, a fake test report, fake stdout JSON, early exit(0), a forged frame with the live nonce, a background writer, and an absolute-path read of the expected values all fail inside the sandbox while the honest solution passes. Read the full coding benchmark methodology or browse the coding leaderboard.