#BugBounty — From finding Jenkins instance to Command Execution.Secure your Jenkins Instance!
A publicly accessible Jenkins instance had no authentication, allowing access to the script console and execution of commands. The attacker could read files and potentially modify production code.
Published on medium.com
#### Avinash Jain (@logicbomb1)
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.
Context
This write-up describes how a publicly reachable Jenkins instance belonging to a private bug bounty program was found during reconnaissance and then used to reach remote code execution. The target is referred to only as redacted.com because the program was private and the name could not be disclosed. Jenkins is a CI (continuous integration) tool used to automate the deployment of projects and applications in enterprises. The feature at the centre of the report is the Jenkins web console itself: the dashboard, the user listing, the credential and configuration pages, and above all the script console at /script/, which lets a user run commands on the server.
Setup
The researcher worked against a private bug bounty program, so no accounts, roles or credentials were issued or needed. The only tool named in the report is Censys, used for information gathering. Censys finds IP addresses and gathers information about them, and it helps discover internal tools and assets by analysing SSL certificates, open ports and similar data. The precondition for the whole chain is that the Jenkins instance was exposed to the internet on port 8080 and had no authentication configured over it.
Finding it
Reconnaissance is where every test starts: finding subdomains, open ports and services, and public server IPs. Searching the targeted domain on Censys returned an instance running on port 8080.
The Censys result showed the server name as Jetty:8080. That was the hint: Jenkins commonly runs on Jetty on a standard port such as 80, 443, 8080 or 8443, so a Jetty service on 8080 was worth a closer look. Checking the IP address (shown as X.X.X.X in the report) confirmed that Jenkins was indeed running there.

Opening the instance showed that it was publicly accessible, and the worst part was that no authentication had been set over it. The Jenkins dashboard loaded without any login.
Access to the dashboard alone is already a security concern. As the report notes, an attacker can reach AWS access keys, sensitive API tokens, private keys, server PEM files, IP addresses, usernames and email addresses from it.
Exploitation
Step 1: enumerate the users
Having worked closely with a CI team, the researcher knew several Jenkins paths by heart. The first is /asynchPeople/, which lists all the people who have access to the Jenkins instance.

The report also lists the other paths worth knowing on a Jenkins instance:
/credentials/, it gives access to view credential ids, names.
**/configure/, ** it is a configuration management dashboard for Jenkins.
/configureSecurity/, configuration management for security settings.
/script/, script console to run commands.
Step 2: reach the script console
Without thinking much, the researcher checked whether there was sufficient permission to access /script/, and the permission was there.

Step 3: run commands
In the script console the researcher tried to read /etc/passwd and was able to do so. The same access allowed writing any file and uploading files. The report does not reproduce the exact command used in the console.
Step 4: hook up the Git plugin
Jenkins also has the ability to hook up the Git plugin, which enables running Git commands from the console itself.

