Introduction to Authentication

What is Authentication


The article should be self-sufficient

Attacks on Authentication


The article should be self-sufficient

Brute-Force Attacks

Enumerating Users


Server response should NOT indicate any difference based on the validity of any of the supplied field. This must be applied for all measurable output :

  • An invalid username must return the same “incorrect login” output than a valid username with a wrong password.
  • The response time should be flattened. An invalid username shouldn’t trigger a faster response than a valid one who proceed to check the password in a second time or supplementary verifications.

Otherwise such an application is vulnerable to username enumeration. We can take advantage of Ffuf parameters such as -fr or -ft to filter based on response content or response time(Check Attacking Web Applications with Ffuf note for more details).

Example of filtering by response content :

ffuf -w /opt/useful/seclists/Usernames/xato-net-10-million-usernames.txt -u http://172.17.0.2/index.php -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "username=FUZZ&password=invalid" -fr "Unknown user"

Questions

Brute-Forcing Passwords


This section is closely linked to both Password Attacks and Login Brute Forcing modules. Quick mention of password spraying when we have a very wide list of username and maximum trials protects the server against usual brute-force.

As explained in the Hybrid Attacks there is a recap on filtering our usual wordlists to match password policies. They still give some insightful commands to achieve that with keywords I didn’t know before :

Using keywords for filtering with grep

grep '[[:upper:]]' /usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt | grep '[[:lower:]]' | grep '[[:digit:]]' | grep -E '.{10}' > custom_wordlist.txt

Equivalent using awk (I really need to get comfortable with this tool) :

awk 'length($0) >= 10 && /[a-z]/ && /[A-Z]/ && /[0-9]/' /usr/share/seclists/Passwords/Leaked-Databases/rockyou.txt > custom_wordlist.txt

In the section it is assumed we determined the admin username exists (despite the response time being flattened and the generic response).

Questions

Brute-Forcing Password Reset Tokens


This section is very similar in execution to the Cracking the PIN section from the login brute forcing module. The objective here is to identify the password reset process and look for weak token or mechanism. If account creation is possible you can identify the complete process by doing it on your own. This way you’ll be able to precisely identify the workflow and attack it.

Questions

Brute-Forcing 2FA Codes


Exact same principle as before but we can look to replay the 2FA POST request. Correct credentials initiate the connection process so your session can be tied up to the 2FA verification.

Weak Brute-Force Protection


  • Rate Limits should be enforced although it’s quite a deep topic. X-Forwarded-For based rate limiting can be bypassed. IP based rate-limiting is not the best solution either. This topic deserves more research other than the implementation but the consideration of the workflow. Check Cloudflare Rate Limiting article, Nginx rate limit …
  • CAPTCHAs can be a solution but this might be checked twice now with AI solving capabilities. Interesting research topic nevertheless.
  • Fixing a maximum amount of trials on a specific account (not global) before temporary blockage might be a good idea if it’s IP based.

Password Attacks

Default Credentials


TL;DR

OWASP has a dedicated note on the Default Credentials Testing

Look for these resources listing default credentials on many known services :

  1. CIRT.net
  2. SecLists Default Credentials
  3. SCADA

The following part is a simple demonstration of leveraging default credentials on a known Web App technology (BookStack)

Vulnerable Password Reset


Guessable Password Reset Questions

This should never have been a thing in the first place but I guess it still exists on the latest versions of Windows.

OSINT or brute-force can solve these questions depending on their nature. Provided example birth city can be tested out with specific wordlists like world-cities.csv (check datasets repository it’s by the way, it might give you some ideas of topic to learn about).

The mentioned wordlist can be cleaned to suit our needs :

cat world-cities.csv | cut -d ',' -f1 > city_wordlist.txt

From there the whole section is a follow along with the brute-force on the cities question.

It goes on to an other example where you can abuse the implementation of the reset password functionality by changing the username in the body after the security question validation.

Questions

Authentication Bypasses

Authentication Bypass via Direct Access


Not really convinced by this section. It’s possible a server include the page content in it’s response even on redirection. While you might not notice anything through the browser it can be logged or intercepted. HTB provides an example of response interception though don’t even need that. Simply access the HTTP history and check the response from the server upon reaching the path.

Questions

Authentication Bypass via Parameter Modification


Taking a quick look at how sometimes authentication or authorization flows can be wrongly implemented. They present really quickly the IDOR vulnerability even though their example is a bit weird.

Suppose we are logged in and redirect to admin.php with the parameter user_id=183. Replaying the request while removing this parameter gets us back to the index.php.

Seeing this, it could be interesting to change the user_id value to observe the resulting behavior. What the section shows is if user_id is the only check done to reach the admin page, then maybe the session cookie isn’t even needed.

Questions

Session Attacks

Attacking Session Tokens


Session token entropy should be tested by making the server do the session setting a huge amount of time to retrieve the biggest token samples possible. Burpsuite has a feature called Sequencer which can be used to retrieve tokens and evaluate the entropy.

Brute-force Attack

Always try to identify if the session token :

  • is complete randomness
  • looks like an existing hash format
  • is it encoded in any way partially or totally Creating multiple ones can help identify similarities between the different values.

Further Session Attacks


Mention of Session Fixation : Making a target authenticate through a crafter link that preemptively set the session. The server doesn’t refresh the session token upon validation and now the attacker can use the known session to hijack the session’s account.

Improper Session Timeout leading to permanent sessions token validity.

Skills Assessment

Skills Assessment


Scenario

The tech company SecureMint Innovations has tasked you to perform a security assessment of their web application after deploying an entirely new authentication concept, including an updated password policy designed to strengthen overall account security. The client wants assurance that no hidden weaknesses could still put user accounts at risk. Your task is to focus specifically on identifying vulnerabilities within the authentication process. Try to utilize the various techniques you learned in this module to identify and exploit vulnerabilities found in the web application.

Discover the app

The web app only functionality that is available is currently the login one so we’ll focus on this first.

First thing to notice is the server response doesn’t seem having a generic “Unknown username or password” to give a different answer depending on the username validity.

Identify password policy

We can try to check response time difference if we’re able to register an account and in the same time look for a password policy :

The “exactly” 12 characters long and “NO special characters” criteria narrow down our search for password combination.

Using grep to match the password policy when filtering wordlists :

grep -P '^(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])[A-Za-z0-9]{12}$' 

I used this password to create an account quickly Aaaaaaaaaaa1. The session token doesn’t look suspicious BUT logout and reconnect gives you the same one so it is not expired on log out.

Invalid password on existing account

Now that we have a valid account we can try to login using the wrong password and notice if something is different :

Bingo. We can now try to find a username by filtering responses who include “Invalid Credentials” (or don’t include “Unknown username or password.”).

Enumerating users

After testing the login feature against the xato-net-10-million-usernames.txt And flagging on matching “Invalid credentials” we find the user gladys. We can filter out the rockyou.txt wordlist with the existing password policy to try to find the user password. With only 17042 possibilities left and sorting by the status code, we can identify the password dWinaldasD13.

Bypassing 2FA

We have the credentials gladys:dWinaldasD13 but now we’re greeted with a 2FA OTP step. Trying to reach directly the content by fetching /profile.php redirects us. However, when looking at the response from the server in the redirection we still get the content of the “unauthorized” page.

And we retrieve the flag this way : HTB{d86115e037388d0fa29280b737fd9171}.