Safeguard
Supply Chain•

What does a cloud agent setup script install, and who checks it?

Setup scripts for cloud coding agents pull packages and tools before the agent starts. How to pin, scan, and cache them so setup is not a supply chain gap.

Safeguard Security Team
6 min read

A cloud agent setup script installs your toolchain and dependencies before the agent starts, often with wider network access than the agent has. That makes it a supply chain entry point. Pin versions, use lockfiles, install from known registries, scan the result, and rebuild cached environments when advisories land.

Why setup deserves attention

Platforms document that setup runs differently from agent work. One lets setup scripts reach the internet to install dependencies while blocking the agent phase by default. Another lets you define setup steps in a workflow file so tools are installed deterministically, and notes that without them the agent installs by trial and error, which may be slow, unreliable, or fail for private dependencies. One vendor caches what a setup script installs so packages are available at the start of every session.

Caching is convenient, but it also means a bad install can persist. That is the same risk as a poisoned build cache.

What can go wrong

RiskExample
Unpinned versionsA new release changes behavior between runs
Install scriptsA dependency runs code at install time
Lookalike or compromised packagesA typo or hijack pulls the wrong code
Broad registry accessThe setup network reaches more than needed
Stale cacheAn old vulnerable layer keeps being reused
Secrets in setupTokens used to fetch private packages remain available

A safer setup script

  1. Store it in version control with code review.
  2. Install from lockfiles with exact versions, and fail if the lockfile is out of date.
  3. Restrict setup network access to the registries you use.
  4. Use read-only, short-lived tokens for private registries.
  5. Generate an SBOM of the resulting environment and keep it with the build.
  6. Scan the SBOM for known vulnerabilities, and review new packages.
  7. Rebuild the cached environment on a schedule, and immediately when an advisory affects it.
  8. Confirm that setup credentials are removed or not present in the agent phase.

Who checks what

StepOwner
Reviewing script changesCode owner for the repository
Registry allowlistPlatform or security engineering
Scanning the environmentSecurity or the team that owns the toolchain
Cache rebuildsPlatform team

Try it yourself

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

Look at how direct and transitive dependencies are listed, which is the inventory you want for a setup environment.

Worked example: a pinned versus unpinned setup

An illustrative comparison.

Unpinned. The setup script runs a package install with no lockfile and installs a global tool at its latest version. Monday's run and Thursday's run install different versions of a transitive package. On Thursday a maintainer account for that package was compromised and a release shipped with a malicious install script. The script runs during setup, with registry access and any token in reach. The cached environment then carries the bad package into every session until someone notices.

Pinned. The script uses a lockfile install that fails if the lockfile does not match the manifest, and the global tool is installed at an exact version. Thursday's release is not picked up. A scheduled job later proposes a lockfile update in a pull request, which a person reviews and a scan checks before it merges. If the new version carries a known issue, the pull request is held.

The difference is not that pinning is magic. It turns a silent change into a reviewed one.

A reviewable setup file layout

PieceWhere it livesReviewed by
Setup scriptRepository, in a dedicated folderPlatform owners
LockfilesRepository rootCode owners
Tool versionsA single versions filePlatform owners
Registry allowlistPlatform configurationSecurity
Base image referencePinned by digestPlatform owners
SBOM of the built environmentStored with build artifactsSecurity, on demand

Pre-merge checks for setup changes

  1. Does the change add a new registry or host?
  2. Does it add a tool downloaded from a URL rather than a registry?
  3. Does it add a step that runs a downloaded script directly?
  4. Does it change token usage?
  5. Does it alter caching behavior?

Any yes needs an explicit reviewer sign off.

Using findings well

A scan of a large environment returns many findings. Not all matter equally. Use reachability to see which vulnerable code your own code can actually call, and prioritize those. For tools used only during setup and not present at agent time, the risk profile differs from packages loaded by your application, so label them separately.

Rebuild triggers

Rebuild the cached environment when:

  • A scan reports a new serious issue in something it contains.
  • A dependency in the lockfile changes.
  • The base image has a security update.
  • A setup script changes.
  • A fixed schedule passes, such as weekly.

Evidence you can show

Keep the lockfile, the SBOM, the scan result, and the review record for each environment build. When a customer asks how your agent environments are controlled, that bundle is a concrete answer.

Where Safeguard fits

Safeguard provides SBOM and dependency scanning, plus reachability analysis to show which findings matter. Run a free scan at gold.safeguard.sh/scan.

Quick check

Should setup scripts install the latest versions?

No. Pin exact versions so each run is reproducible and reviewable.

Is a cached environment safer or riskier?

Both. It is faster and consistent, but a bad layer persists until you rebuild, so rebuild on a schedule.

Do setup-only tools need the same scrutiny as application dependencies?

Yes, because they execute with network access and sometimes credentials. They may carry a different risk profile at agent time, so track them separately but do not ignore them.

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.