Skip to content

hle_web_tools: authenticate /seed_session so a sandbox cannot seed its own session #5845

Open

Description

@rimashahbazyan

Problem

The server resources_servers/hle_web_tools, used by the preset benchmarks/hle_diamond/opencode_hle_tools.yaml, refuses a web_search query that repeats 8 consecutive words of the rollout's question. The question reaches the server through POST /seed_session, which is unauthenticated.

Under network_access: model_and_tools, the sandbox egress policy admits the whole tool-server host. restricted_network_policy in nemo_gym/agents/agent_tools.py restricts hosts, not paths. A process inside the sandbox can therefore:

  1. POST /seed_session without the rollout's cookie, with {"question": "<any unrelated words>"};
  2. use the returned session cookie, or the MCP token minted for it, to call web_search with words of the real question.

The span rule then checks the query against the question the sandbox chose, and the search reaches Tavily.

What the server already does:

  • It refuses web_search from a session never seeded with a question (require_seeded_question, default on). This includes a seed whose question has no words.
  • It refuses re-seeding a session it holds with another question, or with none (HTTP 409).
  • For typed (Environment Server) seeds, it binds the session to its episode and task. It fences closed IDs, and IDs the session cap forgets, in ResourcesSessionFence.

None of these covers a fresh session. The fence is checked only on typed seeds, so it also misses two kinds of session:

  • an Agent (untyped) session that the 10,000-session cap has forgotten;
  • a closed typed ID.

Both accept a later untyped seed through their cookie with another question (HTTP 200).

OpenCode never closes its tool sessions. So a long-lived server forgets a running rollout this way after 10,000 later seeds. An unauthenticated client can also seed past the cap on purpose. The server then forgets other rollouts' questions, and their searches fail closed as unseeded_session.

The session cookie and MCP token are signed with get_session_middleware_key() (nemo_gym/server_runtime/base_server.py). That key is f"{class name}___{instance name}", derived from public config, so the signature cannot tell the agent server's seed from the sandbox's.

Until this is closed, the span rule binds a cooperative harness, not the sandboxed model. Two READMEs document the residual:

  • resources_servers/hle_web_tools/README.md;
  • benchmarks/hle_diamond/README.md, in the section Sandboxed agents (with tools) > Upstream web tools.

A with-tools number from this preset should state it.

Proposed direction

Seed through an authenticated channel:

  • A secret held by the host-side agent server, and not placed in sandbox files, the environment or MCP headers.
  • The server validates it before it installs question state or mints MCP access.
  • The host-side seeding path in nemo_gym/agents/agent_tools.py (seed_mcp_servers) would carry it.
  • The signing key for sessions and MCP tokens also needs a real secret rather than the config-derived key.

Related, with the same root cause: because the sandbox chooses what a fresh seed carries, it also chooses the seed's size. A question of a few MB holds tens of MB of word n-grams, and seeding it holds the event loop for up to a couple of seconds. Measured: about 65 MB held and 0.5 s for a 2.2 MB ASCII question of 320,000 words, and about 1.5 s for non-ASCII text of the same size. The 10,000-session cap counts sessions, not bytes. A trusted seed channel removes the attacker. A per-seed size bound, or hashed n-grams, would bound the honest worst case.

Acceptance

  • An unauthenticated fresh seed from a second client is refused (401/403). It yields no searchable session and no MCP token.
  • A seed without the credential through an existing session's cookie is refused as well. This includes a session the cap has forgotten and a closed typed ID.
  • A trusted seed still permits unrelated queries. It still refuses 8 words of the original question, both over MCP and over plain HTTP.
  • These are preserved:
    • same-question retries;
    • 409 on a changed or dropped question;
    • the 7-word allowance;
    • per-session isolation;
    • the two-tool MCP token;
    • the require_seeded_question: false opt-out;
    • the typed-session contract (check_resources_session_contract(..., keeps_state=True)).

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions