Mid-level Track Roadmap

Security: CSP

This course reads the Content Security Policy of one Rails application line by line. It explains how directives fall back to default-src, and why base-uri, form-action and frame-ancestors do not. It compares allowlists with nonces, hashes and strict-dynamic, and examines each exception in the policy, such as unsafe-inline in style-src and wasm-unsafe-eval. It covers rolling out a policy with report-only mode and a reporting endpoint. It ends with an ordered plan for hardening the policy.

What you'll learn

  • ✓How CSP stops an injected payload from executing
  • ✓Which directives fall back to default-src and which do not
  • ✓How nonces, hashes and strict-dynamic replace host allowlists
  • ✓How to judge each exception in a policy
  • ✓How to roll out a policy with report-only mode
  • ✓An ordered plan to harden an existing Rails policy
Free preview · Lesson 1 4 min read

The policy this app already has

Most Rails applications have config/initializers/content_security_policy.rb sitting there entirely commented out. This one does not.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...