1---2name: moai-ref-owasp-checklist3description: OWASP Top 10 security checklist, authentication patterns, input validation, and HTTP security headers reference. Agent-extending skill that amplifies backend-implementation and security-audit workflows with production-grade security patterns. NOT for: frontend UI, DevOps deployment, performance optimization, testing strategy.4---5
6# OWASP Security Checklist Reference
7
8## Target Agents
9
10- `manager-develop` - Applies checklist during backend API implementation (`cycle_type=tdd` or `cycle_type=ddd` context)
11- `/moai review --security` - Primary security-audit invocation surface (replaces the retired `/moai security` subcommand per SPEC-SUBCOMMAND-RETIRE-001); equivalently available as a per-spawn `Agent(general-purpose)` security specialist per `archived-agent-rejection.md` §C
12
13## OWASP API Security Top 10
14
15| Rank | Vulnerability | Check | Defense |
16|------|-------------|-------|---------|
17| A1 | **BOLA** (Broken Object Level Authorization) | Can user A access user B's resources? | Verify object ownership at every endpoint |
18| A2 | **Broken Authentication** | Weak passwords, unlimited login attempts? | bcrypt (cost 12+), rate limit, MFA |
19| A3 | **Broken Object Property Level Authorization** | Are hidden fields exposed in responses? | Response DTOs, field-level filtering |
20| A4 | **Unrestricted Resource Consumption** | Can mass requests crash the server? | Rate limiting, enforce pagination limits |
21| A5 | **Broken Function Level Authorization** | Can regular users call admin APIs? | RBAC middleware, permission checks |
22| A6 | **SSRF** (Server-Side Request Forgery) | Can URL input access internal resources? | URL whitelist, block internal IPs |
23| A7 | **Security Misconfiguration** | Debug mode, default accounts exposed? | Separate prod config, inspect headers |
24| A8 | **Lack of Automated Threat Protection** | Can APIs be called in abnormal sequences? | State machine validation, business rules |
25| A9 | **Improper Asset Management** | Unused APIs, old versions exposed? | API inventory, version deprecation |
26| A10 | **Unsafe API Consumption** | Are external API responses trusted blindly? | Validate external responses, set timeouts |
27
28## Authentication Checklist
29
30### Password Policy
31- Minimum 8 characters, show strength meter (not strict rules)
32- bcrypt (cost factor 12+) or Argon2id
33- Temporary lock after 5 failed attempts (15 min) or CAPTCHA
34- Prevent reuse of last 5 passwords
35
36### JWT Configuration
37| Setting | Recommended Value |
38|---------|------------------|
39| Access Token Expiry | 15-30 minutes |
40| Refresh Token Expiry | 7-14 days |
41| Algorithm | RS256 (asymmetric) or HS256 |
42| Storage | httpOnly + secure + sameSite cookie |
43| Payload | Minimal: userId, role only (no PII) |
44| Renewal | Silent refresh or token rotation |
45
46### Session Security
47- Regenerate session ID after login
48- Invalidate session on logout (server-side)
49- Set session timeout (30 min idle)
50- Bind session to IP/User-Agent (optional, strict)
51
52## HTTP Security Headers
53
54| Header | Value | Purpose |
55|--------|-------|---------|
56| `Strict-Transport-Security` | `max-age=31536000; includeSubDomains` | Force HTTPS |
57| `X-Content-Type-Options` | `nosniff` | Prevent MIME sniffing |
58| `X-Frame-Options` | `DENY` or `SAMEORIGIN` | Prevent clickjacking |
59| `Content-Security-Policy` | `default-src 'self'` | Prevent XSS |
60| `Referrer-Policy` | `strict-origin-when-cross-origin` | Limit referrer |
61| `Permissions-Policy` | `camera=(), microphone=()` | Restrict browser features |
62
63## Input Validation Checklist
64
65| Type | Method | Tool |
66|------|--------|------|
67| Schema validation | Type + structure check | Zod, Joi, pydantic, Go validator |
68| Length limits | Min/max constraints | Schema definitions |
69| SQL Injection | Parameterized queries | ORM (Prisma, GORM, SQLAlchemy) |
70| XSS Prevention | HTML escaping | DOMPurify (client), server escape |
71| Path Traversal | Path normalization | filepath.Clean + whitelist |
72| File Upload | Type + size validation | MIME type + magic number check |
73| CORS | Origin whitelist | Never `origin: '*'` with credentials |
74
75## Sensitive Data Handling
76
77| Data Type | Storage | Transmission | Logging |
78|----------|---------|-------------|---------|
79| Passwords | bcrypt hash only | HTTPS only | NEVER |
80| API Keys | Environment variables | Header (Authorization) | Masked (first 4 chars) |
81| PII | Encrypted (AES-256) | HTTPS only | Masked |
82| Credit Cards | Tokenized (payment provider) | Provider SDK | NEVER |
83| Sessions | httpOnly cookie | HTTPS only | NEVER |
84
85## Security Review Severity Levels
86
87| Level | Label | Action | Example |
88|-------|-------|--------|---------|
89| P0 | CRITICAL | Block release | SQL injection, auth bypass |
90| P1 | HIGH | Fix before merge | Missing authorization check |
91| P2 | MEDIUM | Fix within sprint | Weak password policy |
92| P3 | LOW | Track in backlog | Missing security header |
93
94## Trust Boundary Verification Principles
95
96| Principle | Applies To | Defense |
97|-----------|------------|---------|
98| Cached/client-supplied session state is not proof of current identity | Any framework caching or locally decoding a session/JWT value | Re-verify identity against the server-side source of truth (session store, token introspection, identity provider) before every authorization decision |
99| Edge/gateway/middleware auth checks are a UX convenience, not a security boundary | Reverse proxies, framework middleware, API gateways, serverless edge functions | Every mutation-handling endpoint independently re-checks authentication AND resource-ownership authorization |
100| Scheduled/cron-triggered HTTP endpoints are still public URLs | Any scheduler that invokes an HTTP endpoint (cron jobs, scheduled serverless functions, container-orchestrator scheduled jobs) | Require a shared-secret bearer check (constant-time compare) on every scheduled-endpoint invocation |
101| Production builds must not expose source maps or equivalent debug artifacts | Any bundler/build tool | Disable production source maps, verbose stack traces, and build manifests in production configuration |
102| Webhook receivers must verify a signature/HMAC header before trusting the payload | Any webhook provider | Verify signature/HMAC against a shared secret before treating the payload as legitimate business data |
103
104<!-- moai:evolvable-start id="rationalizations" -->
105## Common Rationalizations
106
107| Rationalization | Reality |
108|---|---|
109| "This is an internal application, OWASP does not apply" | Internal applications are reachable from compromised internal services. OWASP applies to all web applications. |
110| "The framework handles XSS protection" | Frameworks protect default rendering paths. Dynamic HTML insertion, innerHTML, and template literals bypass the protection. |
111| "We do not store sensitive data, so encryption is unnecessary" | Session tokens, API keys, and PII are sensitive data. If the application has users, it has sensitive data. |
112| "Security headers are just defense-in-depth, not critical" | Each security header blocks a specific attack class. Missing CSP enables XSS even when output is escaped. |
113| "I will do a security review before release" | Late security reviews find issues that are expensive to fix. Secure coding practices prevent them from the start. |
114
115<!-- moai:evolvable-end -->
116
117<!-- moai:evolvable-start id="red-flags" -->
118## Red Flags
119
120- User input rendered in HTML without escaping or sanitization
121- SQL query built with string concatenation instead of parameterized queries
122- Authentication token stored in localStorage instead of httpOnly cookie
123- Missing Content-Security-Policy header on response
124- Secrets (API keys, passwords) found in source code or configuration files committed to git
125
126<!-- moai:evolvable-end -->
127
128<!-- moai:evolvable-start id="verification" -->
129## Verification
130
131- [ ] OWASP Top 10 checklist reviewed for the change (show which items were evaluated)
132- [ ] User input sanitized before rendering in HTML output
133- [ ] All database queries use parameterized statements
134- [ ] Security headers present (CSP, X-Frame-Options, X-Content-Type-Options)
135- [ ] No secrets found in source code (show grep results for common secret patterns)
136- [ ] Authentication tokens use httpOnly, Secure, SameSite cookie attributes
137
138<!-- moai:evolvable-end -->