Day 05 Defense in Depth

Security Headers, CORS, and CSP

HSTS, CSP, CORS policies, SameSite cookies, and the layered defense configuration that stops entire classes of attacks before they reach your application code.

~1 hour Intermediate Hands-on Precision AI Academy

Today's Objective

HSTS, CSP, CORS policies, SameSite cookies, and the layered defense configuration that stops entire classes of attacks before they reach your application code.

01

Never Hardcode Secrets

API keys, database passwords, and JWT secrets hardcoded in source code get exposed in git history, logs, error messages, and accidental deployments. Environment variables are the minimum — secret managers are the standard for production.

.env — Local Development
# .env (local only — in .gitignore!)
DATABASE_URL=postgresql://localhost:5432/myapp
JWT_SECRET=super-long-random-string-at-least-32-chars
ANTHROPIC_API_KEY=sk-ant-...
GOOGLE_CLIENT_SECRET=GOCSPX-...
.gitignore — What Never to Commit
.env
.env.local
.env.*.local
*.pem
*.key
secrets/
node_modules/
Security Audit with Claude
# Use Claude to audit your security posture:

Prompt: "Review this Express application code for security
vulnerabilities. Check for:
- Hardcoded secrets or API keys
- SQL injection vulnerabilities
- Missing authentication on sensitive routes
- Insecure cookie configuration
- Missing rate limiting
- XSS vulnerabilities in response rendering
- Overly permissive CORS settings

[PASTE YOUR CODE]"
02

Production Security Checklist

Day 5 Exercise
Security Audit Your App
  1. Run npm audit on your project. Fix any high-severity vulnerabilities.
  2. Paste your main server file into Claude with the security audit prompt above.
  3. Work through the production checklist — check off each item or add it to your code.
  4. Run your app in production mode (NODE_ENV=production) and confirm error details are not exposed.

Course Complete — Secure Web Authentication

Want to go deeper in 2 days?

Our in-person AI bootcamp covers advanced AI development, agentic systems, and production deployment. Five cities. $1,490.

Reserve Your Seat →

Course Complete

Completing all five days means having a solid working knowledge of Web Security in 5 Days. The skills here translate directly to real projects. The next step is practice — pick a project and build something with what was learned.

Day 5 Checkpoint

Before moving on, verify you can answer these without looking:

  • What is the core concept introduced in this lesson, and why does it matter?
  • What are the two or three most common mistakes practitioners make with this topic?
  • Can you explain the key code pattern from this lesson to a colleague in plain language?
  • What would break first if you skipped the safeguards or best practices described here?
  • How does today's topic connect to what comes in Day the final lesson?

Live Bootcamp

Learn this in person — 2 days, 5 cities

Thu–Fri sessions in Denver, Los Angeles, New York, Chicago, and Dallas. $1,490 per seat. June–October 2026.

Reserve Your Seat →
Back to Course
Web Security in 5 Days — Full Course Overview