As the program is private; Program Name, Endpoints are replaced **
Hey guys, Today i’ll show you how i gained a Code Execution on a HackerOne’s Private Program. This is chaining of multiple issues, which were addressed separately and all were marked as Critical/P1. Nice team
This program had a ABC Enterprise installation and a Normal Installation which have some less features or say some less endpoints , Program hosted Enterprise for testers with admin credentials given. While Normal was available to download and host locally.
- Less features,
- Less bounty,
- Gives basic idea how the app is hosted and working on backend.
Information i gained using Normal Installation
- Some internal services.
- Web app structure.
Some XSS, SSRF were found in Normal Installation, But now i had an understanding of what i’m testing.
Lets go ahead and start with program hosted Enterprise with many more features / endpoints
1 – Critical IDOR
There was option to download logs, After downloading logs i started looking into it what things it contains. And luckily i found a request in logs
where other users api_key was getting leaked, Hmm this is good but we’re working as Admin login right now, So i tired download the log while being normal user & unauthenticated and it got downloaded. Using this IDOR an attacker can download logs while being unauth to instance and then further exploit it with api_key retrieved from logs. So now i can report this one but i decided to dig in it further.
After making request to;
I got another URL in response which was;
Tried changing filename for LFD but didn’t worked, changed upload to download still no LFD, Seems like dead end But then i thought lets make an OPTIONS request (read in someone’s write up)
And GET, PUT was there, Made PUT request and server responded with ‘Content Length can’t be 0’, added raw data and again made request and response was 200 OK, Then i added ../../../../../../../../tmp/harsh.txt in filename and again response 200 OK
Then, ../../../../../../../../etc/harsh.txt and exception
Permission Denied (/opt/xxx/api/uploads/../../../../../../../../etc/harsh.txt)
^ Not exactly this.
At this point i have enough things to report
- Unauthenticated user can download logs
- Logs contains API Key
- Using API Key attacker can create files on server (where current user had permission).
And plot twist;
- Api key was password of admin user itself.
All reported and got response from team.
Code Execution with Server Admin Interaction
So after reporting all the above mentioned issues, I challenged myself to use this endpoint separately and get Code Execution.
And within few minutes i realized a normal user credentials also accepted at /api/v1/upload and hence a normal user can create files on server.
Going back to logs and Normal Installation for gaining info how this issue can get me a Code Execution.
Realized the web app is started from /opt/xxx/bin/xlink, So this was simple all an attacker need to do is overwrite xlink with reverse shell script, and wait server admin to restart (just make some files not usable which will force admin to restart) the server by doing sh xlink restart/stop/start and as soon as he trigger this condition we will have a rev shell.
This issue was Normal user to Code Execution. Traiged and Rewarded as Crtical.
Now this 2 bugs finished here. You might have noticed i mentioned “sh xlink restart/stop/start ” as the file is not executable. Will continue later with another RCE which wont require attacker to wait for admin to restart the server. Instead all an attacker need to do is visit a url and enjoy shell although this one will require attacker to have admin access of web app.
Thanks for reading.
Harsh from Bugdiscloseguys!