Skip to content

Frontend Security

The browser is a hostile environment. Same-origin policy, CORS, CSP, XSS prevention, CSRF, prototype pollution, supply chain attacks, and secure coding patterns.

1
Same-Origin Policy and CORS
intermediate

How browsers decide which cross-origin requests to allow, why CORS exists, how preflight works under the hood, and how to fix every CORS error you will ever see.

18 min read
2
Content Security Policy
intermediate

CSP is your browser's bouncer — an allowlist that controls exactly which scripts, styles, images, and connections your page can load. Learn directives, nonce-based CSP, strict-dynamic, report-only mode, and how to deploy CSP without breaking your site.

18 min read
3
XSS: Reflected, Stored, and DOM-Based
intermediate

The three types of cross-site scripting attacks, how they work under the hood, and how to defend against every single one of them.

18 min read
4
CSRF and SameSite Cookies
intermediate

How cross-site request forgery exploits the browser's automatic cookie attachment, and the modern defenses — SameSite attributes, CSRF tokens, and header checking — that stop it.

16 min read
5
Prototype Pollution
intermediate

How attackers exploit JavaScript's prototype chain to inject properties into every object in your application, and how to stop them.

18 min read
6
Supply Chain Attacks and npm Security
intermediate

How attackers compromise npm packages to infiltrate your app, real-world incidents that burned millions of developers, and the practical defenses every frontend engineer must adopt.

18 min read
7
Secure Token Storage
intermediate

Where to store JWTs and auth tokens safely — localStorage pitfalls, httpOnly cookies, refresh token rotation, and the BFF pattern that top teams actually use.

18 min read
8
innerHTML vs textContent
intermediate

Why innerHTML is the most dangerous API in the browser, when textContent is the safe default, and how to handle the rare cases where you actually need to inject HTML.

14 min read
9
postMessage Security
intermediate

How postMessage enables cross-origin communication, why targetOrigin '*' is dangerous, how to validate origins on the receiver, and the real attack vectors that catch teams off guard.

14 min read
10
Third-Party Script Risks
intermediate

Every third-party script gets full access to your page. Understand the real attack surface of analytics, ads, and widgets — and how SRI, CSP, loading strategies, and auditing protect your users.

14 min read
11
Quiz: Spot the Vulnerability
intermediate

12 real-world code snippets hiding security vulnerabilities. Can you find the XSS, CSRF, prototype pollution, and other flaws before they reach production?

12 min read