The more you have me iterate, the more vulnerabilities pile up: security erosion across iterations
In one sentence: repeated edits do not automatically accumulate security. If each round optimizes only functionality and speed, refactoring can remove existing safeguards.
Symptomโ
The first version has authorization, validation, and error handling. Later requests to simplify or make it run remove or weaken them, while functional tests can still pass.
Why this happensโ
The 2025 paper Security Degradation in Iterative AI Code Generation observed degradation under particular models, tasks, and detection methods. It does not establish that every extra edit makes every model less secure. A separate Java security API study found misuse in specific ChatGPT tasks, not current performance across all tools.
Our practical inference is that security requirements can regress whenever they are absent from change review and validation. Security tests catch covered failures; static analysis depends on its rules and configuration. Neither covers every business security issue.
Consequencesโ
Later patches undo safeguards, green functional tests conceal authorization or sensitive-data changes, and iteration count is mistaken for quality evidence.
What to do insteadโ
- Turn authorization, sensitive-data handling, cryptographic API use, and failure policy into checkable invariants.
- When editing those paths, run relevant negative tests and inspect removed or weakened controls rather than just test counts.
- Supplement with static analysis and dependency checks. Review business authorization that their rules do not cover.
- Report remaining risk when further validation is unavailable; additional edits do not substitute for evidence.
Exampleโ
Before: repair a failing request โ delete authorization โ functionality returns โ merge.
After: the repair must also pass the regression check that rejects unauthorized requests; fix the implementation rather than weakening the requirement.
Version notesโ
The sources concern controlled studies and tested models, not defect rates for every current agent. Different models, tasks, iteration strategies, or detectors require fresh evidence. Revisit when research or security validation changes.