Phoenix LiveView 1.2

Last reviewed Sep 12, 2026

Export as PDF

Prompt Details

Prompt Composition

4prompts
  1. Erlang/OTP 29187 lines · 8.9K tokens
  2. Elixir 1.2051 lines · 1.6K tokens
  3. Phoenix 1.859 lines · 2.4K tokens
  4. Phoenix LiveView 1.249 lines · 1K tokens
Total346 lines · 13.9K tokens

CWE Coverage

  • 20
  • 22
  • 59
  • 73
  • 78
  • 79
  • 89
  • 95
  • 113
  • 116
  • 117
  • 190
  • 201
  • 208
  • 209
  • 214
  • 250
  • 287
  • 295
  • 296
  • 297
  • 298
  • 299
  • 306
  • 307
  • 311
  • 319
  • 323
  • 327
  • 338
  • 347
  • 352
  • 362
  • 367
  • 379
  • 384
  • 400
  • 407
  • 427
  • 434
  • 444
  • 470
  • 472
  • 494
  • 502
  • 522
  • 532
  • 552
  • 601
  • 611
  • 613
  • 614
  • 639
  • 664
  • 674
  • 732
  • 755
  • 770
  • 772
  • 789
  • 799
  • 807
  • 829
  • 834
  • 862
  • 863
  • 916
  • 918
  • 922
  • 940
  • 942
  • 943
  • 1004
  • 1021
  • 1275
  • 1287
  • 1395

Prompt Preview

Apply the Phoenix 1.8 prompt and its Elixir and Erlang/OTP baselines first. These rules cover LiveView mounts, events, components, uploads, client hooks, and long-lived socket state.

Mount and reconnect authorization

  • Authenticate and load identity with on_mount or equivalent hooks on both disconnected and connected mounts.
  • Authorize the current tenant and resource again after the WebSocket connects; disconnected render state is not sufficient authority.
  • Treat params, session data, connect parameters, URI, and client metadata as untrusted even when they were signed or previously rendered.
  • Recheck permissions after navigation, reconnect, impersonation changes, and other identity or tenant transitions. Set live_socket_id in the session so logout and revocation broadcasts can disconnect every affected LiveView.
  • Use separate live_session groups for different authentication requirements; navigation within a group skips router plugs.

Events and components

  • Pattern-match and validate every handle_event/3 payload before lookup or mutation.
  • Authorize the actual loaded object for every event instead of trusting DOM IDs, component IDs, or hidden values.
  • Treat LiveComponents as shared server code, not authorization boundaries, and pass only the minimum trusted assigns.
  • Keep privileged actions out of generic event-name dispatch and never convert an event string to a module, function, or atom.

Rendering and client trust

  • Render attacker content through HEEx escaping and avoid raw/1, unsafe fragments, and client-produced HTML.
  • Treat hidden