# What are the security risks of AI-coded software?

> A risk matrix for CTOs, tech leads and security owners: leaked keys, missing validation, ungoverned AI calls and GDPR/DPA in code written with AI.

Human view: https://hasty.se/en/insikter/sakerhetsrisker-ai-kodad-mjukvara
Agent view: https://hasty.se/en/insikter/sakerhetsrisker-ai-kodad-mjukvara.md

Languages: sv=https://hasty.se/insikter/sakerhetsrisker-ai-kodad-mjukvara | en=https://hasty.se/en/insikter/sakerhetsrisker-ai-kodad-mjukvara | no=https://hasty.se/no/insikter/sakerhetsrisker-ai-kodad-mjukvara | da=https://hasty.se/da/insikter/sakerhetsrisker-ai-kodad-mjukvara | fi=https://hasty.se/fi/insikter/sakerhetsrisker-ai-kodad-mjukvara

Publicerad: 2026-10-07T09:00:00

<p>The biggest security risks in AI-coded software are leaked API keys, missing input validation, databases without access rules, ungoverned AI calls that may pass on sensitive data, and missing data processing agreements (DPA) under GDPR. The risks are reduced with human code review, clear rules for AI use and automated security checks.</p>
<p>AI assistants write code that works, but they optimise for working – not for being secure. That is why the same flaws keep appearing.</p>
<p>The matrix below shows the most common risks, how likely they are in AI-generated code and what reduces them.</p>
<h2>Risk matrix for AI-coded software</h2>
<table><thead><tr><th>Risk</th><th>Likelihood</th><th>Impact</th><th>Mitigation</th></tr></thead><tbody><tr><td>Leaked keys and secrets</td><td>High</td><td>High – unauthorised access and costs</td><td>Server-side secrets, key rotation, scanning in every build</td></tr><tr><td>Missing input validation</td><td>High</td><td>High – injection and data corruption</td><td>Server-side schema validation for all input</td></tr><tr><td>Database without access rules</td><td>Medium–high</td><td>High – data leaks</td><td>Row-level security and roles in a separate table</td></tr><tr><td>Ungoverned AI calls</td><td>Medium</td><td>High – sensitive data sent to external models</td><td>Guardrails, logging without personal data, approved models</td></tr><tr><td>GDPR and DPA</td><td>Medium</td><td>High – fines and loss of trust</td><td>Data processing agreements, data minimisation, records of processing</td></tr></tbody></table>
<h2>Why do the risks appear?</h2>
<p>AI models lack context about your threat model and requirements. They reuse patterns from examples where security was often left out for simplicity.</p>
<h2>How to govern AI use</h2>
<p>Decide which models and tools are approved, which data must never leave the organisation and who reviews code before it reaches production. The EU AI Act also requires documentation for certain use cases.</p>
<h3>Is AI-generated code less secure?</h3>
<p>It is not insecure by nature, but it often contains recurring flaws like leaked keys and missing validation. Human review and automated checks catch them.</p>
<h3>How do you find leaked API keys?</h3>
<p>Scan the code and history for secrets, check what is sent to the browser and rotate any exposed keys.</p>
<h3>Is a DPA needed when using AI services?</h3>
<p>Yes, if personal data is processed by an external AI provider, a data processing agreement is normally required under GDPR.</p>
<h3>What are AI guardrails?</h3>
<p>Rules and technical controls that govern what an AI feature may do, what data it may see and how its output is checked.</p>

---

## Kontakt

- Allmänna frågor: hej@hasty.se
- Offert och nya uppdrag: christian@hasty.se
- Telefon: 08-480 04 706 (+46 8 480 04 706)
- Besöksadress: Bjurholmsplan 24, 116 63 Stockholm, Sverige
- Kontaktsida: https://hasty.se/en/kontakta-oss
- Förfrågan och personlig service: https://hasty.se/en/kontakta-oss
- Juridisk avtalspart: Norrhavet Group AB, org.nr 559258-3792, Stockholm, Sverige.
- Priser och kalkylator: https://hasty.se/en/priser

## Site maps for agents
- https://hasty.se/llms.txt
- https://hasty.se/llms-full.txt
- https://hasty.se/agents.md
- https://hasty.se/sitemap.xml

Hasty is a brand owned by Norrhavet Group AB (org.nr 559258-3792), Sweden.
