Skip to content
Tutorials Center
My learning

Topics

Lesson 16 of 31 ยท Password Security

Auditing Your Own Credential Policy

Audit your own login security: lockout and rate limits, breached-password checks, password managers, and how to do credential testing only with authorization.

Strong hashing and good password math only help if the surrounding policy is sound. A login system is a set of controls working together: what passwords are allowed, how fast someone can guess, what happens after repeated failures, and how stolen passwords are noticed. Auditing means checking that each of those controls exists and behaves as intended.

This lesson looks at credential security as a defender who audits their own systems. It follows Password Storage and Hashing and Password Strength, Entropy and Cracking Resistance. The Python stand-ins check sample passwords against a policy; they never test real accounts.

Credential testing against a system you do not own, or without written scope, is illegal in most places even if you never "break in". Testing only counts as an audit when it is authorized. See Law, Ethics and Authorization.

The controls that matter

A modern login policy has several layers. No single layer is enough.

Layers around a login

Password rules Length and a ban list.
Rate limits Slow down guessing.
Lockout Pause after repeated failures.
MFA A second proof.

Each layer covers a gap in the others.

1 / 2

Rate limiting and lockout

Online guessing (trying passwords through the login form) is stopped by limiting the speed. Two common mechanisms exist and they work best together:

  • Rate limiting caps attempts per account, per IP address and globally, for example five attempts per minute per account.
  • Lockout temporarily blocks an account after a number of failures (for example 10), or increases the delay with each failure (progressive delay).

Lockout has a downside: an attacker can deliberately lock out other people's accounts, a denial of service. That is why many systems prefer increasing delays and CAPTCHA or MFA challenges over permanent locks, and why an unlock path (email link, support process) must be safe too. Per-IP limits alone are weak because attackers spread guesses across thousands of addresses.

Here you will see credential stuffing and password spraying, the two attacks these controls are designed against. Stuffing reuses leaked username-and-password pairs from other sites. Spraying tries a few very common passwords against many accounts to stay below per-account lockouts. Defenders detect both by looking at failures across accounts, not just per account. The stand-in below models a login attempt log (invented data) and a detector for exactly those patterns.

Python Spot spraying in a sample failure log

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real detection uses sliding time windows and many more signals (user agent, geography, timing), but the principle is the one shown: look at the shape of the failures.

Checking passwords when they are chosen

The best time to stop a bad password is when someone sets it. A good policy checks three things:

  1. Minimum length (NIST suggests at least 8, many organizations choose 12 to 15 or more) and a generous maximum (64 or more characters).
  2. A ban list: common passwords, the username, the product or company name, and sequences like 12345678 or qwertyuiop.
  3. A breached-password check. Services such as Have I Been Pwned's Pwned Passwords offer a k-anonymity API: your server sends only the first five characters of the password's SHA-1 hash and gets back the list of matching hash suffixes, so the full password or hash never leaves your system. Checking happens locally against the returned list.

The stand-in below shows the policy-checking idea with a tiny invented ban list, plus the k-anonymity split. SHA-1 is acceptable here because it is used only as a lookup key in that public service, not for storing passwords.

Python A small password policy checker

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Look at the verdicts. Password123! passes most superficial composition rules but is rejected here for what it actually is. The passphrase is accepted because it is long and not on any list. Noticing that the policy rewards length rather than symbols is the point.

Password managers and storage hygiene

For users, the practical answer to "choose a different strong password for each site" is a password manager. It generates long random passwords, fills them only on the correct domain (a small but real protection against phishing pages), and syncs encrypted vaults between devices. For organizations, offering a company-approved manager and single sign-on reduces the number of passwords that exist at all.

On the system side, audit these places where credentials often leak:

  • Plain-text passwords in source code, config files, wiki pages or shell history.
  • Secrets committed to version control (secret-scanning tools can search history).
  • Default and shared administrator accounts on devices and web consoles.
  • Service accounts with passwords that never change and are far more powerful than they need to be.
  • Logs that accidentally record login forms or Authorization headers.

How an authorized credential audit looks

When credential testing is part of an approved engagement, the rules of engagement should say, in writing: which systems and accounts are in scope, whether password guessing is allowed at all, the maximum attempt rate, the time window, and who to call if an account is locked. A responsible tester prefers reviewing the policy and the configuration over guessing: read the lockout settings, the hashing parameters, the MFA coverage list, and the breach-check behavior. Guessing live accounts is the last resort and always limited in rate and in the number of attempts.

A typical audit report would list findings such as "no rate limit on the reset endpoint", "MFA not enforced for administrators", "passwords stored with an unsalted fast hash", each with severity, evidence and a fix. Writing a Professional Security Report shows how to write them up.

What is real and what is the stand-in

The controls, the k-anonymity design of range lookups, and the audit practice are real. The failure log, the ban list and the thresholds are invented, simplified examples. The Python code does not guess passwords or contact any service.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. How does password spraying differ from simple brute-forcing of one account?

    Spraying spreads attempts across many users, which is why detection must look across accounts, not just per account.
  2. 2. What is the main drawback of strict permanent lockout after a few failures?

    Lockout can be abused as denial of service, so progressive delays, challenges and safe recovery paths are often preferred.
  3. 3. What does a k-anonymity breached-password lookup send to the service?

    Only the first five hash characters are sent, and the matching is done locally against the returned suffixes.
  4. 4. Which is the best first step in an authorized credential audit?

    Configuration review finds most weaknesses safely. Live guessing is limited, rate-capped and only within the written scope.
  5. 5. Why is a ban list useful on top of a minimum length?

    Length helps, but 'passwordpassword' is long and still on every list. Blocking known-bad choices closes that gap.

Summary

  • A login policy is layered: password rules, rate limits, lockout or delays, MFA, slow hashing, breach checks and monitoring.
  • Credential stuffing and password spraying are detected by looking at failures across accounts and sources.
  • Check passwords at creation: length, a ban list and a breached-password lookup using k-anonymity.
  • Password managers and secret scanning reduce reuse and leaked credentials.
  • Authorized audits favor configuration review, state rate limits in the rules of engagement and report findings with fixes.

Next, apply the same defensive thinking to the web in Web Application Security Concepts.