Skip to content
Misconfiguration Write-up Beginner

From Public Jenkins Exposure to Remote Code Execution

A publicly reachable Jenkins instance allowed anyone to self-register, and new accounts were granted access to the Script Console, which runs Groovy code inside the server process. An attacker could create an account and execute operating-system commands, leading to remote code execution on the host.

medium.com

Published on medium.com

Information Security

Prasannasalunkhe, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Jenkins is a widely deployed automation server used for CI/CD. Among its features is a built-in Script Console that executes Groovy code inside the Jenkins server process. Access to that console is effectively operating-system-level command execution on the Jenkins host, so it is normally restricted to trusted administrators.

This write-up describes an internet-exposed Jenkins instance found during an authorised bug bounty engagement. The finding was not a software vulnerability in Jenkins itself: the instance appeared fully patched. The risk came from the combination of public exposure, enabled self-registration and excessive privileges granted to newly created accounts.

Setup

The researcher was reviewing internet-exposed assets associated with an authorised bug bounty target. Shodan was used to identify publicly reachable services that might have been missed during normal asset discovery. The results included multiple Jenkins instances hosted within the organisation's in-scope infrastructure.

Two instances are relevant:

  1. One appeared fully patched and did not expose any obvious attack path.
  2. A second had a configuration issue that changed the risk significantly.

No specific Jenkins version, hostname, port or account details are given in the report. The attack required the second instance to be reachable from the public internet, with self-registration enabled and excessive privileges for new accounts.

Finding it

The Jenkins server was publicly accessible over the internet and presented a standard login interface. What stood out was an option allowing new users to register directly from the login page. Self-registration on an externally reachable Jenkins deployment is unusual, and it meant that an unauthenticated external user could obtain an authenticated account without any approval step.

Exploitation

Step 1: Register a test account

The researcher created a test account from the login page to determine what level of access a newly registered user would receive. Registration completed successfully.

Step 2: Authenticate and inspect the granted access

After authenticating, the account was granted access to information that should not normally be exposed to an untrusted user, including:

  • Existing usernames
  • Jenkins job information
  • Build history
  • Internal project details
  • Administrative functionality

At this point the issue was already significant: an unauthenticated external user could create an account and gain visibility into the Jenkins environment. The available permissions suggested the impact might extend beyond information disclosure.

Step 3: Reach the Script Console

The Jenkins Script Console allows Groovy code to execute inside the Jenkins server process. The endpoint was accessible at:

Text
/script

After opening the Script Console, the researcher tested whether the newly created account was permitted to execute Groovy expressions. It was.

Step 4: Execute an operating-system command

The next step was to determine whether those expressions could interact with the underlying operating system. A basic system command was executed through Groovy:

Text
"ls /".execute().text

The expression runs ls / as a process on the Jenkins host and returns its standard output as text. The response returned the contents of the server's root filesystem, which confirmed the impact: command execution on the underlying host.

Root cause

The primary issue was not a software vulnerability but an authorisation and deployment configuration problem. Three conditions created the attack path:

  1. Jenkins was publicly reachable. The service was exposed directly to the internet and could therefore be discovered through internet-wide scanning platforms such as Shodan.
  2. Account registration was enabled. Any external user could create an authenticated account without prior approval.
  3. Newly created users had excessive privileges. The resulting account could access functionality that should have been restricted to trusted administrators.

The Script Console was particularly dangerous because access to it effectively provides execution privileges on the Jenkins host. The vulnerability did not depend on exploiting an outdated Jenkins version; the installation itself could be fully patched while still exposing critical risk. The difference between the two instances encountered during testing was configuration, not patch level.

Impact

The issue progressed from an exposed Jenkins interface to full Remote Code Execution on the underlying host. The attack path was straightforward:

Text
Internet-exposed Jenkins        ↓Self-registration enabled        ↓Attacker creates an account        ↓Account receives excessive permissions        ↓Jenkins Script Console accessible        ↓Groovy executes operating-system commands        ↓Remote Code Execution

