Polution
Challenge Lab (Easy) - by Tyler Ramsbey
The following post by 0xb0b is licensed under CC BY 4.0
Scenario
Objective / Scope
You are a member of the Hack Smarter Red Team and your organization is beginning to roll out a managed SOC service. You've been provided access to a staging version of the web app before it's pushed to production.
The credentials below mirror a customer. Are you able to elevate your privileges and become an Administrator?
Summary
Recon
We use rustscan -b 500 -a 10.1.42.179 -- -sC -sV -Pn to enumerate all TCP ports on the target machine, piping the discovered results into Nmap which runs default NSE scripts -sC, service and version detection -sV, and treats the host as online without ICMP echo -Pn.
A batch size of 500 trades speed for stability, the default 1500 balances both, while much larger sizes increase throughput but risk missed responses and instability.

On Port 3000 we have a Nodejs server running.

When we visit the index page we are greeted by a internal portal login.

We try to enumerate the directories and pages using Feroxbuster and find the /api/mail endpoint and /dashboard endpoint to be reachable.

Without credentials we are able to access the dashboard including the webmail endpoint to send our messages to the admin.

But for now we follow the scenario and log in as pentester. We face the same dashboard.

If we try to access the incident response page we get a 403 like in our unauthenticated FeroxBuster scan.

The session cookie appears to be a very simple one with setting the username. Chaning this won't give us a session as an admin, but the username gets reflected on the page.

When we click on Webmail we gain access to the internal messenger, and we are able to send messages to the admin user.

Access as Admin
We try some simple XSS payloads to determine which field might be injetable if the admin reviews the messages.

We send the message...

... run a python web server. We receive a connection to our web server. The Message field is injectable.

If we try to steal the session cookies with a simple payload like the following...

... we receive a connection, but the cookie value does not get resolved.

Since we know that we are dealing with a Nodejs server and the challenge is called Polution, we could also be dealing with a Prototype Polution vulnerability and need exploit it to obtain a session as admin.
Prototype pollution is a vulnerability where we can modify properties on JavaScript’s base object prototypes by injecting special keys like
__proto__constructor.prototypeprototype
Because all JavaScript objects inherit from these prototypes, polluting them affects the behavior of every object in the application.
Or in other words: we poison the “template” that all objects are created from.
To test for Prototype Polution vulnerabilities we make use of the BurpSuite browser and the BurpSuite addon and enable the DOM Invader plugin.

We also need to enable the attack type prototype polution.

Via More Tools -> Developer Tools -> DOM Invader we can scan now for gadgets.

A new tab is opened and after the scan we can inspect the DOMInvader tab again.

We find a vulnerable gadget and can run exploit.

It opens us an a link which does not successfully resolve the injected javascript:

We make a slight correction and remove the closing brackets. We receive an alert.

Now that we have a working payload, we try to alter it to retrieve the sessions cookies of the user opening the link.
We set up a simple HTTP server with Python that will print the POST body (containing the cookie) in our console.
Next, we will put the suggested prototype polution payload and our fetching payload together and request the link on our own.

We see we are able to retrieve our own session.

Next, we send the link to the admin, if the admin clicks the link we should receive the used session cookies.

Afer a short duration we receive a response with two cookies.

We add them in our browser...

... and reload the page. We are now admin and are allowed to open the incident response page.

Alternative: Retrieving /incident-response by Admin
If the cookie would have been properly secured we would still be able to retrieve the incident response page with the following payload.
We replace the cookie fetching payload with the content fetching payload and send the link to the admin user.

After a short duration we receive the contents of the page including the flag.

Last updated
Was this helpful?