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 of the eight code samples that two Claude models wrote without a single mention of security (all in a personal-data upload task) had real vulnerabilities — an exposed debugger with remote code execution, an unauthenticated download and an endpoint returning every stored name and email. One sentence in the prompt about the SOC 2 standard got code without these holes — no follow-up requests or fixes needed (other standards like GDPR or HIPAA were not tested). 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 of the eight neutral runs of the first two models (all in the personal-data upload task), the code contained real holes: an exposed debugger with remote code execution capability, an unauthenticated download, and an endpoint that returned every stored name and email. A fourth defect turned up in a later Opus 5 run. 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 — the sentence named no individual measure. This bumped compliance in every task to 86–100% and eliminated every vulnerability found. Some controls were still missed (MFA hooks, cookie flags, account lifecycle). Only SOC 2 was tested; other standards (GDPR, CCPA, PCI DSS) may work similarly, but that is our guess. The authors' reading: the added protections were within 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 most of the technical measures on its own (encryption,
access control, logging, retention) — but not MFA hooks, cookie flags
or account lifecycle

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

03

Example in Action

Our illustration. The paper's sentence named only SOC 2 and the data's sensitivity; the prompt below names GDPR/CCPA and lists specific measures, which the paper did not test.

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.

Expected result (our illustration): The model writes code that encrypts fields on write to the DB, avoids hardcoding database passwords (using environment variables instead), logs access to the data, and includes a sample policy for purging stale records. Without that second paragraph, it would likely skip some of these protections — in the paper's personal-data upload task, neutral code met only 50–75% of the checklist, and three of the eight neutral runs of the first two models had real holes.

04

Why This Works

The authors' reading: 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 evidently knows many measures that correspond to SOC 2 — once the standard was named, it added them without being told which ones. 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 (our suggestions; the paper tested only one SOC 2 sentence): - Swap "SOC 2" for GDPR, PCI DSS, CCPA, HIPAA — the model will likely apply the set of measures it associates with the named standard. - Specify the data type ("personal data," "payment information," "health data") — may strengthen the effect. - For narrow, specific measures (MFA, cookie flags, account lifecycle policies), the generic phrase didn't cut it in the paper — name those separately and explicitly.

05

Prompt Template

Our template, not the paper's wording — it adds named measures and other standards that were not tested.

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 didn't activate these. Naming them separately is our suggestion.

⚠️ 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 mattered least — within three Claude models. Claude Fable 5 and Opus 4.8 finished within one checklist item of each other in every comparison; the newer Opus 5 improved the two weakest cases by less than the sentence did. No other vendors were tested, and each cell was a single generation with one wording of the sentence.

⚠️ Eyeballing the code or running a pattern-based automated scanner isn't reliable. In the study the pattern-matching scorer disagreed with meaning-based grading on 27 of 216 judgments and passed a real defect — 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 model ran each task twice — once with a neutral prompt (zero mention of security) and once with the same prompt plus one sentence about SOC 2 — one generation each, 24 outputs in all. Results were checked against a pre-written checklist of 12–15 items, each the authors' mapping of a SOC 2 criterion to a technical measure, 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 the 16 generations of the first two models — 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 (the authors note the expansion was made after reading the code). This supports a practical takeaway: automated pattern-matching scanners can get it wrong in both directions — all ten flags of the first checklist were false alarms, while real holes went unflagged — so 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 of the eight code samples that two Claude models wrote without a single mention of security (all in a personal-data upload task) had real vulnerabilities — an exposed debugger with remote code execution, an unauthenticated download and an endpoint returning every stored name and email. One sentence in the prompt about the SOC 2 standard got code without these holes — no follow-up requests or fixes needed (other standards like GDPR or HIPAA were not tested). 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

Rather than a vague "secure code" (not tested in the paper), name the standard explicitly: the paper used SOC 2; GDPR, HIPAA or PCI DSS may work similarly (our extrapolation). 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

The authors' reading: 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 became 86-100% with it (three Claude models, one generation per cell).

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 (the one tested), or GDPR, HIPAA, PCI DSS — whichever applies to your case (untested). 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

Our illustration (the paper's sentence named only SOC 2 and data sensitivity, no specific measures): [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 four typical tasks and found: Claude Fable 5, Opus 4.8 and Opus 5 skip a lot of security if you don't push them — they met only 47–88% of the checklist unprompted. The models happily hash passwords because that's "basic," but skipped MFA hooks, S3 hardening and data retention policies. If a protection requires a deliberate extra step, the model tends to leave it out. One sentence naming SOC 2 lifted every task to 86–100%. Brevity might be the soul of wit for the model, but for your business it's a security hole.

The test ran only on Claude models; our guess is that other models like GPT or Gemini behave similarly, and that the same goes beyond code — legal contracts, medical advice, financial plans — but that wasn't tested. The models tended to deliver a "minimum viable product." If you didn't spell out security requirements in the prompt, don't assume they're there. Secure-by-default is not something to count on.

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. Name the standard in the prompt (and spell out narrow requirements like MFA), 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.