{% extends "introduction/base.html" %} {% load static %} {% block content %} {% block title %} Improper Authentication {% endblock %}

CWE-287 Improper Authentication

The programme cannot or does not sufficiently demonstrate that an actor is the person they claim to be when they make a specific identity-related claim.

The lab consists of a login page, which request users for their username and password. If you don't know the password ,there is also a feature for login with otp! When the users clicks the login with otp feature, user is directed to a page, which asks users email id to send the otp. When the user provides an email id , you can see that the 3 digit opt is sent back to the page itself. This is not the general scenario , usually the code is sent to the registered email of the user.
The user on receiving the 3 digit code can now enter the code in the input box that says Enter your OTP On entering the valid OTP the user gets a page which says Login Successful as user : email . If the Otp is wrong then the user gets a message saying Invalid OTP

The Bug

The main aim of this lab is to login as admin, for that you are gonna exploit the lack of rate limiting feature in the otp verification flow. You can see that the otp is only of 3 digit(for demo purposes) and the application doesnt have any captcha (To disallow any automated scripts or bots) or any restrictionds on the number of tries for the otp.

Now to send the otp to the admin's mail you need to figure out the admins mail id. Luckily the admin has left his email id for the developers in the page source. Admins email id admin@pygoat.com After entering this email in the send otp input box and hit send, you can see that the page says that otp has been sent to the email id of the admin. In order to exploit the lack of rate limiting , we can try to Brute-force the 3 digit otp.

Steps to Brute force:

Using this otp you will be able to login into admins account.


Here is a admin pannel of the application. After some recon we got the username admin_pygoat@pygoat.com
& password hash $argon2id$v=19$m=65536,t=3,p=4$Ub40KHiEbH9I3Bsd4VHQDA$4zsIHDmAbejFJmaZq8a2yVIJdHvfylDlQ85w3YRLMSQ
Can you access the admin pannel? or you can do something else so that real admin can't access the admin panel

Lets assume a senario, a user 'X' access his account and before leaving he logs out from his account. You didn't saw the user 'X's password, but can access his account ? these are the credentals of different users, try to get some unautherize access.
username : User1 | password : Hash1
username : User2 | password : Hash2
username : User3 | password : Hash3



Mitigation

This type of authentication flaw can be mitigated by:

{% endblock %}