Skip to content

Guidance4 min read

Code generation assistants: the supply chain risk your developers opted into

Coding assistants changed the shape of application risk: insecure patterns arrive faster, dependencies get invented, and code context leaves the building. All three are manageable.

Sameer

Founding Engineer

A laptop screen showing lines of source code in a dark editor
Photo: Lewis Ngugi (CC0, via Wikimedia Commons)

Coding assistants are the most widely adopted enterprise AI tool and the least formally reviewed, because they arrived through individual developers rather than procurement. The risks are not exotic, but they scale with adoption in a way that older code-quality problems did not.

Hallucinated dependencies, and the attack built on them

Models suggest package names that do not exist. Attackers register those names. A developer accepts the suggestion, the install succeeds, and arbitrary code runs in a build environment with credentials. The technique has a name now — slopsquatting — and it needs no vulnerability in the assistant at all.

  • Test your own exposure: collect package names your assistants suggest across common prompts and check which are unregistered. That list is your attack surface.
  • Private registries with an allowlist and a proxy are the effective control, because they turn a hallucinated name into a failed install rather than a silent compromise.
  • Lockfiles, provenance checks and install-script policies limit what a mistaken install can do.

Secrets, in both directions

  • Outbound: assistants send surrounding context to a provider. That context routinely includes credentials in configuration files, internal endpoints, customer data in test fixtures and comments nobody intended to publish. Establish what the assistant transmits, whether it honours exclusion files, and whether the provider retains it.
  • Inbound: assistants reproduce credential-shaped literals from training data and, worse, happily write code that reads a hard-coded key when asked to "just make it work". Secret scanning in pre-commit and in CI catches this; code review alone does not, at the volume AI-assisted development produces.

Insecure patterns at speed

The security quality of generated code reflects its training data, which includes a great deal of tutorial code written for clarity rather than safety. The patterns we most often find in AI-assisted codebases:

  • String-concatenated SQL where the surrounding code uses parameters, because the model followed the prompt’s phrasing rather than the file’s convention.
  • Authorisation checks on the route but not on the object — the generated handler validates the session and then trusts an identifier from the request.
  • Verification disabled to make something work: certificate checks off, signature validation skipped, CORS set to a wildcard.
  • Cryptography assembled from plausible-looking pieces — ECB mode, static IVs, fast hashes for passwords.
  • Error handlers that return the exception to the client.

None of these are new. What is new is the rate, and that they arrive in code that reads as if it were written carefully. Review attention is the scarce resource, which is why the controls have to be automated.

Agentic coding tools raise the stakes

Assistants that run commands, edit files across a repository and open pull requests are agents, and they belong under the agent controls: scoped credentials, no production access, an approval step before anything merges, and an audit trail. A coding agent with a cloud credential in its environment is a privilege-escalation path from a comment in a ticket.

What we test, in order

  1. What each assistant transmits, to whom, with what retention and training terms, and whether exclusion configuration is honoured in practice.
  2. Hallucinated-package exposure against your own prompt patterns, and whether the registry proxy blocks the installs.
  3. Secret scanning coverage at pre-commit, CI and in the assistant’s own context window.
  4. Generated-code review: a sample of AI-assisted changes against the categories above, reported as rates rather than anecdotes.
  5. Agentic tool permissions: credentials available in the environment, network reach, write scope, and the approval gate before merge.
  6. CI/CD exposure, since a compromised dependency or agent acts with pipeline credentials — the highest-value target in the estate.
  7. Policy reality: whether the tools developers actually use match the tools that were approved.

Controls that hold up

  • A private registry proxy with an allowlist, so an invented package name cannot resolve.
  • Secret scanning in pre-commit hooks and CI, with ignore files that the assistants respect and that cover configuration and fixtures.
  • SAST and dependency scanning as merge gates rather than advisory dashboards, because volume has outpaced review.
  • Approved-tool list with enterprise terms: training exclusion, retention, and a sub-processor position you can give a customer.
  • Coding agents run with scoped, short-lived credentials, no production reach, and a human approving every merge.
  • Review guidance that tells reviewers where generated code fails most often, so attention goes to authorisation and crypto rather than formatting.

Where to start

Ask your assistants to solve ten typical tasks in your stack, collect every package they suggest, and check which names are unregistered. Then register nothing and block everything: point installs at a proxy with an allowlist. It is the cheapest high-value control in this entire list.

Questions we get asked

Should we ban AI coding assistants?
Banning moves usage out of view rather than out of existence. Approve specific tools with enterprise terms, block the rest at the network where you can, and put the automated controls — registry proxy, secret scanning, merge gates — in place for the code that results.
Does AI-assisted code need more penetration testing?
It needs the same testing applied to more code, with emphasis shifted toward object-level authorisation, injection in data access layers and cryptographic misuse, which is where generated code fails most reliably.
How do we stop our source code leaving the company?
Choose tools with contractual training exclusion and defined retention, configure and verify exclusion files, keep secrets out of the repository so context leakage is less damaging, and block unapproved assistants at the network layer where your environment allows it.
  • AI coding assistant security
  • code generation LLM risk
  • slopsquatting hallucinated packages
  • secure SDLC AI
  • developer tool security