Skip to content

Comments

fix: add nonce to script-src-elem and style-src-elem when configured#9999

Merged
michalsn merged 1 commit intocodeigniter4:developfrom
michalsn:fix/csp-src-elem
Feb 24, 2026
Merged

fix: add nonce to script-src-elem and style-src-elem when configured#9999
michalsn merged 1 commit intocodeigniter4:developfrom
michalsn:fix/csp-src-elem

Conversation

@michalsn
Copy link
Member

Description
This PR fixes a bug where nonce wasn't added to script-src-elem / style-src-elem when those directives were configured.

Fixes #9992

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@michalsn michalsn added the bug Verified issues on the current code behavior or pull requests that will fix them label Feb 24, 2026
Copy link
Member

@paulbalandan paulbalandan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly from the spec, script-src already governs the other script-src-attr and script-src-elem directives. So, if someone calls getScriptNonce() which sets the nonce to script-src, should it be safe to assume that script-src-attr and script-src-elem don't need to have the same nonce as their source expressions? Same goes for style-src directive.

Copy link
Member

@paulbalandan paulbalandan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have read more and understood it fully. Thanks!

@michalsn michalsn merged commit 0fe15ad into codeigniter4:develop Feb 24, 2026
50 checks passed
@michalsn
Copy link
Member Author

Thank you for the reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: styleSrcElem and scriptSrcElem are not updated with th nonce

3 participants