เอกสารเฉพาะหมวด — แยกออกจากเอกสารอื่นเพื่อให้อ่านง่าย
Reviewed: 2026-05-21. Target: Top 5 risks per OWASP 2021 ranking.
5 / 5 mitigated — ทุกข้อมี mitigation พร้อม evidence
| # | Risk | Status | Mitigation | Evidence |
|---|---|---|---|---|
| A01 | Broken Access Control | ✓ | ทุก route auth-gated ใน src/middleware.ts. Permission helpers ใน src/lib/permissions.ts บังคับกฎ role ที่ server-action boundary ไม่ใช่แค่ UI. Self-edit guard กัน lockout. | tests/lib/permissions.test.ts ครอบคลุม role × target matrix เต็มรูปแบบ (17 tests pass) |
| A02 | Cryptographic Failures | ✓ | Passwords: bcryptjs cost 10. Sessions: JWT HS256 (jose), httpOnly + secure cookies ใน prod. Sensitive product data (login/email/bank): AES-256-GCM ผ่าน src/lib/crypto.ts random IV ต่อ row. Key จาก ENCRYPTION_KEY env (32 bytes). | tests/lib/auth.test.ts + tests/lib/crypto.test.ts — round-trip + tamper detection |
| A03 | Injection (SQL / XSS) | ✓ | DB access ทุกจุดผ่าน Prisma parameterized queries ไม่มี raw SQL string concat. React auto-escape JSX output ทุกที่ ไม่ใช้ dangerouslySetInnerHTML. Server actions แปลง FormData เป็น String(...) + length cap ก่อน persist. | Code review ของ src/app/**/actions.ts ทุกไฟล์ |
| A04 | Insecure Design | ✓ | 2-role model บังคับ end-to-end. Cache rules (ทุก read ผ่าน cached(), ทุก write invalidate) เขียนใน memory cache_rules.md. Transfer state machine: STAFF-initiated → PENDING; MASTER อนุมัติเท่านั้น. Refund hard cap ฿1,000 บังคับ server-side. | Schema review; claims/actions.ts reject refund > 1000 |
| A05 | Security Misconfiguration | ✓ | Nginx headers: X-Frame-Options: SAMEORIGIN, X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer-when-downgrade, X-XSS-Protection: 1; mode=block. server_tokens off ปิด version exposure. HSTS server block พร้อม activate ใน nginx/default.conf (uncomment หลัง certbot install). Docker image รันด้วย non-root user (uid 1001). | nginx/default.conf lines 1, 38-43; Dockerfile runner stage |
ระบบจะถือว่า ผ่านการตรวจสอบความปลอดภัย เมื่อทุกข้อใน Top 5 อยู่ในสถานะ ✓ พร้อม evidence ที่ตรวจสอบได้.
สถานะปัจจุบัน: ผ่านครบทุกข้อ ✓