AI & Software Architecture

The AI Code Supply Chain

Introduction: the code is only one part of the trust problem

For years, software supply-chain security has focused on the components that enter a build: open-source packages, container images, build tools, source repositories and deployment artefacts. That model remains essential. But AI coding agents introduce another set of inputs that can influence what gets written, executed and committed.

This creates a broader trust question: can the organisation establish that the agent, the information it consumed, the actions it took and the artefact it produced were all sufficiently trustworthy?

A pull request can pass tests and still contain an unsafe workflow change. A model can perform well on ordinary evaluations yet contain a dormant backdoor. A package name can look plausible while not existing in a trusted registry. A repository instruction file can quietly steer an agent towards an action that a human reviewer never intended.

The emerging engineering discipline is not simply ‘review AI-generated code’. It is to secure the entire AI-assisted development chain—from model selection and input integrity to execution boundaries, code review, build provenance and release verification.

Diagram showing an AI coding agent proposing code through a pull request, checked by an independent CI/CD gate before signed release.

Why November 2026 makes this more than a theoretical concern

On 12 November 2026, Microsoft Security Research published ‘Trained to betray: How post-training supply chain attacks hijack coding agents’. The work examines two compromise routes: poisoning fine-tuning data and poisoning model checkpoints.

In the dataset-poisoning experiment, researchers inserted 90 crafted examples into a corpus of roughly 9,000 terminal-agent conversations. The model learned to respond to an ordinary-looking request by identifying an available command-execution tool and using it for an unsafe action. Reported attack success was approximately 78% on the two harnesses represented during training. Transfer to an unseen harness varied, illustrating that the behaviour was not universally portable.

In a separate model-poisoning setting, the researchers reported average success rates of 84.1% to 94.8% on unseen repositories. These figures belong to controlled experimental conditions and specific attack designs; they are not estimates of the probability that a commercial coding assistant is compromised. Their significance is architectural: a model can appear useful and behave normally in routine evaluation while retaining conditional behaviour that becomes dangerous when connected to tools.

Model evaluation is necessary, but it cannot be the only security boundary. An enterprise must assume that a model, dataset, tool or instruction source could be compromised and design the development environment so that a single failure cannot become an unrestricted action.

The AI code supply chain: what has changed?

A traditional software supply chain can be represented as source code → dependencies → build system → artefact → deployment. AI-assisted development adds upstream and side-channel influences that can change each stage.

ElementWhat enters the workflowRepresentative risk
Model and checkpointHosted model, open-weight checkpoint, fine-tuned modelBackdoor, untrusted origin, unclear version or training provenance
Training and evaluation dataFine-tuning examples, preference data, benchmark setsPoisoned trajectories, contaminated evaluation, hidden unsafe behaviour
Context and instructionsAGENTS.md, IDE rules, prompts, issues, code comments, docsPrompt injection, hidden instructions, unsafe changes to sensitive files
Tools and extensionsMCP servers, IDE extensions, CLI tools, browser/API integrationsTool poisoning, compromised extension, excessive permissions
Dependencies and generated codeNew packages, copied snippets, generated configuration and scriptsHallucinated or malicious dependency, insecure implementation, licence concerns
Build and releaseCI workflows, secrets, build runners, signing and deploymentCredential exposure, workflow tampering, unverified artefacts

1. Model and dataset provenance: know what you are running

Organisations often assess a coding assistant by visible product features: model quality, IDE integration, latency, cost and developer experience. For high-trust environments, that is incomplete. The model itself is a software dependency.

For every model or checkpoint used in engineering workflows, record:

Apply similar controls to fine-tuning and evaluation datasets. Track source, licence, collection method, transformations, filtering, labelling and version. Preserve dataset lineage so a suspicious training example can be traced to its origin. A large dataset is not automatically trustworthy; a reputable hosting platform is not proof that every row is safe.

For third-party checkpoints, use an explicit intake process. Verify hashes and signatures where available, inspect publisher identity and release history, scan artefacts, review model cards and test the checkpoint in isolation. Treat an unexplained checkpoint change as a dependency change requiring re-approval.

