- AI Governance — operating model, inventory & riskPublished
- The EU AI Act — tiers, obligations & timelinePublished
- ISO/IEC 42001 — build & certify the AIMSPublished
- Shadow AI — discover, assess & governPublished
- 5Security in AI-assisted codingYou're reading this
- Securing the AI you build — LLM app securityComing Dec 2026
Cybersecurity in the Era of AI · Part 5 — Security in AI-Assisted Coding: Capturing the Speed Without the Risk
AI has changed how software is written: how to adopt Copilot, Cursor and their kin safely — enterprise controls, defence against insecure suggestions, secret leakage and hallucinated dependencies, and pipeline guardrails that keep the productivity.
This is Part 5 of Cybersecurity in the Era of AI, and it addresses the AI use that has spread fastest through technology organizations: developers writing code with AI assistants. GitHub Copilot, Cursor, and the wave of LLM-powered coding tools have delivered real, measurable productivity gains, and their adoption is close to universal among developers whether or not it is sanctioned — which makes this both a specific instance of the shadow-AI problem from Part 4 and a distinct secure-development challenge in its own right. The productivity is worth having; the risks are real and specific; and the two are not in opposition if you adopt these tools deliberately. This part is about doing exactly that — keeping the speed while closing the risks that AI-assisted coding introduces: insecure code suggestions accepted uncritically, secrets and proprietary code leaking to models, hallucinated dependencies that become a supply-chain attack, and the subtler risk of developers over-trusting output they did not write and do not fully understand.
The framing that matters: an AI coding assistant is a very fast, very confident junior developer who has read enormous amounts of code — including a great deal of insecure code — and who will produce plausible output for anything you ask, whether or not it is correct or safe. You would not merge a junior's code without review, standards and tests; the same discipline, adapted, is what makes AI-assisted coding safe. And much of that discipline you already have — the [Security by Design] program's pipeline guardrails and threat-model-driven controls apply directly to AI-generated code, because to the pipeline, insecure code is insecure code regardless of who or what wrote it.
Scope of this phase
Every part of this program is scope-bounded so you know exactly when you are done.
- In scope: the specific risks of AI-assisted coding (insecure suggestions, secret/code leakage to models, hallucinated/malicious dependencies, over-trust and licensing/IP exposure); the enterprise controls that make assistant adoption safe; the pipeline guardrails that catch what the assistant gets wrong; and the practices and policy that keep developers in control.
- Explicitly out of scope (later part): securing the AI applications and systems you build and deploy — LLM app security, prompt injection, the OWASP LLM Top 10 (Part 6). This part is about AI that helps you write software; Part 6 is about securing the AI in your software.
- Definition of done: the exit checklist at the end of this part. When every box is ticked, AI-assisted coding is sanctioned, configured safely, and backstopped by pipeline controls — productive and governed.
AI-assisted coding: risks & defences
Insecure suggestions
Same pipeline checks & definition of done as any code.
Secret / code leakage
Enterprise tier, no-training terms, context exclusions.
Hallucinated dependencies
Verify packages; SCA + allowlist + lockfiles.
Over-trust
Review, comprehension responsibility & clear policy.
Treat the assistant as a fast, confident junior — review everything.
The four risks below are best addressed as layers: a safe tool configuration, developer practices, pipeline backstops, and clear policy — no single one is sufficient, but together they let you say yes to AI-assisted coding with confidence. Build them together.
Risk 1 — Insecure code suggestions
AI assistants are trained on vast corpora of public code, much of which is insecure, outdated, or subtly wrong — so they will, confidently, suggest SQL built by string concatenation, weak cryptography, missing authorization checks, and vulnerable patterns that look idiomatic because they are common. Studies and experience consistently find a meaningful fraction of AI-generated code contains security weaknesses. The assistant is not malicious; it is producing statistically likely code, and likely is not the same as secure.
The defence is not to distrust every suggestion but to treat AI-generated code exactly as you treat human-written code — no more trusted, and run through the same gauntlet. This is where the pipeline from the Security by Design program does the heavy lifting: SAST, dependency scanning and the threat-model-driven tests catch insecure patterns whether a human or an assistant wrote them. The critical mindset shift is that the developer remains the author and the accountable party: accepting a suggestion is a decision, not a delegation, and the developer owns the security of what they commit. Tooling helps — some assistants offer suggestion-time vulnerability filtering — but the durable control is that AI-generated code meets the same definition of done, including its security criteria, as everything else.
Risk 2 — Secret and code leakage to models
The second risk runs the other way: what your developers send to the assistant. Depending on the tool and its configuration, the code in the developer's context — which can include proprietary source, secrets, credentials, and confidential business logic — may be transmitted to the provider, potentially retained, and in some consumer configurations used to train future models. For proprietary code and anything secret, that is an unacceptable exposure, and it is the leakage risk of Part 4 in its most concentrated form.
The defence is enterprise-tier tooling configured correctly. The reputable coding assistants offer business and enterprise plans with contractual guarantees that your code is not retained or used for training, along with administrative controls; the essential first move is to sanction a specific tool on its enterprise tier and forbid the consumer tiers for work code (a Part 4 sanctioned-alternative decision). Layer on the hygiene that limits blast radius regardless: keep secrets out of the codebase entirely (they belong in a secrets manager, per Security by Design), so there are no secrets in context to leak; use the tool's exclusion controls to keep sensitive files and paths out of the assistant's context; and confirm the data-handling terms are contractually what you need. Configured this way, the assistant sees code it is contractually bound to protect, and no secrets, so the leakage risk collapses.
Risk 3 — Hallucinated and malicious dependencies
A distinctive and dangerous failure mode: AI assistants sometimes suggest dependencies that do not exist — plausible-sounding package names the model invented. This becomes a supply-chain attack (nicknamed slopsquatting) when an attacker predicts or observes these hallucinated names and registers malicious packages under them, so that a developer who accepts the suggestion and installs the package pulls in attacker code. It is a genuinely new attack surface created by AI-assisted coding, and it exploits exactly the over-trust the whole part warns against.
| Risk | Vector | Defence |
|---|---|---|
| Hallucinated package | Assistant invents a non-existent dependency | Verify every new dependency exists and is the intended one before install |
| Slopsquatting | Attacker registers a hallucinated name | Dependency allowlists / private registry; SCA on every change |
| Typosquatting (amplified) | Assistant suggests a near-miss name | Pin and review dependencies; provenance checks |
| Malicious transitive dep | Pulled in behind a suggested package | Lockfiles + SCA + policy gates in the pipeline |
The defences are the software-supply-chain controls a mature pipeline already runs, now applied with extra vigilance to AI-suggested dependencies: verify a package actually exists and is the one you meant before adding it, run software composition analysis on every change, prefer an internal/proxied registry with an allowlist over pulling arbitrary packages from the public index, and enforce lockfiles so what you reviewed is what you get. The rule of thumb for developers is simple: never install a dependency an assistant suggested without confirming it is real and intended — the two seconds of checking closes an entire attack class.
Risk 4 — Over-trust and the practices that counter it
The subtlest risk is human: AI assistants are fluent and confident, which invites developers — especially under deadline pressure or when working outside their expertise — to accept output they do not fully understand. Code you did not write and cannot explain is code you cannot secure or maintain, and at scale this erodes the collective understanding a codebase depends on. The countermeasures are practices and policy rather than tools. Review discipline: AI-generated code goes through the same code review as any other, and "the AI wrote it" is never a justification a reviewer accepts. Comprehension responsibility: the committing developer must understand and be able to explain the code they submit, whatever its origin. A clear policy (from Part 1's acceptable-use foundation) that states which assistant is sanctioned and on what tier, what may be in context, that AI-generated code carries the same standards and accountability as any other, and the dependency-verification rule. And awareness: developers who understand these specific failure modes make better moment-to-moment decisions than any tool can enforce. A concise policy makes the boundaries explicit:
## AI coding assistants — the rules
- Approved tool: <sanctioned assistant>, ENTERPRISE tier only (no-training terms). Consumer tiers are not for work code.
- You are the author. AI-generated code meets the same definition of done — security checks included — as any code.
- Never install a suggested dependency without verifying it exists and is the one you intended.
- No secrets in the codebase, so none in assistant context; keep sensitive paths excluded.
- You must understand and be able to explain any code you commit, whatever wrote it.Definition of done — Security in AI-assisted coding exit checklist
You are ready for Part 6 when every one of these is true:
- Sanctioned tooling: a specific AI coding assistant is approved on an enterprise tier with contractual no-training/no-retention terms; consumer tiers are disallowed for work code (a Part 4 sanctioned alternative).
- Insecure-suggestion backstop: AI-generated code passes the same pipeline security controls (SAST, tests, the security definition of done) as all code; the committing developer is the accountable author.
- Leakage controlled: secrets are out of the codebase entirely; sensitive files/paths are excluded from assistant context; data-handling terms are verified.
- Dependency defence: SCA runs on every change; dependencies come via an allowlist/private registry with lockfiles; developers verify any AI-suggested package is real and intended before install.
- Over-trust countered: AI-generated code goes through normal review, developers must be able to explain what they commit, and a clear AI-coding policy states the rules.
- Awareness: developers understand the specific failure modes (insecure suggestions, leakage, hallucinated dependencies, over-trust).
Tick every box and your developers keep the productivity of AI-assisted coding while the risks are contained by tool configuration, pipeline backstops and clear accountability. Skip the dependency-verification rule or the enterprise-tier decision and you leave open, respectively, a live supply-chain attack class and a continuous leak of proprietary code.
What's next
Part 6 — Securing the AI you build is the finale and the deepest technical part, turning from AI that helps you write software to the AI systems and features in your software. Building an LLM-powered product opens an attack surface unlike any traditional application — prompt injection, insecure output handling, excessive agency, data poisoning and the rest of the OWASP LLM Top 10 — and it demands its own defence-in-depth, red-teaming and runtime monitoring. Part 6 shows how to secure the AI you ship, completing the program from governance through compliance to the hardest engineering. It ships next month.
If you would like experienced hands to roll out AI-assisted coding safely — select and configure the enterprise tooling, wire the pipeline backstops, and set the policy and awareness that keep developers in control — that is exactly what Axelia's consultants do, and ISMShed records the controls as framework-mapped evidence across ISO/IEC 42001, ISO 27001, the EU AI Act, NIS2, DORA and GDPR. Capture the speed safely now, and Part 6 secures the AI you build with it.
