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.
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.
Element
What enters the workflow
Representative risk
Model and checkpoint
Hosted model, open-weight checkpoint, fine-tuned model
Backdoor, untrusted origin, unclear version or training provenance
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:
Provider or publisher, model identifier, exact version and retrieval date.
Checkpoint hash or immutable reference where self-hosted or locally downloaded.
Whether the model is hosted, open-weight, fine-tuned internally or supplied by a third party.
Available information about training, fine-tuning and evaluation-data provenance.
Approved use cases, prohibited data classes and systems the model may access.
Evaluation results, known limitations, approval owner and review date.
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.
Place agent instruction files under version control and require code-owner review for changes.
Scan instruction files for unexpected hidden Unicode, encoded text or unusual command directives.
Separate trusted project instructions from untrusted issue text, web content, logs and generated output.
Require elevated review when proposed changes touch authentication, authorisation, cryptography, secrets, CI/CD, infrastructure or payment logic.
Record material instruction-file changes in the same audit trail as source-code changes.
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 control
Reason
Read repository files
Workspace-scoped read access
Avoid unrelated local and credential files
Edit source code
Write access only inside assigned workspace
Prevent uncontrolled file-system changes
Install dependencies
Allowlisted registries; review new packages
Reduce dependency confusion and malicious package risk
Run shell commands
Sandbox; command policy; approval for risky commands
Limit execution and persistence
Access network
Deny 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.
Is this the correct package, from the intended registry and publisher?
Is the version pinned and compatible with the project’s support policy?
Does it introduce transitive dependencies or install-time scripts?
Are there known vulnerabilities, suspicious release changes or abandoned maintenance?
Does its licence comply with the product’s distribution and client obligations?
Can the requirement be met with an existing approved library instead?
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:
Deterministic build and automated unit, integration and regression tests.
Static application security testing and software composition analysis.
Secret scanning, licence checks and infrastructure-as-code scanning where relevant.
Policy checks for protected files, dependency changes, workflow modifications and permission expansion.
Branch protection, required human review and code-owner approval for sensitive areas.
Build provenance and artefact integrity controls, including signing and verification where supported.
Traceable links between source commit, build run, dependencies, approvals and release artefact.
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:
Task or ticket identifier and repository commit.
Approved model/tool identity and version, where available.
Agent execution identity and workspace or runner identifier.
Relevant instruction-file and tool-configuration versions.
Dependencies added, removed or upgraded.
Commands and tools used for sensitive operations.
Security and test results, including failed checks and waivers.
Human reviewer, approval decision and release artefact identifier.
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:
Developer task and approved repository scope are established.
Agent runs in an isolated workspace using an approved model, pinned tools and scoped credentials.
Repository instructions are version-controlled; external content is treated as untrusted input.
Agent proposes code and dependency changes but cannot bypass protected branches or CI policy.
Independent CI executes tests, security scans, policy checks and provenance generation.
Human reviewers approve sensitive changes and verify business intent, not just test status.
Release pipeline verifies the approved commit and trusted build artefact.
A 30-day implementation plan for engineering leaders
Period
Priority
Deliverable
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.
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:
Percentage of AI-assisted repositories using approved, inventoried tools and models.
Percentage of agent sessions running with isolated workspaces and scoped credentials.
New dependency verification rate and percentage of dependencies pinned.
Security findings per AI-assisted change, separated by severity and component.
Percentage of sensitive-file changes receiving required specialist review.
Rate of CI policy bypass attempts, exceptions and failed security gates.
Time from detection to containment for compromised model, tool or dependency scenarios.
Common mistakes to avoid
Assuming a reputable model provider eliminates model, dataset or account compromise risk.
Treating a successful benchmark or clean demonstration as proof of model integrity.
Giving an agent the developer’s full credentials because it is convenient.
Allowing repository instructions or MCP tool descriptions to change without review.
Installing model-suggested packages before verifying identity and provenance.
Letting an agent modify the CI checks that validate its own work.
Recording no evidence—or recording every sensitive prompt indefinitely without a retention policy.
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
What is the AI code supply chain?
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.
Can AI-generated code be trusted after it passes automated tests?
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.
What is a poisoned coding-agent model?
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.
What is least agency?
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.
Should companies log every AI prompt and response?
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.
Does this replace DevSecOps?
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.