Safeguard
AI Security•

Should a cloud agent's setup phase have more internet than its work phase?

Splitting a cloud agent's run into setup and work lets you allow installs early and narrow the network later. How the split works and what it leaves open.

Safeguard Security Team
7 min read

Yes, in most cases. Let a setup step fetch dependencies with the access it needs, then run the agent with a much narrower network. That way the part that executes model-driven commands has the least reach. The catch is that setup itself runs code from your dependencies, so it needs scrutiny too.

How one platform splits it

One vendor documents that its cloud environments block internet access during the agent phase by default, while setup scripts still run with internet access so they can install dependencies. Internet access for the agent phase can be turned on per environment, with a domain allowlist and a method limit.

Another platform lets you define a setup workflow that installs tools before the agent starts. It documents that without setup steps, the agent installs dependencies by trial and error, which can be slow and unreliable and may fail for private dependencies. Setup steps make that deterministic. It also notes that its firewall does not directly cover processes started in setup steps.

Put those together and you get a useful pattern. Setup is predictable and scripted, so you can review and pin it. The agent phase is open ended, so it gets the tight network.

Why the split helps

PhaseWho decides the commandsNetwork needGood policy
SetupYou, in a reviewed scriptRegistries and private package hostsAllow named hosts, pin versions
Agent workThe model, influenced by repository and web contentOften noneDefault deny, add narrowly

The agent phase is where prompt injection can steer behavior. OWASP describes indirect injection as instructions hidden in content the model processes, such as files or web pages. A tight network during that phase limits where an injected instruction can send data.

What the split does not fix

  • Setup is code execution. Install scripts from dependencies run with whatever the setup phase has. Pin versions and prefer lockfile installs.
  • Secrets present at setup may persist. One platform's page does not say how secrets are exposed to setup versus agent phases, so check this for your vendor rather than assume.
  • The agent may need packages later. If it hits a block, you will see failures. Decide whether to widen access or add the package to setup.
  • Caching copies the result. One vendor caches what a setup script installs, so a compromised install could repeat across sessions until the cache is rebuilt.

A starting recipe

  1. Write setup as a script in version control with reviewed changes.
  2. Use lockfiles and exact versions.
  3. Allow only registries you actually use during setup.
  4. Switch to none, or a short custom list, for the agent phase.
  5. Rebuild cached environments on a schedule and when a dependency advisory affects them.
  6. Check whether tokens used for setup are still present in the agent phase, and remove them if so.

Worked example: what a setup run actually does

An illustrative scenario for a service with a lockfile of a few hundred packages.

During setup, the script runs a lockfile install. That one command downloads each listed package and its transitive packages. Some run install scripts. The script then runs a build step that compiles native code, and finally warms a test database. All of this happens with network access to the registries, and perhaps with a read-only token for a private feed.

Then the agent phase begins with the network cut. The agent edits code, runs unit tests, and prepares a branch. It does not need the registry, because everything it needs was installed in setup. If it tries to add a new package, that request fails, and the agent reports the block, which is the correct outcome: adding a dependency becomes a human decision.

This pattern also changes how you review. In setup you review the script and the lockfile. In the agent phase you review the diff, including any attempt to change the lockfile.

Phase comparison

QuestionSetup phaseAgent phase
Who writes the commands?YouThe model
Is the input predictable?MostlyNo
Typical network needRegistries, private feedNone for most tasks
Secrets presentOften a registry tokenShould be none, or scoped and unreadable
Main riskCompromised or mistaken packagePrompt injection, data exfiltration
ControlPinning, scanning, reviewed scriptDefault deny, review, logging

Steps to implement the split

  1. Put install and build in a script that runs before the agent, and version it.
  2. Give that phase read only access to the specific feeds it needs.
  3. After setup, revoke or discard setup credentials.
  4. Switch the network policy to deny for the agent phase, or to a short list.
  5. Make dependency changes a deliberate action: the agent proposes, a person approves, and the next setup run installs.
  6. Record the installed package list as an SBOM for each environment build.

Edge cases

  • Tools that download at run time. Some test frameworks fetch browsers or data on first use. Pre-fetch them in setup.
  • Language servers and formatters. Install during setup, so the agent phase stays quiet.
  • Private package changes mid task. If the agent legitimately needs a newly published internal package, publish it first and rebuild the environment.
  • Caches. If the platform caches setup output, rebuild it when a dependency advisory lands. One vendor documents that its cache keeps what a setup script installs, so staleness is your problem to manage.

When the split does not fit

Some tasks, such as research agents that browse documentation, need network access during work. For those, use an allowlist of specific documentation hosts and method limits, and keep the agent away from credentials entirely.

Where Safeguard fits

Safeguard does not control the platform network. Its dependency scanning and policies can check what a setup script installs, and you can run a free scan at gold.safeguard.sh/scan.

Try it yourself

Click through it at your own pace, or open it full screen.

Click through it and look at how direct and transitive packages appear, since setup installs both.

Quick check

Can the agent install packages during its work phase?

Only if the agent phase network allows it. Many teams prefer to install in setup and keep the work phase closed.

Do setup scripts need review?

Yes. They run dependency install code, sometimes with broader network and credentials than the agent has.

What if the agent needs a package that setup did not install?

Treat it as a request, not an automatic action. A person reviews the package, adds it to the lockfile, and the next setup run installs it.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.