Because Jenkins commonly interacts with source-control systems, artifact repositories, deployment infrastructure and cloud environments, compromise of the Jenkins host may extend well beyond the server itself.

Fix

The report lists remediation steps for the affected environment rather than describing changes that were made:

  • Disable public self-registration unless explicitly required.
  • Restrict Jenkins administrative privileges using role-based access controls.
  • Limit Script Console access to trusted administrators.
  • Avoid exposing Jenkins directly to the public internet.
  • Place administrative services behind controlled network access.
  • Review existing Jenkins users and permissions.
  • Audit previous Script Console activity.
  • Rotate credentials and secrets accessible from the Jenkins environment.
  • Review build pipelines for exposed tokens, API keys, deployment credentials and SSH keys.

Where remote access is required, the report suggests controls such as VPN access, identity-aware proxies, network allowlists or zero-trust access mechanisms. It also stresses that authentication alone is not sufficient: a login page does not make a service secure if unrestricted registration lets anyone become an authenticated user, and newly created accounts should not inherit administrative capabilities.

Variants to test

  • Self-registration on other Jenkins instances. Look for a registration option on the login page of internet-exposed Jenkins servers. A positive result is a successful registration followed by access to usernames, job information, build history or administrative functionality.
  • Script Console access for low-privileged accounts. After obtaining any low-privileged account, request /script and attempt a Groovy expression. A positive result is execution of an expression such as "ls /".execute().text returning filesystem contents.
  • Discovery beyond standard ports. Administrative interfaces do not need to run on port 80 or 443 to be discoverable. Search Shodan for Jenkins banners, protocols, certificates and ports, and treat any internet-reachable service as discoverable. A positive result is a reachable Jenkins login page on an internet-facing service.
  • Patch level versus configuration. Compare instances that appear current. A positive result is a fully patched instance that still grants excessive permissions to new or low-privileged accounts.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

What happened, in plain words

A security researcher was looking for weaknesses in a company's systems, with permission, as part of a bug bounty programme. A bug bounty is an arrangement where an organisation invites outside people to test its systems and report problems, often in exchange for a reward. The researcher used a search engine for internet-connected devices called Shodan to find machines belonging to the company that were visible from the open internet. Among them were several Jenkins servers.

Jenkins is a popular piece of software that automates building and releasing software. Think of it as a robot factory worker that, on command, fetches code, compiles it, runs tests and ships the result. Because it does all that, it holds powerful keys to the company's other systems.

One Jenkins server looked fully up to date and offered no obvious way in. A second one had a configuration issue that changed the risk significantly. Anyone on the internet could create an account on it, and a brand-new account was given far more power than a stranger should ever have. That power included a built-in tool that runs commands on the server itself. The researcher used it to run a simple command and list the server's root filesystem. That is remote code execution: making a machine you do not own run commands of your choosing, from far away.

The important lesson is that the software was not out of date. The danger came from how it was configured and how it was exposed to the internet.

Background: what Jenkins is and why it matters

Jenkins is an automation server used for CI/CD. CI/CD stands for continuous integration and continuous delivery: the practice of automatically building, testing and releasing software every time a developer changes the code. Instead of a person copying files to a server by hand, Jenkins does it, repeatedly and on a schedule or on every code change.

To do that job, Jenkins needs access to a lot of things: the place where source code lives, the place where built files are stored, the servers where software is deployed, and often cloud accounts. So a Jenkins server is a bit like the key cabinet in an office building. It may not look important from the outside, but whoever controls it can reach many locked doors.

Jenkins also ships with a feature called the Script Console. It lets an administrator type small programs written in a language called Groovy and run them inside the Jenkins process. Groovy is a programming language that runs on the Java platform. The Script Console is meant for trusted administrators doing maintenance. In practice, anything that runs inside the Jenkins process can also ask the operating system underneath to run commands. That makes the Script Console equivalent to a command line on the server, which is why access to it is normally locked down tightly.

