JavaScript – Con dao hai lưỡi
JavaScript chạy trên 95%+ website (client-side) và ngày càng phổ biến server-side (Node.js, Deno, Bun). Điều này làm nó trở thành mặt tấn công lớn nhất và cũng là công cụ mạnh cho defender.
Rủi ro bảo mật chính (Client-side)
- Cross-Site Scripting (XSS): Tấn công #1 (OWASP Top 10). Kẻ chèn script độc hại vào trang web → thực thi trên trình duyệt nạn nhân → cắp cookie, session, keystroke, redirect, deface.
- Cross-Site Request Forgery (CSRF): Lừa trình duyệt gửi request trái phép đến site đã xác thực.
- Clickjacking / UI Redressing: Iframe ẩn, lừa click.
- Prototype Pollution: Ghi đè prototype object → RCE/DoS.
- Dependency Confusion / Supply Chain Attack: Package npm độc hại (event-stream, ua-parser-js, colors.js).
- Information Leakage: console.log, source map, comment, .map file lộ logic, API key.
JavaScript trong tấn công mạng (Offensive)
- Exploit Kit: Landing page JS fingerprint trình duyệt → chọn exploit phù hợp (CVE-2021-26411 IE, CVE-2022-22965 Spring4Shell payload JS).
- Malicious Browser Extension: Cắp token, keystroke, form data, crypto wallet.
- Polyglot / JPG+JS: File hình ảnh chứa JS hợp lệ – bypass upload filter.
- Node.js RCE: Deserialization (node-serialize), prototype pollution, command injection qua child_process.
- Cobalt Strike / Sliver / Metasploit JS payload: Execute-assembly, inline-execute.
JavaScript cho phòng thủ (Defensive)
- WAF/RASP rules: Viết rule ModSecurity, Cloudflare WAF, AWS WAF bằng JS/Regex detect XSS, SQLi, LFI.
- CSP (Content Security Policy): Header `Content-Security-Policy` – chặn inline script, chỉ allow nonce/hash/trusted domain.
- Subresource Integrity (SRI): `