C:C06
Chapter 6: Securing Generated Code and Agent Runtimes
A guide to the published second edition, with literal citations separated from wider editorial reading suggestions.
Chapter guide
Threat-models two distinct surfaces: the generated application and the agent runtime. Dependency provenance, prompt injection, tool permissions and external services become enforceable boundaries, with security evidence tied to the release decision.
Sintesi in italiano
Analizza due superfici di attacco distinte: l'applicazione generata e il runtime dell'agent. Provenienza delle dipendenze, prompt injection, permessi degli strumenti e servizi esterni diventano vincoli applicabili, collegando le evidenze di sicurezza alla decisione di rilascio.
Learning goals
- threat-model the generated product and the agent runtime separately
- enforce tool permissions independently of instructions embedded in files
- specify the evidence required before accepting a security-sensitive patch
Obiettivi in italiano
Obiettivi di apprendimento
- costruire threat model distinti per il prodotto generato e per il runtime dell'agent
- far rispettare i permessi dei tool indipendentemente dalle istruzioni incorporate nei file
- specificare le evidenze necessarie prima di accettare una patch sensibile dal punto di vista della sicurezza
Chapter outline
- 6.1 Two attack surfaces, two threat models
- 6.2 Functional correctness is not security
- 6.3 What vulnerability studies actually measure
- 6.4 Security-directed generation and remediation
- 6.5 Dependency provenance and hallucinated packages
- 6.6 Prompt injection through repository and tools
- 6.7 Harness configuration, skills and external services
- 6.8 A secure agent execution profile
- 6.9 Threats turned into enforceable boundaries
- 6.10 Security evidence and release decision
- 6.11 Worked engineering example: two threats, two defenses
- 6.12 Practice exercise: threat-model both the product and the agent
Struttura del capitolo
- 6.1 Due superfici di attacco, due threat model
- 6.2 La correttezza funzionale non basta per la sicurezza
- 6.3 Che cosa misurano davvero gli studi sulle vulnerabilità
- 6.4 Generazione e remediation guidate dalla sicurezza
- 6.5 Provenienza delle dipendenze e package inventati
- 6.6 Prompt injection attraverso repository e tool
- 6.7 Configurazione dell'harness, skill e servizi esterni
- 6.8 Un profilo di esecuzione sicura per gli agent
- 6.9 Dalle minacce ai confini applicabili
- 6.10 Evidenze di sicurezza e decisione di release
- 6.11 Esempio ingegneristico svolto: due minacce, due difese
- 6.12 Esercizio pratico: costruire due threat model, per prodotto e agent
Cited in the published chapter
10 linked atlas references from literal citations in the English and Italian editions. General bibliography membership and identifier-index entries are counted separately.
SE@PoliMi bibliography 9
- W030 — Workspace Topology as an Attack Vector in Agentic Coding Assistants
Day · 2026 - W038 — Guiding AI to Fix Its Own Flaws: An Empirical Study on LLM-Driven Secure Code Generation
Yan · 2026 - W041 — Security Vulnerabilities in AI-Generated Code: A Large-Scale Analysis of Public GitHub Repositories
Schreiber · 2025 - W043 — We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs
Spracklen · 2025 - W045 — Is Vibe Coding Safe? Benchmarking Vulnerability of Agent-Generated Code in Real-World Tasks
Zhao · 2025 - W046 — Do Users Write More Insecure Code with AI Assistants?
Perry · 2023 - W053 — Scanning the Harness: Configuration Exposures in AI Coding-Agent Supply Chains
Kapner · 2026 - W060 — Your AI, My Shell: Demystifying Prompt Injection Attacks on Agentic AI Coding Editors
Liu · 2025 - W104 — Coding with Enemy: Can Human Developers Detect AI Agent Sabotage?
Ye · 2026
Martin Fowler’s website 1
- F016 — Coding Assistants Threaten the Software Supply Chain
Jim Gumbley; Lilly Ryan · 2025-05-13
Trace literal citations to chapter sections
Locations come from the supplied English and Italian source files. Chapter text and figure captions are identified separately; identifier-index references and general bibliography membership are not treated as chapter citations.
- F016 · Coding Assistants Threaten the Software Supply Chain
- EN · Two attack surfaces, two threat models
EN/chapters/chapter06.tex:13 - ITA · Due superfici di attacco, due threat model
ITA/chapters/chapter06.tex:13
- EN · Two attack surfaces, two threat models
- W030 · Workspace Topology as an Attack Vector in Agentic Coding Assistants
- EN · Prompt injection through repository and tools
EN/chapters/chapter06.tex:100 - ITA · Prompt injection attraverso repository e tool
ITA/chapters/chapter06.tex:100
- EN · Prompt injection through repository and tools
- W038 · Guiding AI to Fix Its Own Flaws: An Empirical Study on LLM-Driven Secure Code Generation
- EN · Security-directed generation and remediation
EN/chapters/chapter06.tex:68 - ITA · Generazione e remediation guidate dalla sicurezza
ITA/chapters/chapter06.tex:68
- EN · Security-directed generation and remediation
- W041 · Security Vulnerabilities in AI-Generated Code: A Large-Scale Analysis of Public GitHub Repositories
- EN · What vulnerability studies actually measure
EN/chapters/chapter06.tex:50 - EN · What vulnerability studies actually measure
EN/chapters/chapter06.tex:52 - EN · What vulnerability studies actually measure
EN/chapters/chapter06.tex:56 - ITA · Che cosa misurano davvero gli studi sulle vulnerabilità
ITA/chapters/chapter06.tex:50 - ITA · Che cosa misurano davvero gli studi sulle vulnerabilità
ITA/chapters/chapter06.tex:52 - ITA · Che cosa misurano davvero gli studi sulle vulnerabilità
ITA/chapters/chapter06.tex:56
- EN · What vulnerability studies actually measure
- W043 · We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs
- EN · Dependency provenance and hallucinated packages
EN/chapters/chapter06.tex:84 - ITA · Provenienza delle dipendenze e package inventati
ITA/chapters/chapter06.tex:84
- EN · Dependency provenance and hallucinated packages
- W045 · Is Vibe Coding Safe? Benchmarking Vulnerability of Agent-Generated Code in Real-World Tasks
- EN · Functional correctness is not security
EN/chapters/chapter06.tex:44 - EN · What vulnerability studies actually measure
EN/chapters/chapter06.tex:50 - EN · What vulnerability studies actually measure
EN/chapters/chapter06.tex:52 - ITA · La correttezza funzionale non basta per la sicurezza
ITA/chapters/chapter06.tex:44 - ITA · Che cosa misurano davvero gli studi sulle vulnerabilità
ITA/chapters/chapter06.tex:50 - ITA · Che cosa misurano davvero gli studi sulle vulnerabilità
ITA/chapters/chapter06.tex:52
- EN · Functional correctness is not security
- W046 · Do Users Write More Insecure Code with AI Assistants?
- EN · What vulnerability studies actually measure
EN/chapters/chapter06.tex:56 - ITA · Che cosa misurano davvero gli studi sulle vulnerabilità
ITA/chapters/chapter06.tex:56
- EN · What vulnerability studies actually measure
- W053 · Scanning the Harness: Configuration Exposures in AI Coding-Agent Supply Chains
- EN · Two attack surfaces, two threat models
EN/chapters/chapter06.tex:20 - EN · Harness configuration, skills and external services
EN/chapters/chapter06.tex:111 - ITA · Due superfici di attacco, due threat model
ITA/chapters/chapter06.tex:20 - ITA · Configurazione dell'harness, skill e servizi esterni
ITA/chapters/chapter06.tex:111
- EN · Two attack surfaces, two threat models
- W060 · Your AI, My Shell: Demystifying Prompt Injection Attacks on Agentic AI Coding Editors
- EN · Two attack surfaces, two threat models
EN/chapters/chapter06.tex:22 - EN · Prompt injection through repository and tools
EN/chapters/chapter06.tex:100 - ITA · Due superfici di attacco, due threat model
ITA/chapters/chapter06.tex:22 - ITA · Prompt injection attraverso repository e tool
ITA/chapters/chapter06.tex:100
- EN · Two attack surfaces, two threat models
- W104 · Coding with Enemy: Can Human Developers Detect AI Agent Sabotage?
- EN · Prompt injection through repository and tools
EN/chapters/chapter06.tex:100 - ITA · Prompt injection attraverso repository e tool
ITA/chapters/chapter06.tex:100
- EN · Prompt injection through repository and tools
Editorial reading mappings
Broader topical suggestions can overlap the cited sources. A mapping does not add a citation to the published edition or establish that a practice is effective.
SE@PoliMi bibliography 41
- W029 — Beyond Bug Fixes: An Empirical Investigation of Post-Merge Code Quality Issues in Agent-Generated Pull Requests
Cynthia · 2026 - W030 — Workspace Topology as an Attack Vector in Agentic Coding Assistants
Day · 2026 - W031 — More Code, Less Reuse: Investigating Code Quality and Reviewer Sentiment towards AI-generated Pull Requests
Huang · 2026 - W032 — Understanding the Impact of AI Code Assistants on Security API Usage
Mousavi · 2026 - W033 — How AI Coding Agents Modify Code: A Large-Scale Study of GitHub Pull Requests
Ogenrwot · 2026 - W034 — Comparing AI Coding Agents: A Task-Stratified Analysis of Pull Request Acceptance
Pinna · 2026 - W035 — Security in the Age of AI Teammates: An Empirical Study of Agentic Pull Requests on GitHub
Siddiq · 2026 - W036 — On the Use of Agentic Coding: An Empirical Study of Pull Requests on GitHub
Watanabe · 2026 - W037 — After the Party: Growth, Governance, and Security Scanning in the OpenClaw Agent Skill Ecosystem
Xiong · 2026 - W038 — Guiding AI to Fix Its Own Flaws: An Empirical Study on LLM-Driven Secure Code Generation
Yan · 2026 - W039 — Human-Written vs. AI-Generated Code: A Large-Scale Study of Defects, Vulnerabilities, and Complexity
Cotroneo · 2025 - W040 — Security Weaknesses of Copilot-Generated Code in GitHub Projects: An Empirical Study
Fu · 2025 - W041 — Security Vulnerabilities in AI-Generated Code: A Large-Scale Analysis of Public GitHub Repositories
Schreiber · 2025 - W042 — Security Degradation in Iterative AI Code Generation: A Systematic Analysis of the Paradox
Shukla · 2025 - W043 — We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMs
Spracklen · 2025 - W044 — An Empirical Study of Code Clones from Commercial AI Code Generators
Wu · 2025 - W045 — Is Vibe Coding Safe? Benchmarking Vulnerability of Agent-Generated Code in Real-World Tasks
Zhao · 2025 - W046 — Do Users Write More Insecure Code with AI Assistants?
Perry · 2023 - W047 — Lost at C: A User Study on the Security Implications of Large Language Model Code Assistants
Sandoval · 2023 - W048 — Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributions
Pearce · 2022 - W049 — The Range Shrinks, the Threat Remains: Re-evaluating LLM Package Hallucinations on the 2026 Frontier-Model Cohort
Churilov · 2026 - W050 — Understanding the (In)Security of Vibe-Coded Applications
Deng · 2026 - W051 — From Conversation to Contribution: Characterizing Coding Agent in Open-Source Software
Fang · 2026 - W052 — What is the Difference Between Me and You? Benchmarking the Quality Gap Between Human-Written and AI-Generated Code
Improta · 2026 - W053 — Scanning the Harness: Configuration Exposures in AI Coding-Agent Supply Chains
Kapner · 2026 - W054 — Not All Agents Are Equal: Code Quality and Post-Merge Maintenance Across Five Autonomous Coding Agents in the Wild
Kraishan · 2026 - W055 — Debt Behind the AI Boom: A Large-Scale Empirical Study of AI-Generated Code in the Wild
Liu · 2026 - W056 — A Large-Scale Comprehensive Measurement of AI-Generated Code in Real-World Repositories
Mao · 2026 - W057 — How Do AI Coding Agents Contribute to Software Development? An Empirical Study of Agentic Pull Requests
Mazloomzadeh · 2026 - W058 — Decoupling Code Complexity from Newcomer Participation: A Causal Study of AI Coding Agent Adoption in OSS
Xu · 2026 - W059 — AI-Generated Smells: An Analysis of Code and Architecture in LLM- and Agent-Driven Development
Zhu · 2026 - W060 — Your AI, My Shell: Demystifying Prompt Injection Attacks on Agentic AI Coding Editors
Liu · 2025 - W061 — 2025 GenAI Code Security Report
Veracode · 2025 - W062 — Vibe Security Radar
Zhao · 2026 - W067 — (Don't) Trust, but (Don't) Verify: Developers' Attention to Security in AI-Generated Code
Khalid · 2026 - W093 — Automating Low-Risk Code Review at Meta: RADAR, Risk Calibration, and Review Efficiency
Adams · 2026 - W104 — Coding with Enemy: Can Human Developers Detect AI Agent Sabotage?
Ye · 2026 - W132 — New Jobs in 140 Years of Data: Why the AI Displacement Fear Is Overstated — and What to Worry About Instead
Skoglund · 2026 - W146 — McKinsey Technology Trends Outlook 2026
Chui · 2026 - W157 — ClawVM: Harness-Managed Virtual Memory for Stateful Tool-Using LLM Agents
Rafique · 2026 - W173 — Quantifying and Mitigating Turnover-Induced Knowledge Loss: Case Studies of Chrome and a Project at Avaya
Rigby · 2016
Addy Osmani 2
- O014 — The Agent Stack Bet
Addy Osmani · 2026-04-18 - O040 — MCP: What It Is and Why It Matters
Addy Osmani · 2025-03-27
The Pragmatic Engineer 5
- P002 — Did Automattic commit open source theft?
Gergely Orosz · 2024-10-18 - P034 — MCP Protocol: a new AI dev tools building block
Gergely Orosz · 2025-04-08 - P077 — Building MCP servers in the real world
Gergely Orosz; Elin Nilsson · 2025-12-09 - P097 — How will AI change operating systems? Part 1: Ubuntu and Linux
Gergely Orosz · 2026-04-28 - P120 — How will AI change operating systems? Part 2: Windows
Gergely Orosz; Ivan Klaric · 2026-09-22
Martin Fowler’s website 1
- F016 — Coding Assistants Threaten the Software Supply Chain
Jim Gumbley; Lilly Ryan · 2025-05-13
Earlier Non-Deterministic books 14
- B004 — The Fundamental Shift
Enrico Papalini · - B014 — PART II: Quality Assurance
Enrico Papalini · - B023 — Dynamic Context Engineering: Real-Time Information
Enrico Papalini · - B028 — Security, Compliance \& Governance
Enrico Papalini · - B035 — AI Adoption in the European Union
Enrico Papalini · - B061 — Automation and Extensibility: CLI, Modules, and MCP
Enrico Papalini · - B063 — Advanced Patterns: From Frameworks to Practice
Enrico Papalini · - B066 — Installation and Setup
Enrico Papalini · - B093 — Agentic Patterns in Practice
Enrico Papalini · - B096 — Safety, Security, and Risk Management
Enrico Papalini · - B097 — Complete Implementation Guide
Enrico Papalini · - B100 — Ralph Loops with VS Code and GitHub Copilot
Enrico Papalini · - B107 — The Ralph Loop: Persistent Progress Through Fresh Context
Enrico Papalini · - B108 — Building a Full Local AI Loop
Enrico Papalini ·
Software Engineering Practices 10
- PAT:017 — Blast Radius Containment
- PAT:018 — PII and Secret Scrubbing
- PAT:030 — Connectors and Tools: Move Exact Work Outside the Weights
- PAT:034 — Safety and Guardrails: Verification Is Not Authorization
- PAT:037 — Dependency Sweeper: route by risk
- PAT:051 — Security-First Development
- PAT:058 — Acceptable Use Policy
- PAT:077 — Security Pipeline
- PAT:078 — Prompt Injection Scanning
- PAT:079 — Supply-Chain Risk Audit