24.3. Agent Security and Scoping#

An agent runs as you, so it can reach whatever your account can reach on a shared cluster. This page covers how an agent can be turned against you, why remote control is not allowed on the cluster, and how to limit what a misdirected agent can touch. For the guardrails you set in Claude Code itself, such as permission rules and hooks, see Guardrails.

24.3.1. Agent security#

An agent acts on what it reads, and not everything it reads is trustworthy. A web page, PDF, dataset, code comment, or tool result can contain text written to look like an instruction. If the agent follows it, that is prompt injection, the most common way an agent is turned against its user.

        flowchart LR
    U["Untrusted content<br/>web page, PDF,<br/>dataset, code comment"] --> R["Agent reads it"]
    R --> H{"Hidden<br/>instruction?"}
    H -->|treated as data| OK["Ignored;<br/>you stay in control"]
    H -->|followed as a command| BAD["Unintended action:<br/>exfiltration, deletion"]
    classDef n fill:#14154C,color:#ffffff,stroke:#3D3E82;
    classDef good fill:#C6C8F4,color:#14154C,stroke:#14154C;
    classDef bad fill:#A51C30,color:#ffffff,stroke:#A51C30;
    class U,R,H n;
    class OK good;
    class BAD bad;
    

Treat everything the agent reads, including tool output, as data, not commands. Then reduce the risk:

  • Keep a human on consequential actions. Approve anything that deletes data, moves files, pushes code, or spends budget; see Permission modes.

  • Give the agent only the access it needs. Limit subagents to read-only tools where you can; see Configuring Agents for Your Project.

  • Cap autonomous loops. Bound unattended runs with --max-turns, --max-budget-usd, and a SLURM --time; see Caps on unattended runs.

  • Keep secrets out of reach. A misdirected agent can leak anything your account can read, and read-only commands such as cat run without a prompt even outside your project. Keep credentials out of the project, and block reads of credential files with deny rules in ~/.claude/settings.json, for example Read(~/.ssh/**), Read(~/.netrc) (where wandb login stores its key), Read(~/.cache/huggingface/**), and Read(~/.config/gh/**). Or turn on permissions.blockReadsOutsideWorkingDirectories. Both stop the agent’s file tools and commands such as cat, but not a script that opens the file itself. With the sandbox on, the deny rules hold for scripts too; see Agent sandboxing.

For risk categories and defenses, see OWASP’s Top 10 for Agentic Applications and Top 10 for LLM Applications, which ranks prompt injection first.

24.3.1.1. Untrusted repositories#

A repository you clone can ship project instructions, hooks in .claude/settings.json, MCP servers in .mcp.json, and skills in .claude/skills/ or .agents/skills/, and they run as you. In print mode, Claude Code runs the hooks, starts the servers, and applies the settings’ env block without asking, even in a folder you have never opened. Before you run an agent in a repository you did not write, read those files. With claude -p, add --setting-sources user to skip the project’s settings and .mcp.json.

24.3.1.2. Remote control#

Some agents can be steered from another device. Claude Code’s Remote Control, started with /remote-control in a session, claude --remote-control, or claude remote-control (server mode), or for every session with a setting, connects a session on your machine to claude.ai/code or the Claude phone app. Codex has a similar feature: codex remote-control (experimental) and the ChatGPT app’s remote connections, which can also reach projects over SSH. Any device signed in to the same account can then send the agent instructions and approve its actions, and everything runs on the connected machine.

On the cluster, that machine is your cluster account. With remote control on, any device signed in to your AI account can steer the session, without the FASRC login, two-factor authentication, and VPN that normally protect the cluster. An unlocked phone or a browser left signed in becomes a way into your cluster account. Claude Code also keeps the session’s transcript, including tool activity, on Anthropic’s servers while it is connected. Remote control bypasses normal cluster authentication, so do not turn it on for sessions on the cluster; see Prohibited activities.

  • Keep it off. Do not use Claude Code’s Remote Control, codex remote-control, or the ChatGPT app’s remote connections with cluster sessions. Do not turn on “Enable Remote Control for all sessions” (remoteControlAtStartup) on the cluster.

  • Turn it off for good. "disableRemoteControl": true in ~/.claude/settings.json turns Claude Code’s Remote Control off entirely.

  • Stop it if it is on. Run /remote-control again to disconnect, or end the session; in server mode, press Ctrl+C. For Codex, run codex remote-control stop.

  • Use the usual way in. To check on a long run, log in to the cluster and reattach tmux, or read the batch job’s logs.

If remote control was on and you think someone else used the session, stop it and report it as described in Reporting a concern.

24.3.2. Scoping an agent to its task#

Your account can reach many projects, directories, credentials, and services, but one task usually needs only a small part of them. The agent runs as your process, so a bug, bad input, or prompt injection can reach everything your account can. Ask whether the task has more access than its purpose needs, and shrink it toward the inner box.

        flowchart TB
    subgraph ACCT["Account authority"]
        subgraph NEED["What the task needs"]
            AG(["Agent"])
        end
        EXCESS["Everything else the account can reach:<br/>the blast radius if the agent is misdirected"]
    end
    style ACCT fill:#C6C8F4,color:#14154C,stroke:#14154C
    style NEED fill:#14154C,color:#ffffff,stroke:#3D3E82
    classDef excess fill:#A51C30,color:#ffffff,stroke:#A51C30;
    classDef agent fill:#ffffff,color:#14154C,stroke:#14154C;
    class EXCESS excess;
    class AG agent;
    

24.3.2.1. Prefer enforceable boundaries over prompt instructions#

An instruction such as “do not read files outside this directory” guides the model, but it can fail under adversarial input. Prefer limits enforced outside the model: filesystem permissions, SLURM resource limits, tool restrictions such as --tools and read-only subagents, and the sandbox (see Agent sandboxing). Permission rules sit in between: Claude Code enforces them, but a command rule matches only the command as written, so it is not a boundary on its own. Use both layers: enforced limits set the hard boundary, and instructions guide behavior inside it.

24.3.2.2. Before an unattended run#

Answer these questions before you submit. If you cannot answer one, resolve it first.

Question

What to check

Task boundary

Can you state in one or two sentences what the agent should do?

Read scope

Which files must it read, and what else can it see?

Write scope

Where may it write? Can it reach environments, checkpoints, datasets, or repositories it should not change?

Credentials

Which tokens, SSH keys, or signed-in sessions can it reach?

Network

Which external endpoints does the task need?

Data policy

Is every dataset it may read allowed here under its data-use agreement and data level? See Security and Compliance.

Untrusted input

Could it read content that carries hidden instructions? See Agent security.

Resource scope

Are CPU, memory, GPU, wall time, and concurrency bounded, and are loops capped?

Evidence

Will the job ID, code version, timestamps, and input and output paths be recorded, without secrets?

Stop condition

What should make the agent stop and return control to you?

If an unattended agent needs data, credentials, network access, or actions outside its task, the safe default is to stop and ask for review, not to widen its own scope.

24.3.2.3. Container filesystem visibility#

A Singularity or Apptainer container does not isolate an agent from the cluster’s files by default. The default configuration mounts /n (home, lab, and scratch space), your working directory, and /tmp inside the container. To restrict it, use --contain or --no-mount, and add only the paths the task needs with --bind. Check what your container can see rather than assume it is isolated. See Containerization and the FASRC Singularity documentation.

24.3.2.4. Agent sandboxing#

Claude Code and Codex can run an agent’s shell commands in an operating-system sandbox that limits which files they can write and which hosts they can reach. The operating system enforces these limits, whatever the model decides. FASRC asks you to run agents in a sandbox or container where possible; see its AI Agents guidance. On Linux, both use a tool called bubblewrap, and Claude Code also needs socat; both are installed on the compute nodes.

Turn the sandbox on with /sandbox, or in a settings file such as ~/.claude/settings.json:

{
  "sandbox": {
    "enabled": true,
    "failIfUnavailable": true,
    "allowUnsandboxedCommands": false,
    "autoAllowBashIfSandboxed": false,
    "excludedCommands": [
      "squeue *", "sacct *", "sinfo *", "seff *", "sstat *", "scontrol *",
      "sbatch *", "srun *", "salloc *", "scancel *", "clustertool *"
    ]
  }
}
  • It covers shell commands only. File-editing tools follow your permission rules, and hooks and MCP servers run outside the sandbox with your full access.

  • Close its escape hatches. By default, Claude can retry a failed command outside the sandbox, and Claude Code runs without the sandbox if it cannot start. allowUnsandboxedCommands: false and failIfUnavailable: true turn both off, so only excludedCommands run outside.

  • Keep your approvals. By default, sandboxed commands run without asking in every mode except plan, even manual and dontAsk, so a batch run’s --allowedTools no longer limits them. autoAllowBashIfSandboxed: false keeps your usual approvals.

  • Run SLURM commands outside it. The sandbox cuts commands off from the SLURM controller: inside it, sinfo waits almost two minutes, then fails with Unable to contact slurm controller (connect failure). In excludedCommands, it answers at once. sbatch, srun, and salloc then run what they launch outside the sandbox too, so keep them on the ask list in Permission rules. clustertool in the list is ClusterTool, the Kempner command-line tool for cluster tasks.

  • Allow what your work needs. Sandboxed commands can write only to the working directory and a temporary directory, and reach other hosts only if you allow them, so uv sync, pip install, model downloads, and W&B online logging fail inside it. Add the paths and hosts they need with filesystem.allowWrite and network.allowedDomains in the sandbox settings, rather than excluding the tools.

  • Keep your deny rules. Without the read block in the next item, sandboxed commands can read most of the machine, including ~/.ssh, but not the paths your Read deny rules cover; see Agent security. Inside the sandbox, a script that opens a denied file fails with FileNotFoundError; outside it, the script can read the file.

  • Know what the read block hides. With permissions.blockReadsOutsideWorkingDirectories on, the sandbox hides your whole home directory from sandboxed commands, not only the denied paths. Other paths outside the project, such as lab storage, scratch, and the Shared Data/Model Repository, stay readable. So a tool or an environment in your home directory cannot run in sandboxed commands: for example, uv in ~/.local/bin, a conda environment in ~/.conda/envs, or a virtual environment whose Python is in ~/.local/share/uv. Keep these outside your home directory, for example in lab storage: set uv’s UV_PYTHON_INSTALL_DIR to lab storage and UV_PYTHON_PREFERENCE=only-managed, then build the virtual environment again.

  • Keep SLURM calls simple. A call leaves the sandbox only if every command in it is excluded, and a redirect, a cd, or a $(...) keeps it inside. So squeue --me | grep RUNNING stays sandboxed and fails. Add to your project instructions: “Run SLURM and ClusterTool commands on their own, without pipes, redirects, cd, or $(...).”

See the Claude Code sandboxing documentation.

codex exec starts in a read-only sandbox, and --sandbox workspace-write allows edits in the working directory with network access off. sinfo inside Codex’s sandbox fails the same way after almost two minutes, so run SLURM commands yourself rather than through Codex’s sandbox.

See the Codex sandboxing documentation.

See also

For setting up and running agents on the cluster, see Using Agentic AI on the Cluster. For permission rules, hooks, and caps on unattended runs, see Configuring Agents for Your Project. For the university and FASRC rules behind this page, see Security and Compliance.