Skip to content

Conversation

@daniel-beck
Copy link
Member

Fixes #26001

I considered multiple options to address this issue:

  • Amend CSP rules to allow redirects. At least core always sends to www.jenkins.io, so that would be easy.
  • Change the buttons with form submission to links and directly go there.
  • Keep the buttons but attach JS to navigate to the site.
  • Change how the direct is done, from HTTP 302 with Location header to client-side JS/meta tag.

The first one is easy but limited: Any URLs outside www.jenkins.io would be unsupported. Even if there aren't many problems like this across plugins, relaxing rules does not set a good example for plugin developers.

The second one was my favorite until I found #26205. It's still my favorite option for plugins though, and has as additional benefit that it's straightforward to open the link in a new window.

The third seems unnecessarily complicated on the view, so I dismissed it quickly.

This implementation uses the fourth option. For use in plugins, they would need to increase the core dependency, or reimplement the HttpResponse calling Util#printRedirect themselves. The latter seems reasonable, with just using a (currently broken looking) link probably the easiest.

FWIW there is currently no caller for HttpResponses#clientRedirectTo, so technically not ideal. It seems like a natural addition to that API though, and mirrors existing methods. Adding it there would help discoverability.

In terms of plugins, a quick GH code search found just:

  • dimensionsscm is currently incompatible with CSP enforcement anyway, so that just adds another one to the list.
  • analysis-core is suspended since 2020.
  • scis-ad is suspended since 2011, redirects to a dead domain.

Even if my search is not complete, I would expect this to be a problem in few plugins, and it's fairly easily resolved with a link.

Testing done

Clicked the buttons in Chrome once the monitors showed:

  • The reverse proxy monitor is always active in jetty:run, since it fails with "HTTP ERROR 400 Ambiguous URI path separator".
  • hudson.security.csrf.DefaultCrumbIssuer.EXCLUDE_SESSION_ID = true in script console
  • Locally patched JavaVersionRecommendationAdminMonitor so it's already due.

I skipped autotests, because the new code is just a minor adapter around existing code doing the actual work.

Screenshots (UI changes only)

n/a

Before

After

Proposed changelog entries

  • Make redirects to documentation on www.jenkins.io work in the built-in administrative monitors when using Chrome and enforcing Content Security Policy.

Proposed changelog category

/label bug

Proposed upgrade guidelines

N/A

Submitter checklist

  • The issue, if it exists, is well-described.
  • The changelog entries and upgrade guidelines are appropriate for the audience affected by the change (users or developers, depending on the change) and are in the imperative mood (see examples). Fill in the Proposed upgrade guidelines section only if there are breaking changes or changes that may require extra steps from users during upgrade.
  • There is automated testing or an explanation as to why this change has no tests.
  • New public classes, fields, and methods are annotated with @Restricted or have @since TODO Javadocs, as appropriate.
  • New deprecations are annotated with @Deprecated(since = "TODO") or @Deprecated(forRemoval = true, since = "TODO"), if applicable.
  • UI changes do not introduce regressions when enforcing the current default rules of Content Security Policy Plugin. In particular, new or substantially changed JavaScript is not defined inline and does not call eval to ease future introduction of Content Security Policy (CSP) directives (see documentation).
  • For dependency updates, there are links to external changelogs and, if possible, full differentials.
  • For new APIs and extension points, there is a link to at least one consumer.

Desired reviewers

@mention

Before the changes are marked as ready-for-merge:

Maintainer checklist

  • There are at least two (2) approvals for the pull request and no outstanding requests for change.
  • Conversations in the pull request are over, or it is explicit that a reviewer is not blocking the change.
  • Changelog entries in the pull request title and/or Proposed changelog entries are accurate, human-readable, and in the imperative mood.
  • Proper changelog labels are set so that the changelog can be generated automatically.
  • If the change needs additional upgrade steps from users, the upgrade-guide-needed label is set and there is a Proposed upgrade guidelines section in the pull request title (see example).
  • If it would make sense to backport the change to LTS, be a Bug or Improvement, and either the issue or pull request must be labeled as lts-candidate to be considered.

@comment-ops-bot comment-ops-bot bot added the bug For changelog: Minor bug. Will be listed after features label Jan 27, 2026
@daniel-beck daniel-beck requested a review from Copilot January 27, 2026 23:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a client-side redirect HttpResponse and switches selected administrative monitors to use it so that redirects to jenkins.io documentation continue to work in Chrome when CSP form-action is enforced.

Changes:

  • Added jenkins.util.ClientHttpRedirect, an HttpResponse implementation that performs a redirect via HTML meta refresh and a JS helper, using Util.printRedirect.
  • Exposed a convenience API HttpResponses.clientRedirectTo(String url) for client-side redirects.
  • Updated three administrative monitors (JavaVersionRecommendationAdminMonitor, DefaultCrumbIssuer.ExcludeSessionIdAdministrativeMonitor, and ReverseProxySetupMonitor) to use client-side redirects instead of server-side HttpRedirect / sendRedirect when sending users to external documentation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
core/src/main/java/jenkins/util/ClientHttpRedirect.java Introduces a reusable HttpResponse that renders an HTML+JS redirect page via Util.printRedirect, avoiding CSP form-action issues in Chrome for form submissions redirecting off-site.
core/src/main/java/hudson/util/HttpResponses.java Adds clientRedirectTo(String url) as a public helper returning ClientHttpRedirect, making client-side redirects discoverable to core and plugin code.
core/src/main/java/jenkins/monitor/JavaVersionRecommendationAdminMonitor.java Changes the “learn more” path in doAct to use ClientHttpRedirect for the Java support documentation link while keeping the dismiss path using HttpResponses.forwardToPreviousPage().
core/src/main/java/hudson/security/csrf/DefaultCrumbIssuer.java Refactors the ExcludeSessionIdAdministrativeMonitor#doAct to return HttpResponse, using ClientHttpRedirect for the CSRF documentation link and HttpResponses.forwardToPreviousPage() for dismissal.
core/src/main/java/hudson/diagnosis/ReverseProxySetupMonitor.java Updates the admin monitor action doAct to use ClientHttpRedirect for the broken reverse proxy documentation, preserving the existing internal /manage redirect via HttpResponses.redirectViaContextPath.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

bug For changelog: Minor bug. Will be listed after features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redirects to jenkins.io after form submissions are being rejected in Chrome for violating CSP

1 participant