Senior Track Roadmap

Advanced Hotwire security

This course looks at the places in a Hotwire application where work leaves the request you pictured. It shows what a broadcast renders without a request, session or current user, and why nothing per-viewer belongs in a broadcast partial. It covers Content Security Policy nonces with importmap, CSRF tokens in Turbo submissions and hand-written fetch calls, prefetch requests fired on hover, and morphing with DOM identity. It closes with frames, origins, data attributes as untrusted input and a checklist of six questions.

What you'll learn

  • ✓Why broadcast partials render with no request, session or current user
  • ✓How refresh broadcasts let each subscriber re-fetch under its own session
  • ✓What a CSP nonce protects and why importmap needs one
  • ✓How Turbo sends the CSRF token and what your own fetch must do
  • ✓Why prefetch turns state-changing GETs into hover-triggered actions
  • ✓How morphing preserves DOM nodes and why frames and data attributes need care
Free preview · Lesson 1 4 min read

The Hotwire attack surface

A background job renders a partial. Nobody is logged in inside that job, because nobody is anything inside a job. The partial asks for the current user, gets nil and renders the signed-out version of a card. Action Cable sends that same HTML to every browser subscribed to the stream.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...