Skip to main content
Ethical Hacking
CHAPTER 07

Understanding Authentication and Password Security

Updated: May 15, 2026
20 min read

# CHAPTER 7

Understanding Authentication and Password Security

1. Introduction

Authentication is the process of proving you are who you say you are. Usually, this involves a username and a secret password. However, managing passwords securely is notoriously difficult. If a company stores passwords incorrectly, a database breach becomes a catastrophic event for their users. In this chapter, we will explore the mechanisms of authentication, the difference between hashing and encryption, the mechanics of brute-force attacks, and the defensive absolute necessity of Multi-Factor Authentication (MFA).

2. Learning Objectives

By the end of this chapter, you will be able to:
  • Define Authentication vs. Authorization.
  • Differentiate between Encryption (Two-way) and Hashing (One-way).
  • Understand the purpose of a Cryptographic "Salt."
  • Explain Brute Force and Credential Stuffing attacks.
  • Define a secure, modern password policy.

3. Beginner-Friendly Explanation

Imagine a nightclub bouncer.
  • Authentication (Who are you?): You hand the bouncer your ID card to prove your name is Alice.
  • Authorization (What are you allowed to do?): The bouncer checks a list. Alice is allowed onto the dance floor, but Alice is NOT authorized to enter the VIP room.

A common vulnerability (Broken Access Control) occurs when the system correctly *authenticates* Alice, but fails to check her *authorization*, allowing her to walk into the VIP room anyway.

4. Storing Passwords: Hashing vs. Encryption

If a company stores your password as plain text in their database (password123), and a hacker steals the database, the hacker has your password. This is a massive failure. The Bad Fix (Encryption): The company encrypts the password. But encryption is a two-way street. If the hacker steals the database, they just need to find the decryption key hidden somewhere on the server, and they can unlock all the passwords. The Good Fix (Hashing): A Hash is a one-way mathematical meat grinder. You put password123 in, and it spits out a gibberish string: 5baa61e4c.... You *cannot* mathematically reverse the hash back into the password. When you log in, the server hashes what you typed and compares the two gibberish strings. If they match, you are logged in. The server never actually knows your real password!

5. The Threat of "Rainbow Tables" and "Salting"

Hackers are smart. Since they can't reverse a hash, they pre-compute the hashes of every single word in the dictionary (creating a "Rainbow Table"). When they steal a hashed database, they just look up the hashes in their table to find the passwords instantly. The Defense (Salting): Before the server hashes your password, it adds a random string of characters (a Salt) to it. Instead of hashing password123, it hashes password123 + R@nd0mS@lt!. This completely breaks the hacker's pre-computed Rainbow Tables.

6. Attacks on Authentication

  • Brute Force: A hacker uses an automated script to guess every possible combination of letters and numbers (aaaaa, aaaab, aaaac) on a login page until they get in. (This is very loud and slow).
  • Credential Stuffing: Hackers know people reuse passwords. If LinkedIn gets hacked, the hackers take your LinkedIn email and password and write a script to try that exact combination on your bank, your email, and your Amazon account. (This is incredibly effective).

7. Mini Project: Create a Secure Password Policy

A defensive security professional must write policies to protect users from themselves.

Checklist for a Modern Password Policy:

  1. 1. Length over Complexity: A 16-character phrase (correct horse battery staple) is mathematically far harder to crack than an 8-character complex password (P@ssw0rd!), and much easier for humans to remember. Enforce minimum length (e.g., 12 characters).
  1. 2. No Arbitrary Expiration: Do not force users to change their passwords every 90 days. Research shows this causes users to create weaker passwords (e.g., changing Password1! to Password2!).
  1. 3. Screen against Breached Lists: When a user creates a password, automatically check it against known breached password lists (like "Have I Been Pwned") and reject it if it has been used before.
  1. 4. Implement Account Lockout: If an IP address fails to log in 5 times in a row, lock the account or require a CAPTCHA to stop Brute Force attacks.

8. Real-World Scenarios

A major corporation suffered a devastating breach. The hackers didn't use advanced zero-day exploits. They simply searched LinkedIn for the company's employees, found the IT Administrator's name, and used a Credential Stuffing tool. The Administrator had reused the same password from an old, breached gaming forum for their corporate VPN login. Because the VPN did not require Multi-Factor Authentication (MFA), the hackers walked right into the corporate network.

9. Best Practices

  • Multi-Factor Authentication (MFA): Passwords will always be stolen, guessed, or phished. MFA assumes the password is compromised. It requires a second form of proof—usually something you *have* (a code on your phone) or something you *are* (a fingerprint). Implementing MFA blocks 99.9% of automated credential stuffing attacks.
Performing a brute-force or credential stuffing attack against an organization's login portal, even just "to see if it works," is a direct violation of the law. It causes high server load and constitutes unauthorized access attempts.

11. Exercises

  1. 1. Explain why hashing is considered a "one-way" cryptographic function, whereas encryption is "two-way."
  1. 2. Define the purpose of a Cryptographic "Salt" when storing user passwords. How does it defeat a Rainbow Table attack?

12. FAQs

Q: Are password managers safe? A: Yes! Humans cannot remember 50 unique, 16-character passwords. A reputable password manager (like Bitwarden or 1Password) generates and remembers secure passwords for you. You only have to remember one strong "Master Password." If the password manager uses strong hashing, even if they are hacked, the hackers cannot read your vault.

13. Interview Questions

  • Q: Contrast Authentication with Authorization. Provide a specific vulnerability example that exploits a failure in Authorization.
  • Q: Describe the mechanics of a Credential Stuffing attack. Detail three defensive controls an organization can implement to mitigate this specific threat vector.

14. Summary

In Chapter 7, we fortified the front door. We learned to differentiate between proving identity (Authentication) and verifying permissions (Authorization). We recognized that storing plain-text passwords is a catastrophic failure, and explored the necessity of salted, one-way cryptographic hashes to protect user data in the event of a breach. Finally, we acknowledged the human element—password reuse—and countered it with modern password policies and the absolute necessity of Multi-Factor Authentication.

15. Next Chapter Recommendation

Authentication protects the accounts, but what if a hacker tricks the database into bypassing the login screen entirely? Proceed to Chapter 8: Introduction to SQL Injection Awareness.

Finish this Chapter

Save your progress on your learning path and prepare for coding interview challenges.

Discussion

Join the discussion

Log in or create a free account to participate.

Sort: ·