Skip to content

Remove inline scripts and styles to enable strict CSP - #9596

Merged
taylorsilva merged 3 commits into
concourse:masterfrom
Kump3r:refactor-web
Jun 15, 2026
Merged

taylorsilva merged 3 commits into
concourse:masterfrom
Kump3r:refactor-web

Conversation

@Kump3r

@Kump3r Kump3r commented Jun 10, 2026 •

Copy link
Copy Markdown
Contributor

Move keyframe animations from inline <style> in index.html into animation.less so they are compiled into main.css at build time.

Replace the inline <script> that injected window.elmFlags with tags rendered server-side, and update elm-setup.js to read those values via document.querySelector. This eliminates 'unsafe-inline' from script-src, allowing a clean default-src 'self' CSP policy.

Changes proposed by this PR

I can compile and add screenshots later, but there should be no functional changes, the idea is to allow Concourse to use CSP: "frame-ancestors 'none'; default-src 'self'" as strict security hardening, removing only the background_image and custom fonts section, but allowing concourse to continue to run normally

Notes to reviewer

Steps to reproduce, add

CONCOURSE_CONTENT_SECURITY_POLICY: "frame-ancestors 'none'; default-src 'self'" 

to docker-compose.yml web section.

Before:

Screenshot 2026-06-10 at 18 19 57

After:
Screenshot 2026-06-10 at 18 22 38
The font is blocked as expected, with this strict policy, also pipeline images would be blocked.

@Kump3r
Kump3r requested a review from a team June 10, 2026 15:01
Move keyframe animations from inline <style> in index.html into
animation.less so they are compiled into main.css at build time.

Replace the inline <script> that injected window.elmFlags with <meta>
tags rendered server-side, and update elm-setup.js to read those values
via document.querySelector. This eliminates 'unsafe-inline' from
script-src, allowing a clean default-src 'self' CSP policy.

Signed-off-by: Kump3r <[email protected]>
@Kump3r

Kump3r commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

After demo:

Screen.Recording.2026-06-11.at.15.01.25.mov

Important: The error visible in the beginning during login, I addressed in the last commit, now there are no more JS errors and we can safely use: "frame-ancestors 'none'; default-src 'self'" to block scripts, images, fonts that we do not expect.

@Kump3r

Kump3r commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

Also tested the auth flow trough the CF connector in our environments and it works normally without any issue. There are no scripts there, just thought it is worth mentioning 😅

@Kump3r Kump3r added the web-ui label Jun 11, 2026
Signed-off-by: Taylor Silva <[email protected]>
@taylorsilva

Copy link
Copy Markdown
Member

I went ahead and embedded the UnifrakturCook font within Concourse. I prefer having Concourse include everything that it needs to run the web UI.

@ceco556 ceco556 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested locally and it is working as expected. The only thing i didn't test is the CF connector, but i see that Kalin already tested it.

Great job!

@taylorsilva
taylorsilva merged commit 453f983 into concourse:master Jun 15, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants