Because a model can fail in one domain while appearing strong in another. Privacy testing asks whether the model reveals sensitive data, while code testing asks whether it can be induced to produce harmful or exploitable instructions. Those are different control problems, so they need different test cases, review criteria, and sign-off owners.
Why This Matters for Security Teams
ai governance programmes fail when they treat privacy exposure and code-generation abuse as the same risk. A model that refuses to reveal personal data can still produce insecure scripts, while a model that writes clean code can still leak secrets from prompts or training data. That split matters because the test method, evidence, and approval owner are different. NIST’s NIST AI Risk Management Framework frames this as separate risk identification and measurement work, not one blended checklist.
Security teams often get this wrong by relying on a single red-team exercise or a generic policy review. That can create false confidence, especially when the organisation uses the same evaluation set for data leakage, prompt injection, and insecure code suggestions. Privacy risk is about disclosure and data handling. Code risk is about harmful instructions, dependency misuse, unsafe logic, and downstream abuse. The controls overlap, but the failure modes do not.
In practice, many security teams encounter the split only after a model has already exposed sensitive content or generated exploitable code in production, rather than through intentional pre-release validation.
How It Works in Practice
Separate testing starts by defining different assurance questions for each domain. Privacy testing asks whether the model can reveal personal data, memorised secrets, or regulated content under normal prompts, adversarial prompts, or retrieval abuse. Code testing asks whether it can produce insecure, weaponisable, or policy-violating code, including vulnerable patterns such as hard-coded credentials, weak cryptography, unsafe deserialisation, or injection-prone logic.
Good programmes usually split the test plan into distinct evidence streams:
- Privacy controls: prompt leakage tests, training data extraction tests, RAG source filtering, output suppression, and retention review.
- Code controls: secure coding prompts, exploitability checks, dependency and package guidance review, and human sign-off for code intended for deployment.
- Shared controls: logging, access restriction, incident response, and content filtering for both prompt and output paths.
This is where the broader control stack matters. NIST’s NIST AI 600-1 Generative AI Profile and NIST SP 800-53 Rev 5 Security and Privacy Controls support this split by tying test evidence to specific control families rather than treating AI as one generic system. For organisations with formal governance obligations, the EU AI Act also reinforces documentation, oversight, and risk-based validation expectations.
The operational point is simple: privacy testers should not be asked to certify code safety, and code reviewers should not be asked to validate data leakage. The two functions need separate criteria, separate samples, and separate approval paths. These controls tend to break down in fast-moving development environments where teams reuse one benchmark suite for both tasks because it is faster and easier to automate.
Common Variations and Edge Cases
Tighter testing often increases release time and review overhead, so organisations must balance assurance against delivery pressure. That tradeoff becomes sharper when a model serves both customer-facing and developer-assistance use cases, because one interface can create both disclosure and code-generation risk.
Best practice is evolving for agentic and tool-using systems. If an AI assistant can write code, call APIs, or access repositories, then privacy tests alone are not enough, and code tests alone are not enough either. The right approach is layered: test the model, test the tool permissions, and test the workflow that turns model output into action. NIST’s NIST Cyber AI Profile (IR 8596) is useful here because it pushes teams to think about operational risk, not just model behaviour in isolation.
There is also no universal standard for how to score combined privacy and code risk yet. Some organisations use separate severity scales, while others use one enterprise risk register with linked subcategories. The important part is not the label, but that the evidence stays distinct and the sign-off owner matches the risk domain. Privacy officers, security engineering, legal, and product teams should each review only the part they are qualified to judge. For governance-heavy environments, ISO/IEC 42001 helps anchor management-system discipline, while GDPR shapes privacy accountability where personal data may be exposed.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
NIST AI RMF, NIST AI 600-1, NIST CSF 2.0 and NIST IR 8596 set the technical controls, while EU AI Act define the regulatory obligations.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST AI RMF | Splits AI risks into distinct measurement and governance activities. | |
| NIST AI 600-1 | GenAI profile supports operational testing for prompt and output risks. | |
| NIST CSF 2.0 | GV.RM-01 | Governance requires risk decisions to match the specific threat being assessed. |
| NIST IR 8596 | Cyber AI profile addresses operational risks from AI in security contexts. | |
| EU AI Act | Risk-based AI governance expects documentation and oversight by harm type. |
Use separate risk registers and test plans for privacy exposure and code-generation abuse.
Related resources from NHI Mgmt Group
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on August 18, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org