Understanding and preventing credential stuffing attacks
Dropping Science
Now that I've discussed credential stuffing in theory, I'll show a successful credential stuffing attack in action using a WordPress EC2 instance that I have running in Amazon Web Services (AWS). Figure 4 shows the standard login page (note you need the correct URL for the login page in order to point Hydra directly to it).
Figure 5 shows what happens when you execute the following code:
$ hydra -L users.txt -P passwords.txt -t4 -f XXX.XXXXX.tld https-get /wp-login.php
I'll break down the above command to highlight the new options. The X
s redact one of my domain names used for testing on the WordPress server (that's the hidden part in Figure 5). Per the Hydra manual, the -f
option is for exiting when a successful user/password is found. I've also lowered the number of parallel threads to -t4
from the default 16 to stop my laptop stressing out too much. Because I'm targeting a WordPress site running TLS, I use https-get
instead of http-get
like in the previous example. Also pay attention to /wp-login.php
; this is my WordPress login page's URL.
For reference, I've used a couple of the passwords from Listing 1 and appended my known password to the last line. The username file is just populated with chris
. For clarity, Hydra will try all the passwords available against each username unless told otherwise. This example doesn't really simulate a real attack, because an attacker will carefully gauge the sensitivity of the online service that they are attacking and work out how many incorrect logins are permitted.
Pay attention to the the lighter-green text shown in Figure 5 (the line beginning with [443]
). That's where Hydra has successfully weaved its magic and found a valid account to log in with.
I will leave you to experiment with various URLs and other services that the multi-headed Hydra can attack. There are a lot of other useful Hydra options to try as you become more proficient at using Hydra (see Table 2).
Table 2
Useful Hydra Options
s |
Try the username as a password |
n |
Attempt to use an empty password |
r |
Reverse the login in order to try it as password |
Passwords Everywhere
In the introduction, I mentioned password spraying, which is very similar in nature to credential stuffing and easily confused. According to security firm CrowdStrike [15], the difference is that a password spraying attack uses two steps: "An attacker acquires a list of usernames, then attempts logins across all usernames using the same password. The attacker repeats the process with new passwords until the attack breaches the target authentication system to gain account and systems access."
With password spraying, the key difference is one common password is repeated across multiple users. If default passwords are used or password sharing takes place (something that I haven't come across, admittedly), then password spraying can be a successful route to compromising an account.
You can read more about password spraying as a more subtle form of a brute force attack on the CrowdStrike website [15].
Mitigating Attacks
Now that you know about these types of attacks, there are a few things you should do to prevent them:
- Always use multi-factor authentication (MFA) for logging in to accounts. If you use an online service that doesn't offer MFA, nudge them until they do.
- At the very least, ensure there are secondary defenses in addition to your password, such as a personal identification number (PIN) or a secret word or phrase to complement your password.
Website owners can also add these measures to improve their security posture:
- Check for location, browser version, screen resolution, etc., for each user's typical login profile and insist on extra login steps if they do not match.
- Run CAPTCHA puzzles to add a second layer of authentication.
- Introduce rate-limiting to prevent IP addresses from trying repeated logins.
- Blacklist IP addresses that log into multiple accounts.
- Add usernames that are not immediately guessable (e.g., instead of an email address or first name, use something like chrxbinx0091).
If you run your own Linux servers, then I highly recommend Fail2Ban for sophisticated rate-limiting [16]. An article [17] on the Linux Magazine website offers lots of tips on how to get started with Fail2Ban. One word of advice: Start cautiously to avoid potentially causing yourself access problems.
« Previous 1 2 3 4 Next »
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Gnome 48 Debuts New Audio Player
To date, the audio player found within the Gnome desktop has been meh at best, but with the upcoming release that all changes.
-
Plasma 6.3 Ready for Public Beta Testing
Plasma 6.3 will ship with KDE Gear 24.12.1 and KDE Frameworks 6.10, along with some new and exciting features.
-
Budgie 10.10 Scheduled for Q1 2025 with a Surprising Desktop Update
If Budgie is your desktop environment of choice, 2025 is going to be a great year for you.
-
Firefox 134 Offers Improvements for Linux Version
Fans of Linux and Firefox rejoice, as there's a new version available that includes some handy updates.
-
Serpent OS Arrives with a New Alpha Release
After months of silence, Ikey Doherty has released a new alpha for his Serpent OS.
-
HashiCorp Cofounder Unveils Ghostty, a Linux Terminal App
Ghostty is a new Linux terminal app that's fast, feature-rich, and offers a platform-native GUI while remaining cross-platform.
-
Fedora Asahi Remix 41 Available for Apple Silicon
If you have an Apple Silicon Mac and you're hoping to install Fedora, you're in luck because the latest release supports the M1 and M2 chips.
-
Systemd Fixes Bug While Facing New Challenger in GNU Shepherd
The systemd developers have fixed a really nasty bug amid the release of the new GNU Shepherd init system.
-
AlmaLinux 10.0 Beta Released
The AlmaLinux OS Foundation has announced the availability of AlmaLinux 10.0 Beta ("Purple Lion") for all supported devices with significant changes.
-
Gnome 47.2 Now Available
Gnome 47.2 is now available for general use but don't expect much in the way of newness, as this is all about improvements and bug fixes.