Apply to my task
arXiv:2608.07776 ★ 90 Aug 7, 2026

The Compliance Directive: One Sentence About a Security Standard Turns "Working" LLM Code Into Secure Code

Key result

Three out of sixteen code samples that Claude wrote without a single mention of security turned out to be real vulnerabilities — an exposed debugger with remote code execution and endpoints leaking every user's personal data with no permission checks. One phrase in the prompt about the SOC 2 standard (or GDPR, HIPAA) gets you code that closes these holes on its own — no follow-up requests or fixes needed. The model solves the task literally — if you didn't say the data was sensitive, it won't treat encryption and logging as part of the job, even though it perfectly knows how to do them. Just naming the standard — compliance jumps from 47-88% to 86-100%.

01

TL;DR

When you ask Claude to write code without mentioning security at all, the model does exactly what you asked — nothing more. It hashes passwords and adds encryption where that's just part of the "normal" way to write that kind of code, but it skips everything that requires extra, separately-invoked steps: storage access configuration, logging, data retention policy, MFA.

The spread is brutal: in some tasks the model met up to 88% of security requirements on its own; in others, only 47%. Worse — in three out of sixteen cases, the "neutral" code contained real holes: an exposed debugger with remote code execution capability, and endpoints that leaked every user's personal data with zero authorization. And the first review checklist didn't catch these holes at all.

The fix turned out to be almost laughably simple: add one sentence to the prompt saying the data is sensitive and the code must comply with the SOC 2 standard (or the equivalent for your jurisdiction: GDPR, CCPA, PCI DSS). This bumped compliance across the board to 86–100% and eliminated every vulnerability found — even though none of the added protections were technically beyond the model's reach before; it simply didn't consider them part of the task.

Want this for your own case? Apply this study to your task: AI adapts its method to what you are working on and writes the prompt.

02

Method Blueprint

STEP 1 (no method): Prompt about the task with no mention of security
→ model writes working code with a partial set of protections
(only the ones "baked into" the standard way of writing this kind of code)

STEP 2 (the method): Add one sentence to the same prompt:
"this data is sensitive, the artifact must comply with [standard]"
→ model fills in the full set of technical measures on its own (encryption,
access control, logging, retention)

Everything happens in a single prompt — no separate follow-up requests needed.

03

Example in Action

Task: The owner of a small online service asks Claude to write backend code for a lead-capture form that collects customers' email and phone number to store in a database for email marketing.

Prompt:

Write Python (Flask) code for an endpoint that accepts an email
and phone number from a website form and saves them to a PostgreSQL database.

This is customer personal data, so processing must comply
with GDPR/CCPA requirements and include encryption at rest, restricted
access to the database, access logging, and a data retention policy.

Result: The model writes code that encrypts fields on write to the DB, avoids hardcoding database passwords (using environment variables instead), logs every access to the data, and includes a sample policy for purging stale records. Without that second paragraph about GDPR/CCPA, the model would most likely have produced a plain, working INSERT with none of these protections — the code would "work," but it would be riddled with holes.

04

Why This Works

By default, the model solves literally the task it was given. If the task is "save this email to the database," it does exactly that, with the minimal set of actions required. Extra steps — encryption, logs, retention — aren't part of the task definition, so the model doesn't add them, even if it technically knows how.

At the same time, the model absolutely knows which specific measures correspond to standards like SOC 2, GDPR, or CCPA — that's a massive slice of information it absorbed during training. The problem isn't lack of knowledge; it's that without an explicit trigger, the model doesn't treat that knowledge as part of the request.

By naming the standard, you change the actual framing of the task — "write the code" becomes "write code that complies with standard X," and the model pulls out the entire mental checklist of technical measures it associates with that standard.

Levers you can pull: - Swap "SOC 2" for GDPR, PCI DSS, CCPA, HIPAA — the model will apply exactly the set of measures it associates with the named standard. - Specify the data type ("personal data," "payment information," "health data") — this is a second trigger that amplifies the effect. - For narrow, specific measures (MFA, cookie flags, account lifecycle policies), the generic phrase doesn't cut it — you need to name those separately and explicitly.

05

Prompt Template

Write {code/function/service} for {task}.

This data is {data type: personal data / payment information /
health data}, and processing must comply with {standard:
SOC 2 / GDPR / CCPA / PCI DSS} and include encryption at rest,
restricted access, access logging, and a data retention policy.

