Skip to main content

Few steps on how to take over a whole application

Illustration of Few steps on how to take over a whole application
Sebastian Jeż

In a recent penetration test, I found a vulnerability in the password reset tokens within a system’s audit trail functionality. This flaw can lead to arbitrary account takeover, allowing attackers to hijack user accounts, including those with high-level privileges.

Vulnerability Overview

The issue begins with the system’s audit trail logging every account activity. When examining this log, we found sensitive password reset tokens embedded within the JSON data. These tokens are generated whenever a password reset request is made. The lack of effective access control mechanisms directly compounds this exposure.

A notable weakness in the token generation process is its predictability. Specifically, the last six characters of the token, which are hexadecimal values (e.g., 0022CB56110000000012EF8B), show consistent variation. This predictability allows attackers to generate reset tokens for any account, enabling even low-privileged users to reset passwords of higher-privileged accounts, such as administrators.

Exploitation Showcase

As exploitation is a bit complex, here’s how the exploitation process went step by step to take over the whole application:

  1. GET request and token identification: attackers intercept the GET request to the audit trail functionality and identify the insecure token.

  2. Data analysis: by analyzing the JSON data within the audit trail, they find stored password reset tokens among other information.

  3. Token pattern recognition: the attackers recognize a pattern in the token generation, revealing a predictable sequence.

  4. Targeted brute-force attack: instead of a broad brute-force attack, they focus on the six-character hexadecimal variation, significantly narrowing the attack scope.

  5. Account access: within a short time, attackers can access multiple accounts, including administrator accounts, through the targeted brute-force method.

  6. Admin token unveiling: while finding an admin token takes longer, it remains feasible (for example, hexadecimal 12EF8B converting to decimal 1240971).

  7. Audit trail data exposure: with the acquired token, attackers access other users’ audit trail data, extracting sensitive information like email addresses.

  8. Initiating password reset: using the extracted email addresses, attackers initiate password reset requests.

  9. Obtaining fresh reset token: they then request the admin’s audit trail endpoint again to obtain a new password reset token.

  10. URL token substitution: attackers replace their own reset token with the newly acquired admin token within the password reset URL.

  11. Admin password overwrite: this allows them to reset the administrator’s password using the substituted token.

  12. System compromise: with admin-level access, the attackers achieve full system compromise.

Conclusion and Best Practices

The explained exploitation process highlights a significant security concern regarding the handling of sensitive data, even in secure functionalities like audit trails. This vulnerability shows the need for stringent access control and secure token generation mechanisms.

To mitigate such vulnerabilities, it is crucial to follow cybersecurity best practices. This includes:

  • Ensuring secure token handling and generation.
  • Minimizing data exposure in logs.
  • Implementing strict access control mechanisms to protect sensitive data and functionalities.

By adhering to these practices, organizations can better safeguard their systems against similar security threats.

Other Insights

Illustration of How a simple vulnerability allowed proxying TCP traffic - real pentest case

How a simple vulnerability allowed proxying TCP traffic - real pentest case

Dariusz Tytko

During a penetration test for our client, it was discovered that the turn.example.com server, which is part of the tested application infrastructure, is vulnerable. This flaw allows for proxying TCP traffic through the server, enabling attacks on any host on the internet. Additionally, attackers could gain access to internal systems and their configurations, potentially compromising the entire infrastructure.

READ article
Illustration of Exploiting PDF generation vulnerability: a case study from real pentest

Exploiting PDF generation vulnerability: a case study from real pentest

SECURITUM

In a recent penetration test conducted by [Your Security Company], we identified a critical vulnerability within a web application that allowed unauthorized access to sensitive resources. This flaw permits an attacker to access both local server files and data on other servers within the same network. The vulnerability stems from improper handling of user-input data, presenting a severe security risk.

READ article
Illustration of Password reset flaw: when anyone can reset your password

Password reset flaw: when anyone can reset your password

Sebastian Jeż

During rigorous testing, security researchers uncovered a significant weakness in the password reset mechanisms used by numerous online platforms. By exploiting the seemingly harmless phone number field, an attacker can compromise a victim's account. The vulnerability lies in the mishandling of a four-digit code, which, instead of being sent solely to the owner's phone, is also included in the server's response. This oversight turns a seemingly harmless feature into a gateway for hackers to infiltrate users' digital lives.

READ article
A professional cybersecurity consultant ready to assist with your inquiry.

Any questions?

Happy to get a call or email
and help!