This write-up is about an internet-exposed Jenkins instance found during an authorised bug bounty engagement. The finding was not a software vulnerability in Jenkins itself: the instance appeared fully patched. The risk came from the combination of public exposure, enabled self-registration and excessive privileges granted to newly created accounts.

Setup: how the researcher found the servers

The researcher was reviewing internet-exposed assets associated with an authorised bug bounty target. An asset here means any system the company owns that is in scope for testing. Shodan was used to identify publicly reachable services that might have been missed during normal asset discovery. Shodan is a search engine that constantly scans the internet and records what it finds: which machines answer on which ports, what software they announce, what security certificates they present. It is like a directory of every front door on the internet that is open and what kind of lock it has.

Normal asset discovery means the company's own inventory of its machines. It is easy to forget a test server or a machine someone set up quickly, and Shodan finds those forgotten doors.

The results included multiple Jenkins instances hosted within the organisation's in-scope infrastructure. Two instances are relevant:

  1. One appeared fully patched and did not expose any obvious attack path.
  2. A second had a configuration issue that changed the risk significantly.

No specific Jenkins version, hostname, port or account details are given in the report. The attack required the second instance to be reachable from the public internet, with self-registration enabled and excessive privileges for new accounts.

Finding it: the login page that let strangers in

The Jenkins server was publicly accessible over the internet and presented a standard login interface. A login interface is the username and password box you see on almost any website.

What stood out was an option allowing new users to register directly from the login page. Self-registration means the site lets visitors create their own account, like a forum where anyone can sign up. On a Jenkins server that is reachable from the whole internet, that is unusual. It meant that an unauthenticated external user, someone with no account and no relationship with the company, could obtain an authenticated account without any approval step. Authenticated simply means logged in and recognised by the system.

Why did the researcher care? Because a login page creates an impression of safety. If only approved people can log in, the page is a barrier. If anyone can sign up, the barrier is a formality. The researcher wanted to see what a brand-new stranger's account could actually do.

Exploitation

Step 1: Register a test account

The researcher created a test account from the login page to determine what level of access a newly registered user would receive. Registration completed successfully. That single fact is the first half of the problem: the door opened for a stranger.

Step 2: Authenticate and inspect the granted access

After authenticating, the account was granted access to information that should not normally be exposed to an untrusted user, including:

  • Existing usernames
  • Jenkins job information
  • Build history
  • Internal project details
  • Administrative functionality

Each of these deserves a moment. Existing usernames are the names of real staff accounts, useful to anyone planning to guess passwords. Jenkins job information describes the automated tasks the server runs. Build history shows what was built, when, and often whether it succeeded, which reveals how the company works and when it releases software. Internal project details are names and descriptions of private work. Administrative functionality means parts of the interface meant for people who manage the server.

At this point the issue was already significant: an unauthenticated external user could create an account and gain visibility into the Jenkins environment. The available permissions suggested the impact might extend beyond information disclosure. Information disclosure means leaking data that should stay private. The researcher suspected the account could do more than read.

Step 3: Reach the Script Console

The Jenkins Script Console allows Groovy code to execute inside the Jenkins server process. The endpoint was accessible at:

Text
/script

An endpoint is a specific address on a website, the part after the domain name. If the site were a building, the endpoint is the room number. Here, /script is the room where the Script Console lives. The researcher opened it and tested whether the newly created account was permitted to execute Groovy expressions. It was.

That is the second half of the problem. A stranger's account could reach the room where programs are run on the server. Normally that room should be locked to a handful of trusted administrators.

Step 4: Execute an operating-system command

The next step was to determine whether those expressions could interact with the underlying operating system. The operating system is the software that manages the machine itself, such as Linux or Windows. A basic system command was executed through Groovy:

Text
"ls /".execute().text

