Audit security web app qua 5 nhóm: (1) OWASP Top 10 (injection, XSS, CSRF, auth, …), (2) Authentication + session management, (3) Secrets + config, (4) HTTP headers + transport, (5) Dependency + supply chain. Checklist 40 mục dưới đây áp dụng cho mọi web app production. Mỗi audit cycle: 4-8 giờ kỹ sư.
Security incident có thể tổn thất 50-500 triệu (revenue lost + GDPR/Nghị định 13 fines + reputation). Audit định kỳ 6 tháng 1 lần là minimum cho web app production. Hướng dẫn này dựa OWASP Top 10 2021 + Nghị định 13/2023 Việt Nam.
Làm từng bước.
- 01
OWASP Top 10 scan
2-3 giờQuét manual + automated 10 lỗ hổng phổ biến nhất theo OWASP. Đây là baseline minimum.
- A01 Broken Access Control - kiểm tra IDOR, missing authorization checks
- A02 Cryptographic Failures - TLS version, weak ciphers, password hashing (bcrypt/argon2)
- A03 Injection - SQL injection test với sqlmap, XSS test reflected + stored
- A04 Insecure Design - review architecture, threat modeling
- A05 Security Misconfiguration - error pages leak info, default credentials, unnecessary services
- A06 Vulnerable Components - npm audit, dependency scan
- A07 Auth Failures - brute force, session fixation, weak password policy
- A08 Software + Data Integrity - verify CI/CD pipeline + signed releases
- A09 Logging Failures - log security events, không log sensitive data
- A10 SSRF - kiểm tra server-side request forgery
Kết quả: OWASP scan report với CVE severity ranking
- 02
Authentication + Session management
1-2 giờAuth là attack surface lớn nhất. Verify mọi flow: login, logout, password reset, account lockout.
- Password policy enforce: min 8 chars, complexity, no breached passwords (haveibeenpwned)
- Account lockout sau 5-10 failed attempts (rate limit)
- Session cookie: httpOnly + secure + sameSite=lax
- JWT properly: short expiry (15min) + refresh token, validate signature, no sensitive data in payload
- Logout: invalidate session server-side (không chỉ delete cookie)
- Password reset: token expires <1h, single use, secure transmission
- MFA / 2FA cho admin accounts (TOTP, SMS, hoặc passkey)
Kết quả: Auth audit report + recommendations
- 03
Secrets + Configuration
1 giờSecrets leak là root cause của 30% incidents. Verify không có secrets in code, env, log.
- Scan codebase với git-secrets / gitleaks - không có API key trong git history
- Environment variables không log ra console
- Production secrets khác staging khác dev
- Rotate secrets policy: API keys 90 ngày, passwords 180 ngày, certificates 365 ngày
- Secrets storage: AWS Secrets Manager / Cloudflare Secrets / Vault - không .env trên server
- Database connection string không hardcode trong code
Kết quả: Secrets audit + rotation plan
- 04
HTTP Headers + Transport security
30 phútModern web app cần headers đúng để defense in depth. Test với securityheaders.com.
- HTTPS strict - redirect HTTP → HTTPS
- HSTS header: max-age >= 31536000 (1 năm), includeSubDomains, preload
- Content-Security-Policy: restrict script-src, style-src, img-src
- X-Content-Type-Options: nosniff
- X-Frame-Options: DENY (chống clickjacking)
- Referrer-Policy: strict-origin-when-cross-origin
- Permissions-Policy: disable unused features (geolocation, camera)
- Cookies: Secure + HttpOnly + SameSite cho mọi cookies
Kết quả: Headers score A+ trên securityheaders.com
- 05
Dependency + Supply chain
1 giờSupply chain attacks (npm package compromise) tăng nhanh 2024-2026. Verify dependencies định kỳ.
- npm audit / pnpm audit weekly - fix high + critical
- Snyk hoặc Dependabot enabled trong GitHub
- Lockfile (package-lock.json / pnpm-lock.yaml) committed
- Review new dependencies trước khi add - popularity, last update, maintainer reputation
- Pin major versions - không dùng `latest` hoặc `^` cho critical libs
- SBOM (Software Bill of Materials) - list tất cả dependencies + license + version
Kết quả: Dependency audit report + SBOM
- 06
Nghị định 13/2023 compliance (Việt Nam)
1-2 giờNghị định 13 về bảo vệ dữ liệu cá nhân - apply cho mọi web app xử lý data người dùng VN.
- Consent banner cookie + tracking - user opt-in explicit
- Privacy policy đầy đủ - data thu thập gì, dùng làm gì, bao lâu, share với ai
- User rights - xem data, xoá data, export data theo yêu cầu (trong 30 ngày)
- Data localization - data nhạy cảm lưu tại VN (VNG, Viettel IDC) nếu thuộc danh mục bắt buộc
- Audit log truy cập data cá nhân - ai access khi nào
- Breach notification process - báo cáo trong 72h nếu có incident
- DPA (Data Processing Agreement) với mỗi vendor xử lý data (Google Analytics, OpenAI, etc.)
Kết quả: Compliance checklist signed off
Checklist tổng hợp.
- 01
OWASP Top 10
- Authorization checks trên mọi endpoint
- TLS 1.2+ với strong ciphers
- Parameterized queries (no SQL injection)
- Input validation + output encoding (no XSS)
- Default credentials removed
- npm audit clean (no high/critical)
- Brute force protection
- Audit log security events
- SSRF prevention
- 02
Authentication
- Password min 8 chars + breached check
- Account lockout sau 5-10 fails
- Session cookie httpOnly + secure + sameSite
- JWT short expiry + refresh token
- Logout invalidate server-side
- Password reset token <1h + single use
- MFA cho admin
- 03
Secrets + Config
- Git-secrets scan clean
- Secrets không log
- Production secrets isolated
- Rotation policy documented
- Secrets manager (not .env)
- DB connection không hardcode
- 04
HTTP Headers
- HTTPS redirect
- HSTS 1 năm + preload
- CSP restrict script/style/img
- X-Content-Type-Options: nosniff
- X-Frame-Options: DENY
- Cookies Secure + HttpOnly + SameSite
- 05
Nghị định 13 VN
- Cookie consent banner
- Privacy policy đầy đủ
- User data rights (view/delete/export)
- Data localization nếu cần
- Audit log data access
- Breach notification process
- DPA với 3rd party vendors
- API key trong git history. Commit accidentally → leak forever. Tools như git-secrets, gitleaks scan. Nếu lỡ commit: rotate ngay, force-push không cứu được (đã clone). Use BFG Repo-Cleaner.
- Password hash với MD5/SHA1. Vẫn còn thấy trong legacy code VN. Phải migration sang bcrypt/argon2. Migration plan: re-hash password khi user login next time.
- Database backup không encrypt. Backup leak = full database leak. Encrypt backup at rest + transit. Store backup separately từ production credentials.
- Admin panel exposed public. Admin panel tại /admin không có IP whitelist + chỉ rely vào auth = risky. Add IP whitelist (Cloudflare Access) + MFA + audit log.
- Skip security trong sprint hectic. 'Sprint sau sẽ fix' = không bao giờ fix. Embed security trong definition of done. PR review check security checklist.
- Automated scan trong CI/CD. Snyk + npm audit + git-secrets trong GitHub Actions. Block merge nếu high/critical vulnerability. Catch sớm, fix rẻ.
- Penetration test hằng năm. Internal audit không đủ - outside perspective cần thiết. Pentesting Việt Nam 30-80 triệu cho web app medium. ROI cao.
- Bug bounty internal. Reward nhân viên discover vulnerability - 1-5 triệu/finding. Mỗi quý tổ chức 'security day' với reward + ăn pizza.
- Incident response runbook. Có sẵn runbook cho 5-10 scenarios (DB leak, admin compromise, DDoS). Khi happen, không panic - execute runbook.
Công cụ gợi ý.
- OWASP Top 10 PDF VietnamesePhiên bản 2021 dịch tiếng Việt
- Security headers checkerTest online: securityheaders.com
- Have I Been Pwned APICheck password breached: haveibeenpwned.com/Passwords
- Nghị định 13 full textPDF official từ Cổng thông tin Chính phủ
Câu hỏi thường gặp.
Audit security mất bao nhiêu thời gian + chi phí?
Internal audit (đội tự làm theo checklist): 4-8 giờ kỹ sư cho web app medium. Outside pentest: 30-80 triệu, 1-2 tuần. Frequency: internal mỗi 3 tháng, outside mỗi 12 tháng. ROI: 1 incident = 50-500 triệu mất, audit là rẻ.
Web app SME có thực sự cần security audit không?
Có. Tấn công automated bot scan mọi web 24/7, không phân biệt SME hay enterprise. Đặc biệt nguy hiểm: SME có data KH (CRM, contacts) → bị leak có thể bị phạt Nghị định 13 + reputation damage. Minimum: OWASP Top 10 check + Nghị định 13 compliance.
Sửa security issues mất bao lâu sau audit?
Phụ thuộc severity. Critical (RCE, SQL injection): fix trong 24-72h. High (XSS, auth bypass): 1-2 tuần. Medium (missing headers, weak crypto): 2-4 tuần. Low (cosmetic): roadmap dài hơi. Reserve 10-15% dev time cho security backlog.
Bug bounty program có nên không?
Doanh nghiệp SME: chưa cần public bug bounty. Internal program với nhân viên + close circle (HackerOne private) OK. Public bug bounty cần dev team có capacity respond + reward thực - premature thường tạo noise. Khi quy mô >100k user mới cần public.
Nghị định 13 violations bị phạt thế nào?
Mức phạt theo Nghị định: 50-100 triệu cho tổ chức vi phạm xử lý data cá nhân không có sự đồng ý. 200-500 triệu cho trường hợp nghiêm trọng (data >100 người, data nhạy cảm). Reputation damage lớn hơn nhiều: KH cũ lo ngại + KH mới không tin.
Hướng dẫn khác:
Trường hợp cụ thể
có gì khác?
Mô tả bài toán, ALODEV tư vấn đúng nghiệp vụ, miễn phí.