Skip to content
Blog

Jenkins · CI/CD · RCE

Jenkins: Critical CVEs and Securing Your CI/CD Pipeline

Jenkins, the most widely used CI/CD tool, concentrates critical vulnerabilities enabling code execution and secrets access. Analysis of major CVEs and best practices.

3 min readCVE-2024-23897

Jenkins is the world's most widely deployed continuous integration and continuous delivery (CI/CD) tool. A compromised Jenkins instance grants access to build pipelines, production credentials, SSH keys and infrastructure secrets — an extremely high-value asset for an attacker.

CVE-2024-23897: Arbitrary File Read (CVSS 9.8)

The Jenkins CVE of 2024

In January 2024, CVE-2024-23897 — an arbitrary file read in the Jenkins CLI potentially leading to remote code execution.

Mechanism:

Jenkins uses the args4j library for CLI argument parsing. An option allows reading file contents as arguments (@/path/to/file). By exploiting this feature via unauthenticated CLI requests (depending on configuration), an attacker can read arbitrary files on the Jenkins server.

Targeted sensitive files:

  • /etc/passwd — system user list
  • ~/.ssh/id_rsa — SSH keys for build accounts
  • secrets/master.key — Jenkins master key for decrypting credentials
  • credentials.xml — file containing all encrypted credentials

With the master key and credentials.xml, all Jenkins secrets are decryptable.

Affected versions: Jenkins < 2.442, LTS < 2.426.3
CVSS Score: 9.8

Active Exploitation

Public exploits were available within 48 hours of disclosure. Jenkins honeypots detected mass exploitation attempts specifically targeting secrets/master.key and credentials.xml.

CVE-2019-1003000: Script Security Sandbox Escape (CVSS 9.8)

A Groovy sandbox escape in Jenkins Pipelines. The sandbox is meant to prevent arbitrary code execution in pipelines — this CVE bypassed it via specific Groovy metaprogramming methods.

CVE-2018-1000861: Unauthenticated RCE (CVSS 9.8)

An insecure deserialization in the Stapler library used by Jenkins enabled unauthenticated remote code execution via a crafted HTTP request.

The Groovy Problem in Jenkins

Jenkins pipelines use Groovy — a full JVM language. Even with the sandbox enabled, escapes are regularly discovered. Key recommendations:

Declarative vs Scripted Pipeline

// LESS SECURE — Scripted Pipeline, full Groovy access
node {
    sh "deploy.sh"
}

// MORE SECURE — Declarative Pipeline, restricted syntax
pipeline {
    agent any
    stages {
        stage('Deploy') {
            steps {
                sh 'deploy.sh'
            }
        }
    }
}

Securing Jenkins

1. Disable CLI If Not Needed

# Via UI: Manage Jenkins → Security → Disable CLI

2. Enable Strict Authentication and Authorization

Manage Jenkins → Configure Global Security
→ Security: Project-based Matrix Authorization
→ Only allow authenticated users
→ Disable anonymous access

3. Use Jenkins Credentials Instead of Plaintext Variables

// DANGEROUS
environment {
    AWS_SECRET = "my-plaintext-secret"
}

// CORRECT — use Jenkins credentials
withCredentials([string(credentialsId: 'aws-secret', variable: 'AWS_SECRET')]) {
    sh 'aws deploy ...'
}

4. Never Expose Jenkins Directly to the Internet

Place Jenkins behind a reverse proxy (Nginx/Apache) with strong authentication. Never expose the Jenkins port (8080) directly.

5. Update Jenkins and Its Plugins

# Via Jenkins CLI
java -jar jenkins-cli.jar -s http://localhost:8080 install-plugin <plugin-name>

Jenkins plugins are frequently the source of vulnerabilities — keep them updated.

6. Isolate Build Nodes

Jenkins agents execute potentially untrusted code (developer code, third-party dependencies). Use ephemeral Docker agents:

pipeline {
    agent {
        docker {
            image 'node:18-alpine'
            args '--network none'  // Network isolation
        }
    }
}

7. Enable Audit Logs

Manage Jenkins → Audit Trail Plugin
→ Log all admin actions and builds

Jenkins in 2024: Attack Surface Remains Large

Jenkins has over 1,800 official plugins — each representing a potential attack surface. Plugin CVEs (sometimes critical) are published weekly. If you use Jenkins, CVE monitoring for both the core AND plugins is essential.


Check Jenkins CVEs on cveo.tech — search for jenkins to see the complete vulnerability history.

Know which CVEs hit the versions you run.

Add the product and its version: cveo.tech lists the CVEs that affect it right away, then alerts you by email when a new one affects it — including before NVD has finished its analysis. Free, an account is all it takes.

Every Monday

The week's critical CVEs, in your inbox

One email a week: the CVSS ≥ 9 vulnerabilities published in the last seven days, plus our latest analyses. Nothing else.

Double opt-in by email. Unsubscribe in one click, any time.