fix: insecure-document-method-29 – prevent potential XSS vulnerability#26163
fix: insecure-document-method-29 – prevent potential XSS vulnerability#26163girichinna27 wants to merge 6 commits intojenkinsci:masterfrom
Conversation
…ctory-disallow-doctype-de-110-qXI6KU9kjQ fix: semgrep-documentbuilderfactory-disallow-doctype-decl-missing
…-method-29-8L13xoquS0 fix: semgrep-insecure-document-method
|
Missing required label for changelog. Requires at least 1 of: bug, developer, dependencies, internal, localization, major-bug, major-rfe, rfe, regression-fix, removed, skip-changelog. Found: . You can add the required label by adding a comment with the following text: |
|
Please don't sabotage yourself as a new contributor. Be sure that you:
As far as I can tell, you skipped all of those items in your pull request. If you're not willing to do those things, we'll close the pull request. In the interim, I'm marking the pull request as draft so that others do not waste their time reviewing it. |
There was a problem hiding this comment.
Pull request overview
This PR addresses security hardening in the Jenkins core UI and SVG symbol handling, primarily to mitigate XSS and XML-based attacks.
Changes:
- Replaces
innerHTMLwithtextContentwhen displaying server error responses in the plugin manager UI to avoid injecting unsanitized HTML into the DOM. - Configures the
DocumentBuilderFactoryused for loading SVG symbols to disallow XML DOCTYPE declarations, reducing exposure to XML entity expansion and related parser attacks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| core/src/main/resources/hudson/PluginManager/_installed.js | Stops writing arbitrary HTML into the #needRestart element by using textContent for error messages, addressing the Semgrep XSS finding. |
| core/src/main/java/org/jenkins/ui/symbol/Symbol.java | Tightens XML parsing for SVG symbols by disallowing DOCTYPE declarations on the DocumentBuilderFactory used in loadSymbol. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
daniel-beck
left a comment
There was a problem hiding this comment.
This pull request lacks motivation for the XXE change, and the XSS change does not look like it was tested.
| if (!rsp.ok) { | ||
| rsp.text().then((responseText) => { | ||
| document.getElementById("needRestart").innerHTML = responseText; | ||
| document.getElementById("needRestart").textContent = responseText; |
| DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); | ||
| try { | ||
| dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); | ||
| dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); |
There was a problem hiding this comment.
Why? This is redundant per https://semgrep.dev/docs/cheat-sheets/java-xxe#3a-documentbuilderfactory.
|
If this addresses a real vulnerability, you just disclosed it to the world, contrary to our published reporting guidelines. Why? If it doesn't, what does this PR accomplish? |
…-FiSEAFraBe fix: semgrep-eval-detected
|
The new commit does nothing to address previous feedback, instead it scope-creeps this PR with a change that will significantly negatively impact the plugin ecosystem and not actually improve security. We're done here. |

Hi Maintainers 👋,
This Pull Request addresses a Semgrep security finding related to the unsafe use of DOM manipulation methods that may lead to Cross-Site Scripting (XSS) vulnerabilities.
🔍 Issue Details
✅ Fix Applied
Replaced the unsafe document method usage with a safer alternative that avoids direct HTML injection (for example, using textContent or properly sanitized DOM updates).
🎯 Impact
This change mitigates the risk of XSS attacks by ensuring that user-controlled data is not injected into the DOM using insecure document methods.
The issue was identified and remediated using AI-Guardian, a security analysis tool developed by my company OpsMx.
Thanks for your time and review 🙏