Through that, the publicly accessible Jenkins console allowed the researcher to view and modify the production code of the application as well, which made the finding more dangerous.
Root cause
The mistake is a deployment and configuration one: the Jenkins server was reachable from the internet and had no authentication set over it, because the company treated it as an internal application. With anonymous access to the console, the authorisation checks that should protect /script/ never came into play, so the script console was available to anyone who found the IP. The exposure was discoverable because the service advertised itself on port 8080 through its Jetty server name in Censys, which is exactly the kind of signal certificate and port analysis surfaces.
Impact
An unauthenticated attacker who finds such an instance gets the Jenkins dashboard and, from there, whatever the instance holds: AWS access keys, sensitive API tokens, private keys, server PEM files, IP addresses, usernames and email addresses. With access to /script/, the attacker can read files such as /etc/passwd, write and upload files, and run commands on the server, which is remote code execution. With the Git plugin hooked up, the attacker can also view and modify the production code of the application. All of this applies to instances that, like this one, are exposed to the internet without proper authentication.
Fix
The report does not describe the fix itself, only its timeline. The bug was reported to the company on 15 September 2018 and marked fixed the same day; it was re-tested and the fix confirmed on 16 September 2018, and the company rewarded the researcher on 19 September 2018. The lesson the author draws is that companies should not make the Jenkins server accessible over the internet and should set proper authentication over it instead of assuming it is an internal application.
Variants to test
- Search Censys (or a similar service) for the target domain and look for services on 8080, 8443 and other standard ports whose server name is Jetty. A positive result is a host that responds like a Jenkins instance.
- Request the root of any candidate host and check whether the Jenkins dashboard loads without a login. A positive result is the dashboard rendering for an unauthenticated client.
- Request
/asynchPeople/on the instance. A positive result is a list of users with access to Jenkins. - Request
/script/and, if the console loads, try reading a local file such as/etc/passwd. A positive result is the file contents coming back in the console output. - Check whether the Git plugin is available from the console and whether Git commands can be run from it. A positive result is command output from the console that reflects access to the application's source code.
What happened, in plain words
A security researcher was taking part in a private bug bounty programme. A bug bounty programme is an arrangement where a company invites independent researchers to look for security problems in its systems and pays them for reporting what they find. This one was private, meaning only invited people could take part, so the company's name is hidden here and the target is called redacted.com.
While doing the early information gathering that every test starts with, the researcher found a Jenkins server belonging to that company sitting openly on the internet. Jenkins is a piece of software that companies use to build and deploy their own programs automatically. It is normally something only staff inside the company should reach. This one had no login at all, so anyone who found it could walk straight in.
From there the researcher reached a special page inside Jenkins called the script console, which lets a logged-in user run commands on the server itself. That turned a simple case of "a page is open to the internet" into remote code execution, usually shortened to RCE: the ability to make the server run whatever you tell it to. The researcher read a system file, could write or upload files, and could view and modify the company's production source code through a Git plugin. The company fixed it the same day it was reported.
The background you need first
What Jenkins is
Jenkins is a CI tool. CI stands for continuous integration, which is a way of working where every change a developer makes to a program is automatically built and tested, and then automatically deployed to the servers that run it. Instead of a person copying files around by hand, Jenkins does it. Because it does that job, a Jenkins server holds a lot of power and a lot of secrets: it needs the keys to log in to other servers, the passwords to deploy things, and access to the source code itself.
That is why the report calls access to it a security concern in itself. Think of Jenkins as the caretaker of a building who holds every key: if a stranger gets hold of the caretaker's key ring, they do not just get into one room, they get into all of them.
What reconnaissance is
Every hack and every penetration test starts with reconnaissance, which simply means gathering information before touching anything. The report lists some of its parts: finding subdomains (extra names under a company's main domain, like build.example.com under example.com), finding open ports and services, and finding public server IPs. An IP address is the number that identifies a machine on the internet, the way a street address identifies a house. A port is a numbered door on that machine: one door might be a website, another might be a mail server. Port 8080 is a very common door for web applications that are not the company's main public website.
The one tool used: Censys
Censys is a search engine, but instead of searching web pages it searches machines that are reachable on the internet. It finds IP addresses and gathers information about them, and it helps discover internal tools and assets by analysing SSL certificates, open ports and similar data. An SSL certificate is the small file a website presents to prove its identity and to encrypt traffic; certificates often contain the server's name and other clues, which is why a search engine like Censys can use them to spot things a company may not realise are public.
Finding it
The researcher searched the targeted domain on Censys and got back an instance running on port 8080.
The Censys result showed the server name as Jetty:8080. Jetty is a piece of software that serves web pages, and Jenkins commonly runs on top of Jetty. Jenkins also commonly sits on a standard port such as 80, 443, 8080 or 8443. So a Jetty service answering on 8080 was a strong hint that Jenkins might be behind it. This is the reasoning step worth copying: the tool did not say "Jenkins here", it said "Jetty on 8080", and the researcher knew what that combination usually means.
Checking the IP address, shown in the report as X.X.X.X, confirmed that Jenkins was indeed running there.

Opening the instance showed it was publicly accessible, and the worst part was that no authentication had been set over it. Authentication means proving who you are, normally with a username and password. With none configured, there was nothing to prove: the Jenkins dashboard loaded with no login at all.
Getting the dashboard alone is already a security concern. As the report notes, from it an attacker can reach AWS access keys, sensitive API tokens, private keys, server PEM files, IP addresses, usernames and email addresses. A few of those terms in plain words: AWS access keys are the credentials that let a program use Amazon's cloud services, an API token is a long random string that acts like a password for a program rather than a person, a private key is the secret half of a cryptographic key pair used to log in to servers, and a PEM file is a common file format for storing such keys. Any one of those can be enough to get into other systems, which is why the report links to an article about how much damage a compromised Jenkins can cause.
Exploitation, step by step
Step 1: list the users
Having worked closely with a CI team, the researcher knew several Jenkins addresses by heart. The first is /asynchPeople/, which lists all the people who have access to the Jenkins instance. A URL path like this is just the part of the address after the domain name; typing it into the browser's address bar takes you to that page.

Knowing who has access is useful because those names and accounts are themselves information an attacker can use, and because it shows how the instance is used inside the company.
The report also lists the other paths worth knowing on a Jenkins instance:
/credentials/, it gives access to view credential ids, names.
**/configure/, ** it is a configuration management dashboard for Jenkins.
/configureSecurity/, configuration management for security settings.
/script/, script console to run commands.
In plain words, each of those is a page on the Jenkins website:
/credentials/is the page where Jenkins stores the logins it uses to talk to other systems. Even seeing the ids and names tells you what the company connects to./configure/is the settings page for the whole Jenkins installation./configureSecurity/is the settings page for who is allowed to do what./script/is the script console, the dangerous one: a box where you type code and Jenkins runs it on the server.
Step 2: reach the script console
Without thinking much, the researcher checked whether there was sufficient permission to access /script/, and the permission was there.

This is the turning point of the whole report. Up to here the problem was "a private tool is visible to the public". The script console changes the kind of problem: it is a feature designed to let an administrator run code on the server, so if an outsider can open it, the outsider effectively becomes the administrator. Authorisation, which means being allowed to do something once you are identified, had never been applied because nobody had to identify themselves in the first place.
Step 3: run commands
In the script console the researcher tried to read /etc/passwd and was able to do so. /etc/passwd is a standard file on Linux and similar systems that lists the user accounts on the machine. It is the classic first file to read when testing whether you can read files at all, because it is always there and its contents are recognisable. The report does not reproduce the exact command used in the console.
The same access allowed writing any file and uploading files. Reading a file proves you can see secrets; writing a file proves you can change the system, for example by placing a program there and running it. That combination is what makes this remote code execution rather than just an information leak.
Step 4: hook up the Git plugin
Jenkins also has the ability to hook up the Git plugin, which enables running Git commands from the console itself. Git is the tool developers use to keep track of changes to source code, and a plugin is an add-on that gives Jenkins extra abilities. If the plugin is installed and reachable from the console, the console can talk to the code repository.

Through that, the publicly accessible Jenkins console allowed the researcher to view and modify the production code of the application as well, which made the finding more dangerous. Production code is the code that actually runs the live service customers use, so being able to change it means being able to change what the company's product does.
Why it was possible
The mistake is a deployment and configuration one. The Jenkins server was reachable from the internet and had no authentication set over it, because the company treated it as an internal application, something only staff on the company network would ever open. With anonymous access to the console, the permission checks that should protect /script/ never came into play, so the script console was available to anyone who found the IP.
The exposure was discoverable because the service advertised itself on port 8080 through its Jetty server name in Censys. That is exactly the kind of signal certificate and port analysis surfaces: the company never announced the server, but the server answered questions about itself to anyone who asked.
What the impact was
An unauthenticated attacker, meaning one with no account and no password, who finds such an instance gets the Jenkins dashboard and, from there, whatever the instance holds: AWS access keys, sensitive API tokens, private keys, server PEM files, IP addresses, usernames and email addresses. With access to /script/, the attacker can read files such as /etc/passwd, write and upload files, and run commands on the server, which is remote code execution. With the Git plugin hooked up, the attacker can also view and modify the production code of the application. All of this applies to instances that, like this one, are exposed to the internet without proper authentication.
How it was fixed
The report does not describe the fix itself, only its timeline:
| Date | What happened |
|---|---|
| 15 September 2018 | Bug reported to the company |
| 15 September 2018 | Bug marked fixed |
| 16 September 2018 | Re-tested and fix confirmed |
| 19 September 2018 | Researcher rewarded by the company |
The lesson the author draws is that companies should not make the Jenkins server accessible over the internet and should set proper authentication over it, instead of assuming it is an internal application.
How to check for the same thing yourself
These are the same checks the researcher made, written as a list you can follow with nothing but a browser. Only test systems you are allowed to test: your own, or a programme that has invited you.
- Search Censys, or a similar service, for the target domain and look for services on 8080, 8443 and other standard ports whose server name is Jetty. A positive result is a host that responds like a Jenkins instance.
- Request the root of any candidate host and check whether the Jenkins dashboard loads without a login. A positive result is the dashboard rendering for an unauthenticated client.
- Request
/asynchPeople/on the instance. A positive result is a list of users with access to Jenkins. - Request
/script/and, if the console loads, try reading a local file such as/etc/passwd. A positive result is the file contents coming back in the console output. - Check whether the Git plugin is available from the console and whether Git commands can be run from it. A positive result is command output from the console that reflects access to the application's source code.
Glossary
- Authentication: proving who you are, usually with a username and password, before a system lets you in.
- Authorisation: what a system lets you do once it knows who you are.
- Bug bounty programme: an arrangement where a company invites researchers to look for security problems and pays for reports.
- Private programme: a bug bounty programme open only to invited researchers, often with the company name kept secret.
- Reconnaissance: the information gathering done before testing, such as finding subdomains, open ports and public IPs.
- Subdomain: an extra name under a company's main domain, such as
build.example.comunderexample.com. - IP address: the number that identifies a machine on the internet, like a street address.
- Port: a numbered door on a machine through which a particular service is reached; 8080 is a common one for web applications.
- Jenkins: a CI tool that automates building, testing and deploying software, and therefore holds many secrets and much power.
- CI (continuous integration): a way of working where every code change is automatically built, tested and deployed.
- Censys: a search engine for machines reachable on the internet, which finds IP addresses and gathers information about them from certificates, open ports and similar data.
- SSL certificate: a small file a website presents to prove its identity and encrypt traffic; it often reveals the server's name.
- Jetty: software that serves web pages, commonly used underneath Jenkins.
- Dashboard: the main page of a web application after you open it.
- AWS access keys: credentials that let a program use Amazon's cloud services.
- API token: a long random string that acts like a password for a program rather than a person.
- Private key: the secret half of a cryptographic key pair, used to log in to servers.
- PEM file: a common file format for storing keys and certificates.
- URL path: the part of a web address after the domain name, such as
/script/. /asynchPeople/: a Jenkins page listing all the people who have access to the instance./credentials/: a Jenkins page showing the ids and names of stored credentials./configure/: the Jenkins settings page for the whole installation./configureSecurity/: the Jenkins settings page for security and permissions./script/: the Jenkins script console, a page where typed code is run on the server.- Script console: a feature that lets an administrator run code on the Jenkins server; dangerous in the wrong hands.
/etc/passwd: a standard file on Linux and similar systems listing the machine's user accounts.- Remote code execution (RCE): making a server run commands or code of your choosing from a distance.
- Git: the tool developers use to track changes to source code.
- Plugin: an add-on that gives Jenkins extra abilities, such as talking to Git.
- Production code: the code that actually runs the live service customers use.
- Anonymous access: using a system with no account and no login at all.
- Unauthenticated attacker: someone with no account or credentials who is nevertheless able to act against a system.