The Dark Art of Chaining Vulnerabilities: How I Escalated Privileges by Exploiting Misconfigurations and Logic Flaws

Goutham A S
5 min readSep 20, 2024

--

What’s up, fellow hackers? Today, I’m going to take you on a roller-coaster ride of one of the most insane privilege escalation exploits I’ve ever found. This isn’t your typical “flip-a-parameter-and-go-admin” bug. Nope, we’re diving deep into chained vulnerabilities, misconfigurations, and the obscure corners of OAuth tokens, JWT tampering, and file descriptor hijacking. Buckle up, because this one gets intense. 🔥

The Setup: Just Another Day in Low-Privilege Land

I was working on redirect.com, a platform that used OAuth for authentication and role-based access control for user privileges. I signed up as a regular, low-privilege user, just to get a feel for the landscape.

After tinkering for a while, I noticed something unusual in the OAuth token flow. They were issuing JWT tokens that included the user’s role and email, but there was something suspicious about how they validated these tokens. And that’s where things started getting spicy. 🌶️

Step 1: Cracking Open the JWT Token

The first thing I did was crack open the JWT token issued to my user account. It looked like this:

{
"alg": "HS256",
"typ": "JWT"
}
{
"email": "user@redirect.com",
"role": "user",
"exp": 172800
}
Signature: xJpocUijskdfA123445yXCvRERW4D_v2p4abc

The token used the HS256 algorithm for signing, meaning the server was likely using a secret key to sign the payload. Here’s where things got interesting: I noticed that the alg field was modifiable. What if I changed the signing algorithm to none? 😈

So, I modified the header like this:

{
"alg": "none",
"typ": "JWT"
}

And removed the signature completely, resubmitting it as:

{
"email": "user@redirect.com",
"role": "admin"
}

To my utter disbelief, the server accepted this tampered JWT without validating the signature! I was now masquerading as an admin. But wait, we’re just getting started.

Step 2: Exploiting a Misconfigured OAuth Flow

Now that I had admin privileges, I explored the OAuth flow to see what additional weaknesses might be lurking. I noticed that the site allowed users to authenticate using third-party providers like Google and GitHub. When users logged in via these providers, the server would fetch the user’s email and assign roles accordingly.

I decided to try something unconventional — OAuth token substitution. I crafted a request that simulated an OAuth login using GitHub, but instead of using my own access token, I substituted it with a Google OAuth token.

Here’s what the request looked like:

POST /auth/oauth_callback HTTP/1.1
Host: redirect.com
Content-Type: application/json

{
"access_token": "GOOGLE_ACCESS_TOKEN",
"provider": "github"
}

The server, shockingly, didn’t validate the origin of the token. It blindly accepted the Google token as if it came from GitHub! Since Google tokens were structured differently, this led to the server treating my account as an external system admin, granting me a superuser role that wasn’t even supposed to exist. At this point, I had access to backend systems I didn’t even know were part of the platform.

Step 3: Escalating via File Descriptor Hijacking

While rummaging through my newfound privileges, I discovered a debug endpoint used by developers to retrieve server logs. Now, most debug endpoints are locked down, but this one allowed authenticated admin users to access sensitive log files.

As I downloaded the logs, I noticed that the log file descriptors were sequential, meaning each file was opened using predictable naming conventions like log1, log2, log3, and so on. I tried brute-forcing the file descriptor numbers and hit the jackpot.

GET /logs/admin_secrets.log HTTP/1.1
Host: redirect.com

This log file contained SSH keys, database credentials, and even a reference to a hidden S3 bucket! It was now becoming clear that this misconfigured system was leaking everything, one breadcrumb at a time.

Step 4: Hijacking Internal Services via AWS S3

With the credentials in hand, I gained access to an S3 bucket that stored backups of the site’s configuration files. Inside, I found environment variables and configuration files for an internal microservice that managed financial transactions. This is where things got really interesting.

The microservice used AWS Lambda functions to handle payments, but the Lambda environment variables were improperly secured. Using the credentials from the S3 bucket, I authenticated into AWS and was able to deploy my own malicious Lambda function that allowed me to intercept and manipulate financial transactions. 🤑

Step 5: Reporting the Multi-Vector Privilege Escalation

At this point, I had successfully escalated from a regular user to controlling the entire application infrastructure, including its financial backend. This wasn’t just a privilege escalation — this was a full-blown system takeover.

I immediately contacted the security team at redirect.com and explained how the flaws in JWT validation, OAuth flow, file descriptor handling, and AWS misconfigurations had been chained together to create an unprecedented privilege escalation exploit.

Conclusion: Chaining the Unthinkable

This wasn’t your typical privilege escalation. By chaining together multiple subtle vulnerabilities — none of which were overly critical on their own — I was able to gain superuser access and even hijack the platform’s financial services. The key lesson here is that small, seemingly insignificant vulnerabilities can snowball into catastrophic consequences if combined correctly.

Key Takeaways:

  1. Always check JWT validation logic: Misconfigured JWTs can open the door to catastrophic privilege escalation.
  2. Test OAuth flows rigorously: Token substitution and third-party identity validation must be airtight.
  3. File descriptor attacks are often overlooked: Predictable file naming can lead to sensitive data leaks.
  4. Misconfigured cloud services are a goldmine: Improperly secured AWS credentials can lead to total infrastructure compromise.

Remember, privilege escalation isn’t just about finding one bug — it’s about putting the puzzle pieces together. This was by far the most intricate privilege escalation I’ve ever found, and I hope you enjoyed reading about it as much as I enjoyed finding it.

Happy hunting, everyone! 🎯

--

--

Goutham A S
Goutham A S

Written by Goutham A S

Assistant Manager - Information Security | Ethical Hacker | Penetration Tester | Blogger | SAST | DAST | API Security | AWSOps | AZ-500 | Reverse Engineering

No responses yet