Fill in {task} with a concrete description of what the code should do, and {standard} with the law or standard actually relevant to your situation (for US-based projects, that's often CCPA, HIPAA, or PCI DSS depending on the data type).

06

Limitations

⚠️ The directive doesn't cover everything: MFA, Secure/HttpOnly cookie flags, account lifecycle rules — the generic standard-mention phrase doesn't activate these. You need to name them separately, by name.

⚠️ 100% on the checklist is not a guarantee of passing a real audit. Compliance was measured against the researchers' own technical interpretation, not an official SOC 2 checklist — the standard dictates goals, not specific technical implementations.

⚠️ Model choice barely matters. The difference between Claude Fable 5, Opus 4.8, and Opus 5 was minimal — the effect comes from how the prompt is worded, not from which specific model you pick.

⚠️ Eyeballing the code or running a pattern-based automated scanner isn't reliable. These scanners produce both false alarms and missed real holes — you need a review based on actual meaning (e.g., having another model or a human read the whole thing).

07

How This Was Studied

A team from Vanta took three top-tier Claude models and asked them to write code for four typical tasks: uploading files to S3, an authentication service, database infrastructure in Terraform, and a file-upload handler for personal data. Each task was run twice — once with a neutral prompt (zero mention of security) and once with the same prompt plus one sentence about SOC 2. Results were checked against a pre-written checklist of 12–15 items, each tied to a specific standard requirement, and every failure was manually verified rather than trusted to automation.

A fun detail: the first version of the "dangerous actions" checklist found zero problems across 16 generations — and that wasn't a flaw in the code, it was a flaw in the checklist. When the researchers expanded the list of vulnerabilities to check for, real defects surfaced: an exposed debugger with remote code execution, an unauthorized endpoint leaking other users' data. This directly confirms the main practical takeaway: automated pattern-matching scanners regularly get it wrong in both directions, and blindly trusting them to review AI-generated code is a bad idea.

08

Resources

Can AI Write Compliant Code, and to What Extent? — Iccha Sethi, Herman Errico (Vanta).

Research digest

Key result

Three out of sixteen code samples that Claude wrote without a single mention of security turned out to be real vulnerabilities — an exposed debugger with remote code execution and endpoints leaking every user's personal data with no permission checks. One phrase in the prompt about the SOC 2 standard (or GDPR, HIPAA) gets you code that closes these holes on its own — no follow-up requests or fixes needed. The model solves the task literally — if you didn't say the data was sensitive, it won't treat encryption and logging as part of the job, even though it perfectly knows how to do them. Just naming the standard — compliance jumps from 47-88% to 86-100%.

Principle

Don't ask for "secure code" — that phrase triggers nothing, because the model has no idea what it's supposed to mean. Name the standard explicitly: SOC 2, GDPR, HIPAA, PCI DSS. The standard's name works like a key that unlocks an entire checklist of measures the model associates with that word — encryption, access control, logging, data retention periods.

Why it works

By default, the model does exactly what was asked with the minimum set of actions — if the task is "save the email to the database," it saves the email to the database, period. It has the knowledge about encryption and logging, but that knowledge isn't treated as part of the request without an explicit trigger. The moment you name the standard, the framing of the task changes on its own — it's no longer "save the email," it's "save the email per SOC 2 rules," and the model pulls up the whole set of technical measures tied to that standard from memory. The phrase doesn't give the model new skills — it simply expands its understanding of the task, and the 47-88% spread without the directive becomes a stable 86-100% with it.

When to apply

Backend code generation → any work involving emails, phone numbers, payments, or medical data, especially when the code is written fast and without a security review. Not needed for internal utilities with no user data or one-off scripts for personal use — there, the directive just adds extra code with no real benefit.

Mini recipe

1. Describe the task: exactly what the code should do — an endpoint, a form, a service. 2. Name the data: "this is personal data / payment information / medical data." 3. Name the standard: SOC 2, GDPR, HIPAA, or PCI DSS — whichever applies to your case. 4. Spell out narrow requirements explicitly: if you need MFA, Secure/HttpOnly flags, or account-deletion logic, a generic mention of the standard won't trigger them — write those out separately. 5. Check for meaning, not patterns: ask another model or a human to read through the entire code — an autoscanner or a quick skim will miss real vulnerabilities.

Examples

[BAD]: `Write Python code for a form that saves a customer's email and phone number to PostgreSQL` [GOOD]: `Write Python code for a form that saves a customer's email and phone number to PostgreSQL. This is personal data, and processing must comply with GDPR, including encryption at rest, restricted database access, access logging, and a data retention policy`

In plain words

The core of the problem is that modern LLMs like Claude are diligent overachievers who take everything literally. When you ask a model to write code, it isn't thinking about your security posture or legal checks like SOC 2. It just cranks out functionality that works "here and now." If password hashing happens to be baked into the language's standard library, sure, it'll add that — but anything requiring a deliberate extra step, like logging, access controls, or data protection, gets left out. The model isn't being lazy; it simply doesn't consider that part of the task unless you spell it out for it.

It's like hiring a contractor to "just put up a wall." He'll put up a wall — straight and tidy. But he won't run wiring through it, add insulation, or check fire safety, because you never asked him to. So the wall stands, but you can't actually live in that house — the first inspection or short circuit will bring the whole thing down. Technically the job is done, but in reality it's a disaster waiting to happen, because the devil is in the details the builder decided were optional.

Researchers tested this on real-world cases and found: Claude 3.5 Sonnet and Opus fumble security if you don't push them. The models happily hash passwords because that's "basic," but completely ignore MFA (multi-factor authentication), forget about event logging, and blow off data retention policies. If a method requires importing an extra library or five additional lines of code to secure storage, the model just cuts them. Brevity might be the soul of wit for the model, but for your business it's a security hole.

Although the test ran on the Claude family, this principle is universal for any model, whether it's GPT-4 or Gemini. And it's not just about code — it applies to any complex instructions: legal contracts, medical advice, or financial plans. The model always takes the path of least resistance, delivering a "minimum viable product." If you didn't spell out security requirements in the prompt, assume they don't exist. Secure-by-default is a myth that shatters against how transformers actually work.

The main takeaway is simple: AI-generated code is a half-baked meal that looks fully cooked. If you copy-paste it straight into production without a rigorous SOC 2 (or other standard) compliance audit, you're putting your own neck on the line. Either spell out every last requirement in the prompt, or brace yourself for your "quick code" turning into a one-way ticket to an auditor's interrogation room. It's not the model's fault you expected a sense of responsibility that the algorithm simply doesn't have.

AI lab assistant

Apply this study to your task

Describe what you're working on. AI takes the method and the measured results from this paper and adapts them to your case, or writes a ready prompt built on them.

Based on The Compliance Directive: One Sentence About a Security Standard Turns "Working" LLM Code Into Secure Code arXiv:2608.07776

Sign in to apply this study New accounts get 50 free credits.