How i got my First Bug Bounty in Intersting Target (LFI to SXSS)
Published on ph-hitachi.medium.com
Ph.Hitachi
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
The target was a private HackerOne program whose scope included an online IDE, described by the researcher as similar to VS Code or Visual Studio Code. The public repositories the target was built on were identified as:
The program's scope description, quoted in the write-up, framed the asset as follows:
ide.redacted.com is anonline IDE*, available to the public for developing test Applications. Its primary purpose is to facilitate bootcamps, it is not a intended for production use, or for anything other than one-off test scenarios.*
The shell terminal is deliberately available to everyone, without authentication required, because there is no sensitive information to be revealed.
The shell is also resource limited, does not accept inbound network connections, and the shell session will automatically expire. It is not designed as a long-term store of data.
The shell runs in a container. It should not be possible to access the host operating system, however if you find a way to break out of the container and compromise the host then we would like to hear about it :-)
So the terminal being open to anyone was an explicit design decision, not a bug. The interesting question was whether the file handling around that terminal could be turned into something with impact.
Setup
No accounts, roles or special tooling are described. The researcher opened every in-scope asset in a Chrome tab and worked from the browser. The only precondition was the publicly reachable IDE with its unauthenticated terminal.
Finding it
One of the in-scope assets stood out: an online IDE modelled on VS Code. The researcher first explored the terminal, checking the gcc version and the kernel version, and tried to get root access. That attempt failed. The terminal itself was open to anyone, so any command could be executed in it, including a reverse shell, but per the scope description this was expected because the target held no sensitive information.
The researcher then created a file named xss.html containing an XSS payload, but running it produced no visible output.
Looking at the source code revealed something more interesting: a full directory path was called in the URL after the hashes.
/usr/local/****/src/browser/media/favicon.ico
That is a full path inside the server. Opening it in another tab and changing the URL to point at /etc/passwd returned the file successfully. That confirmed a Local File Inclusion vulnerability.
At this point the researcher re-read the program policy, having previously lost reputation for not doing so, and found the scope text quoted above. The terminal was deliberately open, so a plain LFI reachable through the terminal functionality would not be accepted without impact.
Exploitation
Step 1: Confirm file read
Changing the path in the URL from the media file to the system file returned the contents of /etc/passwd. The report shows no request or response for this step, only that the file was successfully called in the URL.
Step 2: Try a PHP webshell
Since internal files could be read and files could be created through the terminal, the next idea was to create a file with a .php extension as a webshell. That attempt always returned:
Content-type: text/plain
so the PHP file could not be executed. The researcher notes this made little sense given that everything was already possible in the terminal.
Step 3: Reuse the XSS file
The first file created, xss.html with the XSS payload, was still on the server. The researcher copied the location of that file as an internal file and pasted that location in place of /etc/passwd in the URL. The alert(document.domain) payload executed, confirming Stored Cross-site Scripting.
The report does not include the exact payload, the exact URL used, or the response body for this step.
Step 4: Report
The Stored XSS was reported. After the report, the program removed the asset from its bounty scope.
Root cause
The report does not describe the server-side code, so the exact mistake is not stated. What the behaviour implies is that the same URL parameter that served static media from a path under the application directory accepted arbitrary filesystem paths, with no restriction to the intended media directory. Because the terminal let any visitor write files into that filesystem, an attacker could plant an HTML file with script in it and then request it through the file-serving path, which is what turned the file read into stored XSS. The Content-type: text/plain response for .php files suggests some content-type handling existed, but it did not prevent the HTML file's script from executing. Whether that handling was a deliberate defence or an accident is not stated.
Impact
The confirmed impact was stored cross-site scripting: the researcher's own payload executed when the crafted URL was opened. The report does not describe who else used the IDE, whether sessions or credentials were exposed, or what an attacker could reach through the XSS. The LFI on its own was not treated as impactful, because the scope explicitly said the terminal was open by design and held no sensitive information. The program's own scope text set the bar for a serious finding at breaking out of the container and compromising the host; the report does not claim that was achieved.
Fix
The only change mentioned is that the program removed the asset from its bounty scope after the report. A fix would be to constrain the file-serving path to the intended media directory and to serve user-written files with a content type and headers that prevent them from executing as pages.
Variants to test
- Path traversal in static file parameters: replace a media path with
../../../../etc/passwdand look for system file contents in the response. - Absolute path acceptance: supply a full path such as
/etc/passwddirectly where a relative asset path is expected. A positive result is the file contents returned. - Content-type bypass: upload or create files with
.html,.svgand.phpextensions and request each one. A positive result is HTML or SVG returned with a type the browser renders and executes, rather thantext/plain. - Write-then-read chains: wherever an unauthenticated terminal or upload feature exists, plant a file with a script payload and request it through the file-serving endpoint. A positive result is the payload executing in the browser.
- Container escape: per the scope text, try to reach the host operating system from the shell. A positive result is access to host files or processes outside the container.
What happened, in plain words
A security researcher found a bug in a website that lets people write and run code in their browser, a bit like an online version of Visual Studio Code. The site had a terminal (a command line) that anyone could use without logging in. That was intentional, but the researcher discovered that the same part of the site that served images could be tricked into showing any file on the server, including system files. That is called Local File Inclusion (LFI). The researcher then used the open terminal to create a file containing JavaScript code, and then used the file-reading trick to make that file run in a browser. That turned the file read into a Stored Cross-site Scripting (XSS) vulnerability. The researcher reported it and a $250 bounty was awarded. After the report, the program removed that asset from its bounty scope.
The target and the rules
The researcher was taking part in a private bug bounty program on HackerOne. A bug bounty program is a scheme where organisations pay people to find and report security problems in their systems. "Private" means only invited researchers can participate.
One of the assets in scope (the list of things you are allowed to test) was an online IDE. An IDE (Integrated Development Environment) is a program that helps you write and run code. This one was similar to VS Code or Visual Studio Code, which are popular code editors. The researcher identified the public repositories the target was built on:
A repository (repo) is a place where source code is stored, often on GitHub. These links show that the site was based on open-source code.
The program's scope description, quoted in the write-up, said:
ide.redacted.com is anonline IDE*, available to the public for developing test Applications. Its primary purpose is to facilitate bootcamps, it is not a intended for production use, or for anything other than one-off test scenarios.*
The shell terminal is deliberately available to everyone, without authentication required, because there is no sensitive information to be revealed.
The shell is also resource limited, does not accept inbound network connections, and the shell session will automatically expire. It is not designed as a long-term store of data.
The shell runs in a container. It should not be possible to access the host operating system, however if you find a way to break out of the container and compromise the host then we would like to hear about it :-)
This tells us several important things:
- The terminal (also called a shell) is open to everyone on purpose. You do not need an account to use it.
- The terminal is limited in resources and cannot receive incoming network connections. It also expires after a while.
- The terminal runs inside a container. A container is like a lightweight virtual machine that keeps programs separate from the main operating system (the host). The program says it should not be possible to escape the container and access the host, but they would like to hear about it if you find a way.
So the open terminal is not a bug. The researcher knew this and looked for something with more impact.
How the researcher found the bug
No special tools or accounts are mentioned. The researcher opened every in-scope asset in a Chrome tab and worked from the browser. The only precondition was the publicly reachable IDE with its unauthenticated terminal.
One asset stood out: an online IDE modelled on VS Code. The researcher first explored the terminal, checking the gcc version and the kernel version, and tried to get root access. gcc is a compiler (a program that turns source code into runnable programs). The kernel is the core of the operating system. Root access means having the highest level of permission on a system. That attempt failed.
The terminal itself was open to anyone, so any command could be executed in it, including a reverse shell. A reverse shell is a way to make the target machine connect back to you and give you a command line. But according to the scope description, this was expected because the target held no sensitive information.
The researcher then created a file named xss.html containing an XSS payload, but running it produced no visible output. XSS (Cross-site Scripting) is a type of attack where malicious JavaScript is made to run in someone else's browser. A payload is the actual code that performs the attack.
Looking at the source code revealed something more interesting: a full directory path was called in the URL after the hashes.
/usr/local/****/src/browser/media/favicon.ico
This is a full path inside the server. A path is the location of a file on a computer, like an address. The URL contained this path, which means the website was using the URL to decide which file to show. The **** hides part of the path, probably to avoid revealing sensitive information.
Opening that path in another tab and changing the URL to point at /etc/passwd returned the file successfully. /etc/passwd is a standard file on Linux systems that lists user accounts. It does not usually contain passwords, but it is a system file that should not be readable from a web application. That confirmed a Local File Inclusion vulnerability. LFI means the application includes (reads and shows) files from the local filesystem based on user input, without proper restriction.
At this point the researcher re-read the program policy, having previously lost reputation for not doing so, and found the scope text quoted above. The terminal was deliberately open, so a plain LFI reachable through the terminal functionality would not be accepted without impact. In other words, just reading a file that anyone could read via the terminal was not enough; the researcher needed to show something worse.
Exploitation
Step 1: Confirm file read
Changing the path in the URL from the media file to the system file returned the contents of /etc/passwd. The report shows no request or response for this step, only that the file was successfully called in the URL. This step proved that the URL parameter could be used to read arbitrary files on the server.
Step 2: Try a PHP webshell
Since internal files could be read and files could be created through the terminal, the next idea was to create a file with a .php extension as a webshell. A webshell is a script that gives an attacker remote control over a server. PHP is a programming language often used on web servers. The researcher hoped that by creating a PHP file and then accessing it through the browser, the server would execute the code and give a shell.
That attempt always returned:
Content-type: text/plain
This is an HTTP response header. HTTP is the protocol browsers and servers use to communicate. The Content-type header tells the browser what kind of file it is receiving. text/plain means plain text, so the browser displays the file as text instead of running it. Therefore the PHP file could not be executed. The researcher notes this made little sense given that everything was already possible in the terminal.
Step 3: Reuse the XSS file
The first file created, xss.html with the XSS payload, was still on the server. The researcher copied the location of that file as an internal file and pasted that location in place of /etc/passwd in the URL. The alert(document.domain) payload executed, confirming Stored Cross-site Scripting. Stored XSS means the malicious script is saved on the server (stored) and then served to anyone who visits the page. alert(document.domain) is a simple JavaScript command that shows a pop-up with the domain of the current page; it is often used to prove that script execution is possible.
The report does not include the exact payload, the exact URL used, or the response body for this step.
Step 4: Report
The Stored XSS was reported. After the report, the program removed the asset from its bounty scope.
Root cause
The report does not describe the server-side code, so the exact mistake is not stated. What the behaviour implies is that the same URL parameter that served static media from a path under the application directory accepted arbitrary filesystem paths, with no restriction to the intended media directory. Because the terminal let any visitor write files into that filesystem, an attacker could plant an HTML file with script in it and then request it through the file-serving path, which is what turned the file read into stored XSS. The Content-type: text/plain response for .php files suggests some content-type handling existed, but it did not prevent the HTML file's script from executing. Whether that handling was a deliberate defence or an accident is not stated.
Impact
The confirmed impact was stored cross-site scripting: the researcher's own payload executed when the crafted URL was opened. The report does not describe who else used the IDE, whether sessions or credentials were exposed, or what an attacker could reach through the XSS. The LFI on its own was not treated as impactful, because the scope explicitly said the terminal was open by design and held no sensitive information. The program's own scope text set the bar for a serious finding at breaking out of the container and compromising the host; the report does not claim that was achieved.
Fix
The only change mentioned is that the program removed the asset from its bounty scope after the report. A fix would be to constrain the file-serving path to the intended media directory and to serve user-written files with a content type and headers that prevent them from executing as pages.
Variants to test
- Path traversal in static file parameters: replace a media path with
../../../../etc/passwdand look for system file contents in the response. Path traversal means using../to move up directories and reach files outside the intended folder. - Absolute path acceptance: supply a full path such as
/etc/passwddirectly where a relative asset path is expected. A positive result is the file contents returned. - Content-type bypass: upload or create files with
.html,.svgand.phpextensions and request each one. A positive result is HTML or SVG returned with a type the browser renders and executes, rather thantext/plain. - Write-then-read chains: wherever an unauthenticated terminal or upload feature exists, plant a file with a script payload and request it through the file-serving endpoint. A positive result is the payload executing in the browser.
- Container escape: per the scope text, try to reach the host operating system from the shell. A positive result is access to host files or processes outside the container.
Glossary
- Bug bounty program: A scheme where organisations reward people for finding and reporting security vulnerabilities.
- HackerOne: A platform that hosts bug bounty programs.
- Private program: A bug bounty program that only invited researchers can participate in.
- Scope: The list of assets (websites, apps, etc.) that are allowed to be tested.
- Asset: A specific system or application that is part of the scope.
- IDE (Integrated Development Environment): A software application that provides comprehensive facilities to computer programmers for software development.
- VS Code / Visual Studio Code: A popular free code editor made by Microsoft.
- Repository (repo): A storage location for software code, often hosted on platforms like GitHub.
- Terminal / shell: A text-based interface for entering commands to control a computer.
- Container: A lightweight, isolated environment that runs an application separately from the main operating system.
- Host: The underlying operating system that runs containers.
- gcc: The GNU Compiler Collection, a compiler for programming languages like C and C++.
- Kernel: The core part of an operating system that manages system resources.
- Root access: The highest level of permission on a Unix-like system, allowing full control.
- Reverse shell: A technique where the target machine connects back to the attacker, providing a command shell.
- XSS (Cross-site Scripting): A vulnerability that allows an attacker to inject malicious scripts into web pages viewed by other users.
- Payload: The part of an exploit that performs the malicious action.
- LFI (Local File Inclusion): A vulnerability that allows an attacker to include files from the local filesystem in the application's output.
- Path: The location of a file or directory in a filesystem.
- /etc/passwd: A system file on Unix-like systems that stores user account information.
- PHP: A popular server-side scripting language.
- Webshell: A script that provides remote control over a web server.
- HTTP: The protocol used for communication between web browsers and servers.
- Content-type header: An HTTP header that indicates the media type of the resource.
- text/plain: A content type indicating plain text, which browsers display as text rather than executing.
- Stored XSS: A type of XSS where the malicious script is permanently stored on the server and served to users.
- alert(document.domain): A JavaScript command that displays a pop-up with the current domain, often used to demonstrate XSS.
- Path traversal: A technique to access files outside the intended directory by using
../sequences. - Content-type bypass: A technique to circumvent restrictions on file types to execute code.
- Container escape: A technique to break out of a container and access the host system.