Line by line, in plain words:

  • "ls /" is a piece of text containing a command. ls is the standard Linux command that lists the contents of a folder, and / means the very top of the filesystem, the root folder from which everything else hangs.
  • .execute() tells Groovy to take that text and actually run it as a program on the machine, rather than just treat it as words.
  • .text takes whatever the program printed and returns it as text, so it can be displayed in the browser.

In everyday terms, it is like writing a note that says "list everything in the building's lobby" and handing it to a robot that follows instructions literally. The expression runs ls / as a process on the Jenkins host and returns its standard output as text. The response returned the contents of the server's root filesystem, which confirmed the impact: command execution on the underlying host.

That is the moment the finding changed from "a stranger can read things" to "a stranger can run commands on the machine".

Root cause: why it worked

The primary issue was not a software vulnerability but an authorisation and deployment configuration problem. Authorisation means deciding what a logged-in user is allowed to do, as opposed to authentication, which is deciding who they are. Three conditions created the attack path:

  1. Jenkins was publicly reachable. The service was exposed directly to the internet and could therefore be discovered through internet-wide scanning platforms such as Shodan.
  2. Account registration was enabled. Any external user could create an authenticated account without prior approval.
  3. Newly created users had excessive privileges. The resulting account could access functionality that should have been restricted to trusted administrators.

Think of it as a building where the front door is on a busy street, the reception desk hands a keycard to anyone who asks, and that keycard opens the server room. No single step is exotic. Together they are a complete path in.

The Script Console was particularly dangerous because access to it effectively provides execution privileges on the Jenkins host. The vulnerability did not depend on exploiting an outdated Jenkins version; the installation itself could be fully patched while still exposing critical risk. The difference between the two instances encountered during testing was configuration, not patch level.

Impact

The issue progressed from an exposed Jenkins interface to full Remote Code Execution on the underlying host. Remote Code Execution, often shortened to RCE, means an attacker can make the machine run commands of their choosing from somewhere else. The attack path was straightforward:

Text
Internet-exposed Jenkins        ↓Self-registration enabled        ↓Attacker creates an account        ↓Account receives excessive permissions        ↓Jenkins Script Console accessible        ↓Groovy executes operating-system commands        ↓Remote Code Execution

Read top to bottom, that diagram is the whole story: each arrow is one small step that was possible because of the step above it. No step required breaking encryption or guessing a password.

Because Jenkins commonly interacts with source-control systems, artifact repositories, deployment infrastructure and cloud environments, compromise of the Jenkins host may extend well beyond the server itself. A source-control system stores the code. An artifact repository stores the built files. Deployment infrastructure is where software is published. Cloud environments are the rented computers and services the company runs. If Jenkins holds keys to all of those, taking over Jenkins can mean reaching all of them.

Fix: what should change

The report lists remediation steps for the affected environment rather than describing changes that were made:

  • Disable public self-registration unless explicitly required.
  • Restrict Jenkins administrative privileges using role-based access controls.
  • Limit Script Console access to trusted administrators.
  • Avoid exposing Jenkins directly to the public internet.
  • Place administrative services behind controlled network access.
  • Review existing Jenkins users and permissions.
  • Audit previous Script Console activity.
  • Rotate credentials and secrets accessible from the Jenkins environment.
  • Review build pipelines for exposed tokens, API keys, deployment credentials and SSH keys.

A few of those terms need unpacking. Role-based access controls mean giving people permissions according to their role, so a developer gets developer rights and only administrators get administrator rights. To audit means to review records of what happened, in this case who used the Script Console and when. To rotate credentials means to replace passwords and keys with new ones, because the old ones may have been seen by someone else. A token or API key is a long secret string that software uses instead of a password to prove its identity. An SSH key is a similar secret used to log in to servers securely. A build pipeline is the sequence of automated steps Jenkins runs to build and release software.

