Researchers found that adding security rules to AI coding prompts helps models avoid common vulnerabilities like insecure direct object references.
Key points
- Datadog Security Labs tested Sonnet 5, Composer 2.5, and GPT 5.5 with and without security rules.
- Default mode runs produced code with insecure direct object reference vulnerabilities across all three models.
- The study used Project CodeGuard to provide pre-set security guidelines for the AI agents.
Datadog Security Labs published findings showing how AI coding agents handle security rules. The research compared code output from three models when prompted with standard instructions versus those with explicit security guidelines.
What happened
Researchers at Datadog Security Labs evaluated whether pre-set security rules improve the security of code generated by AI agents. The team tested Sonnet 5, Composer 2.5, and GPT 5.5 using identical prompts in each scenario. The study relied on Project CodeGuard, an open source framework that provides security rules for coding agents. For Claude Code, the team installed Project CodeGuard version 1.4.0 locally. For Cursor and Codex, they followed the framework's installation guide using zip files and associated commands. The researchers used the same prompt in every iteration to ensure consistency. This prompt previously resulted in an insecure direct object reference vulnerability because it did not specify document access controls.
The team ran each model once to allow for deeper analysis of the specific output. They acknowledged that AI responses are nondeterministic and may vary between runs. Supply Chain Firewall was used to prevent malicious package installations during the testing process. Datadog Code Security identified static application security testing and software composition analysis vulnerabilities. The team also used Claude’s code review skill with Sonnet 5 to audit the generated code. In default mode without security rules, all three models produced code with the same architectural blind spot. Any authenticated session could access or annotate files belonging to other users. This confirmed the presence of an insecure direct object reference vulnerability in the baseline results.
Why it matters
AI coding agents often lack context about application security requirements. Without explicit instructions, they may generate code that appears functional but contains serious flaws. Security rules provide necessary constraints that guide the model toward safer implementation choices. This reduces the risk of introducing vulnerabilities during the development process. Teams should treat AI output as untrusted code requiring rigorous review.
The fix
- Integrate open source security frameworks like Project CodeGuard into your development workflow.
- Install security rule plugins locally for your specific AI coding agent.
- Use static
Background: Supply chain attacks
Verify code signatures and hash values before installing any update. Monitor for unexpected outbound traffic or permission requests. If anomalies appear, isolate the system immediately and revert to a known good state. Treat third-party updates as untrusted until proven otherwise.
Read the full guide: Supply Chain Attack Warning Signs and Response Steps
What to do and how to stay safe
- Formal guidelines dictate credential creation and rotation rules across enterprise networks.
- Rigid complexity requirements frequently drive users toward predictable habits and unsafe workarounds.
- Modern frameworks prioritize length and breach checks over arbitrary expiration timelines.
Effective password rules prioritize length and breach prevention over frequent, arbitrary modifications. Replace monthly expiration mandates with long passphrases and automated checks against known compromised databases.
Step-by-step guide: What is password policies and how they protect systems
General security guidance from the Crypt Weekly newsroom. It is not confirmed advice from the organisations named in this story.



