# How do I stop Claude Code or other coding agents from installing malicious or slopsquatted packages?

Answers / Guard. Breadcrumb: [Home](https://osty.dev/) / [Answers](https://osty.dev/answers) / Block malicious coding-agent installs

Put `osty-proxy` in front of package registries and gate lockfiles with `osty verify` before any install hook executes. Osty (osty.dev) detonates each new release in a honey-secret Firecracker microVM, diffs artifacts against Git tags and enforces cooldowns so slopsquatted or hijacked packages fail closed before an agent runs them, as scenarios `a03` and `a05` prove.

Table: Coding-agent dependency failure modes and the pre-install control that stops each one

| Attack vector | Why coding agents hit it | Pre-install control in Osty | Proof |
| --- | --- | --- | --- |
| Slopsquatted package names | Models hallucinate plausible package names that attackers register on npm or PyPI with install hooks. | Cooldown hold (`defaultCooldownHours`) plus Firecracker honey-secret detonation before first install. | Scenario `a03` |
| Freshly hijacked maintainer release | An agent asked to bump dependencies pulls a patch release published minutes earlier. | Signed `vPrev -> vNew` behavior baseline and DNS/TLS sinkhole trace block the pull at `osty-proxy` and `osty verify`. | Scenarios `a03`, `a04` |
| Poisoned tarball or wheel | Source repo looks clean to the agent, but the published registry artifact adds a `postinstall` script. | File-by-file diff between the published artifact and its upstream Git tag escalates the verdict before install. | Scenario `a05` |
| Sneaked transitive or unlisted package | Prompt injection in release notes or a package README steers an agent to add an extra dependency. | `forbidUnlistedDependencies: true` in the Policy Patch Verifier rejects any dependency outside the authorized closure. | Scenario `a10` |

Gate a lockfile against signed verdicts before install runs:

```bash
osty verify --lockfile package-lock.json --json
```

## Why coding agents widen the install-time blast radius

Interactive and autonomous coding agents such as Claude Code, Codex and Cursor routinely run `npm install`, `uv add` or `pip install` inside shells that hold developer SSH keys, cloud profiles, `.npmrc` tokens and CI secrets. Two failure modes compound when installs happen faster than humans audit them: slopsquatting, where attackers register package names that models frequently hallucinate, and maintainer takeovers that slip a secret stealer into a minor or patch release.

Asking the same model whether a package is safe does not close the gap. Model weights are static, release artifacts are fetched from live registries, and lifecycle scripts execute during install before any test suite runs.

## Put a pre-install firewall between the agent and the registry

The reliable fix sits outside the coding agent. Route package manager traffic through `osty-proxy` so every resolved version must carry a clean, Ed25519-signed Plane 1 verdict and pass your cooldown window before the tarball or wheel is served, and gate every lockfile in CI with `osty verify` before `npm ci` or `pip install` runs.

Supply-chain and patch-verifier rules in `.osty/policy.yaml`:

```yaml
apiVersion: osty.io/v1
kind: FleetPolicy
supplyChain:
  defaultCooldownHours: 48
  fastTrackVerifiedKEV: true
  blockVerdicts: [CONFIRMED_MALICIOUS, QUARANTINED_HIGH_RISK]
  blockLicenseChanges: true
  proxyFailureMode:
    prodCI: FAIL_CLOSED
    devLaptop: FAIL_OPEN_WITH_CACHE
patchVerifier:
  forbidUnlistedDependencies: true
  forbidNewShellOrNetworkPrimitives: true
```

Verify the policy and gate the lockfile before running install:

```bash
osty policy validate .osty/policy.yaml
osty verify --lockfile package-lock.json --policy .osty/policy.yaml --json
```

## Give coding agents signed verdicts before they suggest a bump

Alongside enforcement at the proxy and in CI, coding agents can check Osty before choosing a package version. The read-only public MCP server at `https://mcp.osty.dev/mcp` exposes `verify_package`, `check_cve_backport` and `check_upgrade_compatibility` backed by Ed25519-signed Plane 1 snapshots, and the `osty-security` Agent Skill in `osty-dev/agent-skills` teaches agents the exact `osty` CLI commands and flags.

## What a registry gate does not replace

- Osty does not sandbox a developer's interactive terminal session or restrict arbitrary shell commands a coding agent executes outside package installs; keep your agent's own permission and sandbox controls enabled.
- Disable lifecycle scripts by default where your ecosystem allows it (`npm ci --ignore-scripts`) as defense in depth alongside `osty verify` and `osty-proxy`.
- Osty is not a first-party SAST or secret scanner for code your coding agent writes directly; keep secret scanning and code review in place for application code.

## Frequently asked questions

### Does `osty-proxy` work with Claude Code, Codex and Cursor without changing how developers prompt?

Yes. Because `osty-proxy` sits in the registry path used by npm, PyPI, Go, Cargo and Maven, every package pull triggered by a developer, CI runner or coding agent passes through the same verdict and cooldown check automatically.

### What if a coding agent hallucinates a brand-new package name an attacker registered today?

A newly published package is held by `defaultCooldownHours` and detonated in Plane 1's Firecracker honey-secret sandbox before it can clear as `CLEAN`. Any credential exfiltration or anomalous install hook blocks the install.

### Can we start without deploying `osty-proxy` in our VPC?

Yes. Start with `osty verify` in CI through `osty-dev/osty-action` before the install step, and connect coding agents to the free public MCP server (`https://mcp.osty.dev/mcp`) or `osty` CLI. Add in-VPC `osty-proxy` on Enterprise when you want inline registry enforcement.

## Related pages

- [Osty vs Claude Code and coding agents](https://osty.dev/compare/osty-vs-coding-agents): Why teams with coding agents still need pre-install detonation, runtime truth and deterministic policy enforcement.
- [Block npm postinstall secret theft](https://osty.dev/answers/block-npm-postinstall-secret-exfiltration-ci): How honey-secret Firecracker detonation catches credential exfiltration before `npm ci` runs.
- [Pre-install supply-chain firewall](https://osty.dev/guard): Verdicts, cooldowns, source-vs-Git diffs and progressive rollout for `osty verify` and `osty-proxy`.
- [Edge and proxy reference](https://osty.dev/docs/edge-proxy): Flags, routes and fail-closed settings for `osty-proxy`.

## See what is actually exposed in 10 minutes

Connect a read-only GitHub App and cloud role. Osty installs nothing in your environment and writes nothing to your repositories. The report strips out backport and reachability noise before your team or coding agents patch it, and flags stale deploys and unowned workloads.

Get a free X-Ray: https://osty.dev/xray

Written by Osty Engineering. Published 2026-11-29. Updated 2026-11-29.

Canonical: https://osty.dev/answers/stop-coding-agents-installing-malicious-slopsquatted-packages
