Bỏ qua menu, vào nội dung chính

Rà soát an toàn cho phần mềm web - 40 mục cần kiểm

4-8 giờ kỹ sư + 2-4 tuần fixKhóCTO / Security Engineer / Senior Dev

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 + phạt GDPR/Luật Bảo vệ dữ liệu cá nhân + 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 + Luật Bảo vệ dữ liệu cá nhân 91/2025/QH15 Việt Nam.

Các bước

  1. 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

  2. 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

  3. 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

  4. HTTP Headers + Transport security

    30 phút

    Modern 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

  5. 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

  6. Luật Bảo vệ dữ liệu cá nhân 2025 (Việt Nam, thay Nghị định 13/2023)

    1-2 giờ

    Luật Bảo vệ dữ liệu cá nhân 91/2025/QH15 và Nghị định 356/2025/NĐ-CP (hiệu lực 01/01/2026) - 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

Danh mục kiểm

  1. 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
  2. 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
  3. 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
  4. 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
  5. Luật Bảo vệ dữ liệu cá nhân 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

Rủi ro và lưu ý

Dấu hiệu rủi ro

  • 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.

Lưu ý khi làm

  • 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 ý

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 theo Luật Bảo vệ dữ liệu cá nhân 2025 + reputation damage. Minimum: OWASP Top 10 check + tuân thủ Luật Bảo vệ dữ liệu cá nhân.

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.

Vi phạm Luật Bảo vệ dữ liệu cá nhân bị phạt thế nào?

Điều 8 Luật Bảo vệ dữ liệu cá nhân 91/2025/QH15 (hiệu lực 01/01/2026, thay Nghị định 13/2023) đặt mức phạt tiền tối đa với tổ chức: 3 tỷ đồng cho phần lớn hành vi, 5% doanh thu năm trước với vi phạm chuyển dữ liệu xuyên biên giới, 10 lần khoản thu với mua bán dữ liệu cá nhân; cá nhân chịu một nửa mức của tổ chức. Mức phạt từng hành vi cụ thể do nghị định xử phạt quy định, cần đối chiếu khi áp dụng. Reputation damage lớn hơn nhiều: KH cũ lo ngại + KH mới không tin.

Trao đổi về dự án

Cần tư vấn?