2. Treat repository instructions as executable influence

Files such as AGENTS.md, IDE-specific rule files, prompt templates and project-level assistant instructions can look like harmless documentation. In practice, they influence what an agent reads, which commands it runs and how it modifies a repository. Govern them like code.

This is especially important when agents ingest untrusted content. A GitHub issue, pull-request description, external web page, log entry or dependency README may contain text designed to manipulate the agent. The agent may interpret that content as instructions even though it is merely data supplied by an external party.

Instructions that can change agent behaviour are part of the attack surface. Their ownership, integrity and review history should be visible.

3. Apply least agency, not just least privilege

Least privilege limits what an identity can access. AI coding agents need an additional concept: least agency. The agent should be allowed to perform only the actions necessary for the task, for the shortest practical period, within a defined workspace.

A developer may have broad access to source repositories, cloud accounts, package registries and production systems. Giving an agent the developer’s full session effectively transfers that authority to a probabilistic system that can be influenced by untrusted content.

A safer design separates the developer identity from the agent’s execution identity. Give the agent a disposable development container or isolated workspace, scoped credentials, restricted network egress and explicit approval gates for sensitive operations.

Action Default controlReason
Read repository filesWorkspace-scoped read accessAvoid unrelated local and credential files
Edit source codeWrite access only inside assigned workspacePrevent uncontrolled file-system changes
Install dependenciesAllowlisted registries; review new packagesReduce dependency confusion and malicious package risk
Run shell commandsSandbox; command policy; approval for risky commandsLimit execution and persistence
Access networkDeny by default; allowlist required endpoints Reduce data exfiltration and remote payload retrieval
Access secrets No production secrets; short-lived scoped tokens only Contain credential theft and misuse
Change CI/CD or deployment Separate approval and protected branch controls Prevent an agent changing its own release boundary

This is not about making agents ineffective. An agent tasked with refactoring a service should not need production database credentials, unrestricted outbound internet access or permission to alter release workflows.

4. Verify tools and extensions as software dependencies

An agent’s capabilities are determined partly by the tools connected to it. An MCP server, IDE extension, command-line helper or browser integration can read data and perform actions under the permissions granted by the host environment. Tool metadata and responses can also influence the agent’s decisions.

Tool approval should be treated as a lifecycle, not a one-time click. Maintain an inventory of approved tools, their owners, versions, source repositories, permissions, network destinations and data access. Pin versions where possible and review changes to tool schemas, descriptions and endpoints. Reassess a tool when its publisher, maintainer, hosting location or requested permissions change.

Do not rely on a model to recognise malicious tool instructions. Enforce authorisation outside the model. Validate tool arguments against strict schemas, reject unexpected parameters, restrict file paths and API scopes, and log both the request and the actual operation. Where an action changes business data or infrastructure, the system executing that action—not the model’s explanation—must enforce the policy.

5. Generated dependencies need independent verification

Coding models can recommend packages that are outdated, insecure or simply nonexistent. The latter creates a risk commonly described as package hallucination or ‘slopsquatting’: an attacker may register a plausible package name suggested by a model and publish malicious code under it.

A generated package reference should never be treated as a verified dependency. Before installation, check that the package exists in the intended registry, confirm its canonical name and maintainer, inspect release history, review dependency relationships and apply the organisation’s software composition analysis policy.

The same scrutiny applies to generated Dockerfiles, GitHub Actions, shell scripts, Terraform, Kubernetes manifests and package-manager configuration. These files can affect the build and deployment environment even when application code itself looks correct.

6. Make CI/CD the independent verification boundary

A common mistake is to let the same agent that writes a change also decide whether that change is safe. An agent can propose tests, run them and summarise results, but those outputs are not independent evidence. The organisation’s trusted pipeline must verify the change using controls that do not depend on the agent’s assertions.

A practical pull-request pipeline for AI-assisted changes should include:

The key is separation of duties. The coding agent can create a pull request, but it should not be able to weaken the checks that evaluate that pull request. It should not modify protected workflow definitions and then approve the resulting workflow. CI credentials should be scoped to the job, and untrusted pull-request code should not receive access to secrets.

AI does not replace dependency scanning, code review, branch protection, build isolation or release controls. It increases the importance of applying them consistently.

7. Build an evidence trail for every AI-assisted change

Organisations do not necessarily need to record every token exchanged with a model. They do need enough evidence to reconstruct how a consequential change was produced and approved.

For material changes, capture a compact development record:

This record supports incident response, change accountability and client assurance. It helps answer whether a defect came from generated code, an untrusted dependency, a compromised tool, a malicious instruction or a build workflow change. Keep evidence proportionate: store sensitive prompts and repository content only where necessary, apply retention controls, and avoid creating a new data-leakage repository in the name of auditability.

A practical reference architecture

The following operating model separates the agent’s ability to propose work from the organisation’s authority to execute and release it:

  1. Developer task and approved repository scope are established.
  2. Agent runs in an isolated workspace using an approved model, pinned tools and scoped credentials.
  3. Repository instructions are version-controlled; external content is treated as untrusted input.
  4. Agent proposes code and dependency changes but cannot bypass protected branches or CI policy.
  5. Independent CI executes tests, security scans, policy checks and provenance generation.
  6. Human reviewers approve sensitive changes and verify business intent, not just test status.
  7. Release pipeline verifies the approved commit and trusted build artefact.

A 30-day implementation plan for engineering leaders

Period PriorityDeliverable
Week 1 Discover and classify Inventory AI coding tools, models, extensions, MCP servers, repositories and data access. Identify high-risk code paths.
Week 2 Contain execution Move agent work into isolated workspaces. Remove production secrets, restrict network access and introduce scoped identities.
Week 3 Protect repository and pipeline Review instruction files, pin approved tools, protect CI/CD configuration, enforce dependency and security scans.
Week 4 Prove and improve Introduce change evidence, test prompt-injection scenarios, review exceptions and establish ownership and metrics.

Metrics worth tracking

Avoid measuring success only by the number of AI-generated lines or pull requests. Track whether the organisation is maintaining control as throughput increases:

Common mistakes to avoid

Conclusion: trust the process, not the generated explanation

AI coding agents are becoming part of the software production system. Their influence extends beyond the lines they generate: they consume data, interpret instructions, select tools, install dependencies and interact with build environments. That makes the AI code supply chain a genuine extension of the software supply chain.

The answer is not to prohibit agentic development or to assume every generated change is unsafe. It is to make trust verifiable. Know which models and tools are approved. Protect the integrity of instructions and datasets. Give agents narrow, temporary authority. Verify dependencies independently. Keep CI/CD controls outside the agent’s reach. Preserve enough evidence to reconstruct consequential changes.

The central engineering principle is this: an AI agent may propose a change, but it should never be the sole authority that validates, authorises and releases that change.

FAQ

It is the complete set of models, training artefacts, instructions, tools, dependencies, execution environments and build processes that influence software created or modified with AI coding systems.
Passing tests is useful evidence of functional behaviour, but it does not prove the absence of security flaws, malicious dependencies, unsafe workflow changes or compromised upstream components. Independent security and policy checks are still required.
It is a model whose training or post-training process has introduced hidden conditional behaviour. Under a trigger, it may misuse tools or perform unsafe actions while appearing normal on ordinary tasks.
Least agency limits an AI agent to the smallest set of actions, resources and duration needed for a task. It complements least privilege by restricting what the agent can do, not only what data it can access.
Not necessarily. Retain proportionate evidence for consequential actions—model and tool versions, agent identity, sensitive tool calls, code changes, approvals and build results—while applying privacy, security and retention controls.
No. It extends DevSecOps controls to new upstream inputs and actors. Secure code review, dependency scanning, CI/CD isolation, branch protection and release verification remain essential.