Master Web Application Security Specification
Defense-in-Depth Security Engineering and Vulnerability Prevention Standard. A living standard for humans and for AI coding agents such as Claude Code. It extends the “2026 Web App Security Checklist” with SSRF, OWASP LLM, Agentic AI security, standards alignment, and verification requirements.
1. Security standards and references
Use the following as the primary reference framework. Do not treat the OWASP Top 10 as a complete security verification standard.
- OWASP Application Security Verification Standard (ASVS) 5.0.0 — primary implementation and verification reference.
- OWASP Top 10:2025 — awareness and risk framing.
- OWASP API Security Top 10:2023 — object-level and function-level authorization.
- OWASP Web Security Testing Guide, latest stable release and relevant newer guidance.
- OWASP GenAI Security Top 10:2026, where AI functionality exists.
- OWASP Top 10 for Agentic Applications:2026, where autonomous agents exist.
- NIST SP 800-218 Secure Software Development Framework (SSDF).
- Relevant CWE vulnerability classifications.
Map applicable security controls to ASVS requirements. Document any requirements that cannot be implemented because they fall outside the application’s architecture or functionality.
2. Initial application security assessment
Before modifying code, inspect and document the following:
- Entire application architecture.
- Programming languages, frameworks, libraries, databases, APIs, and external integrations.
- Authentication, authorization, sessions, and account recovery.
- Database models, queries, and access permissions.
- All public and private endpoints.
- Frontend JavaScript and browser security.
- File uploads, downloads, and document processing.
- External HTTP requests and outbound network connections.
- Background jobs, scheduled tasks, and webhooks.
- Deployment configurations, environment variables, and secrets.
- AI models, prompts, vector databases, retrieval systems, and agent tools where applicable.
Do not assume absence
Do not assume a vulnerability is absent simply because you cannot find an obvious example. Produce an initial assessment identifying critical assets, trust boundaries, entry points, attack surfaces, and potential attack paths.
3. Frontend and browser security
- Content Security Policy with appropriate nonces or hashes. Deploy in report-only mode before enforcing a new policy that may break functionality.
- HTTP Strict Transport Security after HTTPS deployment has been verified.
X-Content-Type-Options,Referrer-Policy, andPermissions-Policy.frame-ancestorsand appropriate clickjacking protection.- Secure CORS configuration.
- Subresource Integrity where applicable.
- Trusted Types where supported and appropriate.
- Context-aware output encoding and DOM-based XSS prevention.
- Safe handling of untrusted HTML and protection against DOM clobbering.
- Secure cookie configuration.
- Elimination of unnecessary third-party scripts.
- Prevention of secret exposure in frontend code and protection of sensitive information in browser storage.
- Appropriate cross-origin isolation policies where applicable.
Never rely on the client
Do not rely on client-side validation or hidden interface elements for security. innerText is not equivalent to innerHTML in XSS risk; prefer safe text insertion and sanitize HTML only when rendering untrusted rich content.
4. Authentication and identity security
- Secure password hashing with Argon2id or an appropriately configured equivalent.
- MFA for privileged accounts, with secure enrollment, recovery, and revocation. Consider passkeys/WebAuthn.
- Secure password recovery using single-use, expiring tokens.
- Email verification where required.
- Credential stuffing and brute-force protection; login throttling and abuse detection.
- Account enumeration protection for usernames and email.
- Secure session generation; session fixation prevention; regenerate session identifiers after authentication and privilege changes.
- Session expiration, idle timeout, and absolute timeout; session revocation.
- Logout and device/session management, including logout from all devices and administrator session revocation.
- Secure OAuth/OIDC implementation using state, nonce, and PKCE where applicable.
- Protection against stolen, replayed, and expired authentication tokens.
- Appropriate administrator reauthentication for sensitive operations.
- Detection of suspicious login patterns with step-up authentication.
Avoid permanent lockouts
Do not use permanent account lockouts that allow attackers to deny service to legitimate users. Combine throttling, risk-based challenges, and MFA.
5. Authorization and access control
Treat authorization as a critical security boundary.
- Role-based or attribute-based authorization as appropriate.
- Server-side permission checks on every sensitive operation.
- Object-level, function-level, and property-level authorization.
- Resource ownership verification and multi-tenant isolation.
- Privilege escalation prevention.
- Administrative access separation.
- Protection against IDOR/BOLA and mass assignment.
- Authorization checks for background tasks and asynchronous jobs.
Negative testing is mandatory
Test with multiple users and different permission levels. Verify that changing an identifier in a URL, request body, or API call never grants access to another user’s resources. Do not assume that an authenticated request is automatically authorized.
6. Injection and input handling
Defend against:
- SQL and NoSQL injection.
- Cross-site scripting (stored, reflected, and DOM-based).
- OS command injection.
- Server-side template injection (SSTI).
- LDAP and XPath injection where applicable.
- XML External Entity (XXE) attacks.
- Unsafe deserialization.
- Path traversal and directory traversal.
- HTTP header injection, CRLF injection, and response splitting.
- Open redirects.
- Prototype pollution in JavaScript applications.
- Regular expression denial of service (ReDoS).
Use parameterized database operations, safe APIs, context-aware output encoding, and strict schema validation. Never construct executable commands or database queries by concatenating untrusted input.
7. SSRF and outbound network security
For every server-side URL fetcher, webhook, document importer, image fetcher, URL preview, or external integration:
- Validate URL schemes and prefer strict destination allowlists.
- Reject localhost, private, loopback, link-local, and reserved IP ranges, for both IPv4 and IPv6.
- Check all resolved DNS addresses; defend against DNS rebinding by validating the resolved IP at connect time.
- Prevent redirects to unauthorized destinations; disable or strictly validate HTTP redirects on server-side fetchers.
- Apply connection, response-size, and execution-time limits.
- Restrict outbound network access at the infrastructure level.
- Block cloud metadata endpoints such as
169.254.169.254. - Do not trust user-supplied URLs or external service responses.
Layered SSRF defense
Application-level validation must be reinforced with network-level egress controls. Network isolation is the last line of defense when URL validation is bypassed.
8. File uploads and document processing
- File signature and MIME verification, plus extension validation.
- Randomized server-generated filenames.
- Upload size, decompression, and processing limits; archive extraction protections.
- Malware scanning where appropriate.
- Secure document storage outside executable web directories.
- Private document authorization and safe document downloads; short-lived authorized download links where applicable.
- Protection against path traversal and malicious filenames.
- Parser and OCR resource limits, and isolation of document-processing services where appropriate.
- Protection against malicious PDFs, images, archives, and office documents.
- Enforce document ownership and tenant isolation.
No automatic execution
Uploaded files must never automatically become executable content.
9. Database and data security
- Least-privilege database accounts with separated read and write roles.
- Parameterized queries and secure database connections.
- Encryption in transit and, where appropriate, at rest.
- Secure key management and key rotation.
- Separation of application and administrative database permissions.
- Tenant-level data isolation.
- Secure, encrypted, access-controlled backups; tested backup restoration.
- Data retention and deletion policies.
- Protection of sensitive information in logs.
- Database connection limits and query timeouts.
Never expose database credentials or sensitive records through error messages or frontend code.
10. API and business logic security
Inspect every API and sensitive business workflow.
- Authentication and authorization on every endpoint.
- Request and response schema validation; reject unexpected fields.
- Rate limiting and resource consumption controls.
- API inventory and version management; remove obsolete endpoints.
- GraphQL query limits and protection against excessive nesting.
- WebSocket authentication and message-level authorization.
- Webhook signature verification and replay protection.
- Idempotency for applicable transactions.
- Race-condition protection and transaction integrity.
- Payment and financial operation authorization; prevent price, quantity, discount, and balance manipulation.
- Protection against workflow bypass and business logic manipulation.
- Validate responses from external services before trusting them.
Authenticated does not mean authorized
Do not assume that an authenticated request is automatically authorized.
11. Secrets and cryptographic security
- Centralized production secrets management.
- High-entropy cryptographic keys and appropriate modern algorithms.
- Secure password hashing and secure key storage with rotation.
- Separation of development and production credentials.
- Restricted access to secrets and secret access auditing.
- TLS for all sensitive communication.
- Prevention of secrets in source code, repositories, build logs, and application logs.
About .env files
A .env file is not inherently insecure. The critical requirements are preventing repository exposure, restricting access, and using an appropriate production secrets manager or secure platform injection. Do not commit .env files or credentials to version control.
12. Infrastructure and deployment security
Review and harden:
- Operating system, web server, reverse proxy, and application runtime.
- Database server, containers, and virtual machines.
- Cloud IAM and network firewall rules.
- DNS and TLS, CDN and WAF configuration.
- CI/CD pipelines and infrastructure-as-code.
- Production environment configuration.
- Least-privilege IAM and restricted cloud metadata access.
- Separation of production, staging, and development environments.
- Signed and verified production release artifacts; container image and infrastructure configuration scanning.
- Disabled unnecessary ports and services; non-root execution.
- Protection of DNS, domain, and TLS certificate management.
Use non-root execution, least privilege, network segmentation, and minimal services. Protect build pipelines against unauthorized code modification and compromised dependencies.
13. Logging, monitoring, and incident response
Implement centralized security logging for:
- Authentication failures and suspicious login activity.
- Permission denials and administrative actions.
- Password and account recovery events.
- Rate-limit violations.
- Sensitive data access.
- File uploads and downloads.
- API abuse.
- Agent tool executions where applicable.
- Security configuration changes.
Use structured logs, correlation identifiers, and protected audit records. Implement SIEM integration, alerting, and anomaly detection where appropriate.
Never log secrets
Never log passwords, authentication tokens, API secrets, or unnecessary sensitive personal information.
Implement security alerts, incident response procedures, containment mechanisms, and documented recovery processes.
14. AI and agentic application security
Where AI or autonomous agents exist, implement the applicable OWASP GenAI and Agentic security controls. Update the AI taxonomy to reflect the current 2026 OWASP publications rather than older lists.
LLM application controls
- Direct and indirect prompt injection.
- Sensitive information disclosure.
- Model and dependency supply-chain security.
- Data and model poisoning.
- Improper output handling.
- Excessive agency.
- System prompt leakage.
- Vector and embedding weaknesses.
- Misinformation.
- Unbounded consumption.
Agentic controls
- Unauthorized tool execution; validate all tool arguments and outputs.
- Agent identity and privilege abuse; give agents independent identities and least-privilege permissions.
- Memory and context poisoning.
- Insecure inter-agent communication.
- Agent cascading failures.
- Unsafe code execution; sandbox all code execution paths.
- Unauthorized external network access.
- Cross-user and cross-tenant RAG retrieval; enforce document permissions before retrieval, not just after generation.
- Separate system instructions from retrieved content.
Treat AI inputs and outputs as untrusted
Treat retrieved documents, external websites, emails, and user-provided instructions as untrusted data. Enforce authorization independently of the LLM. A model must never be able to grant itself additional privileges through its prompts or generated output. Require explicit approval for consequential actions such as financial transactions, destructive operations, changes to customer records, or production infrastructure. Provide audit trails, spending limits, tool allowlists, execution boundaries, and an emergency kill switch. Test indirect prompt injection and data exfiltration.
15. DevSecOps and supply-chain security
Integrate security throughout the software development lifecycle:
- Static Application Security Testing (SAST).
- Dynamic Application Security Testing (DAST).
- Software Composition Analysis (SCA) and dependency vulnerability scanning.
- Secret scanning.
- Infrastructure-as-Code scanning and container image scanning.
- Software Bill of Materials (SBOM).
- Dependency version pinning and build integrity verification.
- Secure code review and automated regression testing.
- Security testing before production releases.
Protect the source repository, CI/CD credentials, and deployment environment.
16. Security testing and verification
Do not stop after implementing controls. Create automated tests for:
- Authentication bypass and unauthorized access.
- Cross-user and cross-tenant data access.
- Privilege escalation.
- SQL injection, XSS, CSRF, and SSRF.
- File upload abuse and path traversal.
- API authorization failures.
- Rate-limit bypass.
- Session security.
- Business logic manipulation and race conditions.
- Sensitive information exposure.
- AI prompt injection and unauthorized tool execution where applicable.
Negative tests are required
A security feature is not verified simply because the corresponding configuration exists. Add explicit negative tests. Use safe, controlled testing environments. Do not run destructive penetration tests against production systems without explicit authorization. Use the OWASP Web Security Testing Guide to guide additional manual and automated verification.
17. Defense-in-depth requirement
For every critical vulnerability class, identify:
- The primary preventive control.
- An independent secondary protective control.
- The detection and logging mechanism.
- The containment or recovery mechanism.
- The automated test proving that the protection works.
Defense-in-depth security architecture
AI-specific controls must operate across all six layers rather than being treated as an isolated security feature. The key principle: every critical asset and attack path should have preventive, detective, and recovery controls.
Example: SQL injection defense in depth
SQL injection protection should combine parameterized queries, restricted database permissions, input validation, safe error handling, monitoring, and automated injection testing — not merely input validation. Avoid treating multiple controls that depend on the same vulnerable component as independent layers.
18. Security acceptance criteria
Before declaring the application production-ready:
- No unresolved critical or high-severity security findings.
- All critical authorization boundaries have been tested.
- Cross-tenant access tests pass where applicable.
- No known exposed production secrets.
- No debug mode or detailed stack traces in production.
- HTTPS and appropriate security headers are verified.
- Authentication and session controls are tested.
- Sensitive endpoints have appropriate rate limits.
- Database permissions follow least privilege.
- File processing and upload controls are verified.
- Backup restoration has been tested.
- Dependency and source-code security scans have been performed.
- Security regression tests pass.
- All identified exceptions are documented and risk-accepted by an authorized person.
A clean scan is not proof
A clean automated scan alone is not proof of application security.
19. Required deliverables
Produce the following project documentation:
SECURITY_ARCHITECTURE.md— Security architecture, trust boundaries, and defense-in-depth design.SECURITY_CHECKLIST.md— Complete implementation checklist with statuses.THREAT_MODEL.md— Assets, threats, attack surfaces, and mitigations.SECURITY_AUDIT.md— Findings, severity, evidence, and remediation.SECURITY_TESTS.md— Test cases, results, and outstanding gaps.SECURITY_HEADERS.md— Browser and HTTP security configuration.INCIDENT_RESPONSE.md— Detection, containment, and recovery procedures.SECURITY_DEPENDENCIES.md— Dependency inventory, vulnerabilities, and remediation.ASVS_MAPPING.md— Mapping of applicable security controls to OWASP ASVS 5.0.SECURITY_EXCEPTIONS.md— Documented exceptions, justification, compensating controls, and approval.
| Field | Purpose |
|---|---|
| Control ID | Unique reference |
| Vulnerability | What is being prevented |
| Implementation | What was actually done |
| Verification | How it was tested |
| Evidence | Test output or code reference |
| Status | Pass, Fail, Partial, Not Applicable |
| Risk | Critical, High, Medium, Low |
20. Implementation instructions
Work systematically:
- Phase 1: Inspect the application and establish the baseline.
- Phase 2: Identify and prioritize vulnerabilities by severity, exploitability, exposure, and business impact.
- Phase 3: Implement critical and high-priority security fixes.
- Phase 4: Implement additional defense-in-depth controls.
- Phase 5: Add automated security tests and regression protection.
- Phase 6: Run security verification and produce the documentation.
Constraints
- Do not unnecessarily rewrite working application components. Preserve existing functionality, integrations, user experience, and data.
- Do not silently disable features to make security tests pass.
- Do not claim that a security control has been implemented unless it exists in the actual application and has been verified.
- When a security issue cannot be resolved automatically, document the issue, its impact, the recommended remediation, and any temporary compensating controls.
Important corrections to the original checklist
Before publishing or reusing the original document, correct these details:
1. The “100 requests per minute” recommendation
Do not make this a universal default. Limits should depend on the endpoint, user, cost, and abuse potential.
2. Environment secrets (.env)
A .env file is not inherently insecure. The critical requirements are preventing repository exposure, restricting access, and using an appropriate production secrets manager or secure platform injection.
3. JavaScript output: innerText vs innerHTML
innerText is not equivalent to innerHTML in terms of XSS risk. Prefer safe text insertion, and sanitize HTML only when rendering untrusted rich content.
4. Account lockouts
Combine throttling, risk-based challenges, and MFA rather than allowing attackers to lock out legitimate users indefinitely.
5. Security headers
Add Permissions-Policy and appropriate cross-origin isolation policies where applicable. Deploy CSP in report-only mode before enforcing a new policy that might break functionality.
6. AI taxonomy
Update the AI sections to reflect the current 2026 OWASP publications rather than presenting the older lists as the latest versions.
7. Testing
Add explicit negative tests. A security feature is not verified simply because the corresponding configuration exists.
Final recommendation
Maintain two complementary documents
- Document A — Master Security Standard: the expanded specification above. This is what Claude Code should follow during development.
- Document B — Security Verification Checklist: a checklist that Claude Code updates as it implements and tests individual controls, using the fields in the deliverables table.
One final caution
Even with all these controls, do not advertise an application as completely secure or penetration-tested merely because Claude Code completed the checklist. Production readiness requires independent security assessment, appropriate penetration testing, and ongoing vulnerability management.
Final instruction: Treat security as a continuous engineering requirement, not a one-time checklist. The objective is to make the application resistant to compromise, capable of detecting attempted attacks, and resilient enough to limit damage and recover when a security control fails.
Make this the reusable security standard across web development projects, while requiring Claude Code to adapt the controls to each application’s actual architecture. This gives a much stronger foundation than repeatedly asking an AI coding assistant to make an application secure.
