Skip to content

Commit f21b10c

Browse files
dadachiclaude
andcommitted
Use SecureRandom for CSP nonce instead of session ID
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ab39ca1 commit f21b10c

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

config/initializers/content_security_policy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
end
2020

2121
# Generate session nonces for permitted importmap and inline scripts.
22-
config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
22+
config.content_security_policy_nonce_generator = ->(request) { SecureRandom.base64(16) }
2323
config.content_security_policy_nonce_directives = %w[script-src]
2424

2525
# Report violations without enforcing the policy.

0 commit comments

Comments
 (0)