Allow overriding Content Security Policy on published artefacts - #377
Open
mc1arke wants to merge 1 commit into
Open
Allow overriding Content Security Policy on published artefacts#377mc1arke wants to merge 1 commit into
mc1arke wants to merge 1 commit into
Conversation
mc1arke
commented
Sep 15, 2025
mc1arke
force-pushed
the
content-security-policy
branch
from
September 17, 2025 07:23
65cab36 to
a833257
Compare
Jenkins currently enforces a global Content Security Policy that prevents in-line styles and scripts from being loaded, so prevents archived HTML from tools that use such in-line elements from rendering properly. The workaround for this is to weaken the global policy by allowing such in-line elements to be loaded across Jenkins, although in some places people are recommending to disable CSP completely. To overcome this, the plugin is being altered to allow configuration to be set that enables scripts and styles, and dynamically injects these into the Content-Security-Policy header when serving archived artefacts. To ensure that a user with Job Configure permissions can't initially use their access to enable a Content Security Policy to publish malicious artefacts for attacking the Jenkins instance, the option to alter the Content Security Policy is enabled instance-wide through a global configuration by default, and must be enabled through the Jenkins UI by an Administrator.
mc1arke
force-pushed
the
content-security-policy
branch
from
September 17, 2025 08:10
a833257 to
08e6bea
Compare
|
Hi, we have a similar issue. We use the resource root URL setting in Jenkins to serve artifacts from a different domain, which solves the issue for HTML files in the workflow artifact list. But reports published via this plugin don't seem to respect this setting. Wouldn't it be better to make it so that the output of this plugin is served from behind the resource root, if configured? Then you don't need to mess with the CSP, and the risk of privilege escalation via session hijack by a user with |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Jenkins currently enforces a global Content Security Policy that prevents in-line styles and scripts from being loaded, so prevents archived HTML from tools that use such in-line elements from rendering properly. The workaround for this is to weaken the global policy by allowing such in-line elements to be loaded across Jenkins, although in some places people are recommending to disable CSP completely. To overcome this, the plugin is being altered to allow configuration to be set that enables scripts and styles, and dynamically injects these into the Content-Security-Policy header when serving archived artefacts.
JENKINS-75843, JENKINS-75769
Testing done
Automated test that shows sandbox attribute being altered on iframe, and Content-Security-Policy header being modified on serving of archived content. Manual testing shows a page that didn't render properly with current plugin now rendering properly with altered plugin:
Gatling report with default htmlpublisher configuration (scripts and styles fail to load):

Gatling report with altered htmlpublisher configuration (scripts and styles successfully load):

Similarly, ZAP report with default configuration (inline styles and images failing to load):
Same report with styles and images enabled:
Submitter checklist