Where remote access is required, the report suggests controls such as VPN access, identity-aware proxies, network allowlists or zero-trust access mechanisms. A VPN is a private tunnel into a network, so the service is not visible to the open internet. An identity-aware proxy sits in front of a service and checks who you are before letting you through. A network allowlist means only certain known addresses may connect. Zero-trust access means every request is checked, rather than trusting anything just because it is inside the network.

It also stresses that authentication alone is not sufficient: a login page does not make a service secure if unrestricted registration lets anyone become an authenticated user, and newly created accounts should not inherit administrative capabilities.

Variants to test

These are the patterns worth checking on other systems, described so a beginner can follow the reasoning.

  • Self-registration on other Jenkins instances. Look for a registration option on the login page of internet-exposed Jenkins servers. A positive result is a successful registration followed by access to usernames, job information, build history or administrative functionality.
  • Script Console access for low-privileged accounts. After obtaining any low-privileged account, request /script and attempt a Groovy expression. A positive result is execution of an expression such as "ls /".execute().text returning filesystem contents.
  • Discovery beyond standard ports. Administrative interfaces do not need to run on port 80 or 443 to be discoverable. A port is a numbered channel on a machine; web traffic normally uses 80 for plain HTTP and 443 for encrypted HTTPS. Search Shodan for Jenkins banners, protocols, certificates and ports, and treat any internet-reachable service as discoverable. A banner is the greeting a service sends when you connect, which often names the software. A positive result is a reachable Jenkins login page on an internet-facing service.
  • Patch level versus configuration. Compare instances that appear current. A positive result is a fully patched instance that still grants excessive permissions to new or low-privileged accounts.

Glossary

  • Asset: any system or service owned by an organisation that is in scope for testing.
  • Audit: reviewing records of past activity to see what happened.
  • Authentication: proving who you are, usually by logging in.
  • Authorisation: deciding what a logged-in user is allowed to do.
  • Banner: the greeting a network service sends when a client connects, often revealing the software name and version.
  • Bug bounty: a programme where an organisation invites outside researchers to test its systems and report problems, often for a reward.
  • Build history: the record of past automated builds, including when they ran and whether they succeeded.
  • Build pipeline: the sequence of automated steps used to build, test and release software.
  • CI/CD: continuous integration and continuous delivery, the practice of automatically building, testing and releasing software.
  • Configuration: the settings chosen when installing and running software, as opposed to the software's own code.
  • Credential: a secret used to prove identity, such as a password, token or key.
  • Endpoint: a specific address on a website, the part after the domain name.
  • Groovy: a programming language that runs on the Java platform, used by the Jenkins Script Console.
  • Information disclosure: leaking data that should have stayed private.
  • Jenkins: an automation server used to build, test and release software.
  • Job: a task configured in Jenkins, such as building a project.
  • Least privilege: the principle of giving each user or account only the permissions it actually needs.
  • Network allowlist: a list of addresses that are permitted to connect, with everything else refused.
  • Operating system: the software that manages a machine, such as Linux or Windows.
  • Patch level: how up to date a piece of software is with security fixes.
  • Port: a numbered channel on a machine that a service listens on; 80 and 443 are the usual web ports.
  • Remote Code Execution (RCE): making a machine run commands of your choosing from somewhere else.
  • Role-based access control: giving permissions according to a user's role, such as developer or administrator.
  • Rotate: replace a secret such as a password or key with a new one.
  • Script Console: a Jenkins feature that runs Groovy code inside the Jenkins process.
  • Self-registration: a setting that lets visitors create their own accounts without approval.
  • Shodan: a search engine that indexes internet-connected devices and services.
  • SSH key: a secret used to log in to servers securely.
  • Token / API key: a long secret string that software uses instead of a password to prove its identity.
  • Unauthenticated: not logged in, with no account recognised by the system.
  • VPN: a private tunnel into a network, hiding services from the open internet.
  • Zero-trust access: an approach where every request is checked, rather than trusting anything inside the network by default.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.