Skip to content

ADR: A password guess should cost something

ADR: A password guess should cost something

Status
accepted
Date
2026-09-03

POST /api/auth/login had a lockout policy on paper and none in practice, for as long as it has existed.

In plain words

The sign-in endpoint let anyone guess a password as fast as the server could answer, because nothing counted failed attempts even though the database had columns for it. Now five wrong guesses lock an account for five minutes (ASP.NET Core Identity lockout), and the refusal reads the same as a wrong password.

What that is worth: a developer learns to check that a control in the schema is also in the code path, and the organization's accounts can no longer be worked through with an endless wordlist.

What was there

The login endpoint is public, which it has to be, and it does the right things about what it says: one sentence for a wrong password and one for an address that is not registered, on purpose, so the endpoint is not a list of who has an account here.

What it did not do is count. The check was:

if (user is null || request.Password is null || !await users.CheckPasswordAsync(user, request.Password))

UserManager.CheckPasswordAsync verifies a password and does nothing else. It does not touch AccessFailedCount, so lockout never engages, and nothing else in the application was counting either: there is no rate limiter in front of it and the identity options never configured a lockout.

The AspNetUsers table has had LockoutEnd, LockoutEnabled and AccessFailedCount in it since the schema was written. Three columns, correctly typed, faithfully migrated, and never once read or written.

That is the specific shape worth naming: a control that exists in the schema, in the framework and in everybody's mental model of what Identity does, and is absent from the code path. It is more comfortable than a missing control, because everything about the system looks like it is there.

What it allowed

An unmetered password oracle against real accounts in Azure SQL Database. One request per guess, no delay, no counter, no ceiling. A wordlist against a known address is bounded only by how fast the container answers.

The demo's own accounts are throwaway, so the loss is small. The property is not: this is the endpoint in front of the only table in the system holding anything that belongs to a person.

Decision

Count the failures, and refuse for five minutes after five of them.

options.Lockout.MaxFailedAccessAttempts = 5;
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
options.Lockout.AllowedForNewUsers = true;
if (await users.IsLockedOutAsync(user)) return refused;
if (!await users.CheckPasswordAsync(user, request.Password))
{
    await users.AccessFailedAsync(user);
    return refused;
}
await users.ResetAccessFailedCountAsync(user);

Four things about that, each of which is a decision rather than a line.

The lockout is checked before the password. Otherwise a locked account keeps answering guesses, and the lock only stops the attacker from learning the answer rather than from asking the question.

It is asked through UserManager rather than by reading the column, because that is what knows the window has expired.

A success resets the count. Without it, five wrong guesses spread over a week eventually lock somebody out of their own account, and a control that punishes the legitimate user is how a control gets removed.

The refusal after a lockout says exactly what a wrong password says. A distinct "this account is locked" tells a stranger the address is registered here, which is the one thing this endpoint has always gone out of its way not to say. The cost is a real user seeing a confusing message during their lockout, which is the smaller harm.

Why five and five, and what it actually buys

The numbers are arithmetic rather than strength. Five attempts per five minutes is twelve guesses an hour per account. Against a wordlist that is the difference between finishing and not finishing, and it is invisible to somebody who mistyped their password twice.

It is per account, not per address, which is what matters here: an attacker with a botnet defeats an IP limit and does not defeat this one.

What this is not

It is not a rate limit, and this application still has none. The audit that found this also found POST /api/errors/client and POST /api/auth/register unmetered, and GET /api/admin/selftest/exception a free way to evict the public error ring. A limiter is worth adding.

Why one was not added here instead: behind the edge, the origin sees the edge's address for every visitor, so an IP-partitioned limiter is a global cap rather than a per-attacker one, and the origin is directly reachable in any case because the origin lock is still owed (ADR: Azure Front Door, addendum), so an attacker can bypass the edge and forge whatever address they like. A limiter here would be worth having and it would not be the control this needed. Lockout does not depend on knowing who is asking.

Consequences

  • Six wrong guesses on an account stops working, including the sixth being right.
  • Three columns that have been carried, migrated and indexed since the schema was written are now load-bearing.
  • Two tests, and the one that matters asserts that the correct password is refused after five wrong ones, because a test that only checks the wrong password still passes when nothing is counting.

The policy, read from this build, with the reason it is five and five written above it:

// Five wrong passwords buys five minutes off.
//
// Without this, POST /api/auth/login
// is an unmetered password oracle against real accounts: the endpoint
// is public, there is no throttle in front of it, and every attempt
// costs an attacker one request. Five and five is the usual shape and
// the reason it works is arithmetic rather than strength: it turns
// thousands of guesses a minute into twelve an hour, per account,
// which is the difference between a wordlist finishing and not.
//
// The refusal after a lockout says the same sentence as a wrong
// password, deliberately. A distinct "this account is locked" is a
// reply that confirms the address is registered here, and the login
// endpoint already goes out of its way not to be that
// (ADR: A password guess should cost something).
options.Lockout.MaxFailedAccessAttempts = 5;
options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
options.Lockout.AllowedForNewUsers = true;

Live from api/TheYard.Api/Features/Accounts/Module.cs, region lockout, read from this build at 99df7a8.

Where it sits

This lives in the Api host: the lockout options are set in Composition/AuthRegistration.cs, and the sign-in path in Endpoints/AccountEndpoints.SignIn.cs checks IsLockedOutAsync before the password and calls AccessFailedAsync after a miss, using columns the DACPAC in TheYard.Database has always defined. No SOLID principle is at stake here, because the decision switches on a control ASP.NET Core Identity already ships and adds no class of its own. The cost lands on a real user who mistypes five times, waits five minutes and sees the same message a wrong password gets. Once the origin lock is in place and the server can see a real client address, a per-address rate limit would be worth adding beside it.

Files

Enforced by

Not machine-checked. Held by review.

Store

The Yard, home

Steven StoutStaff .NET engineerRemote

Production .NET that stays up. Built with AI, measured on every version.

Steven Stout

Hi, I'm Steve. I build the systems that make delivery boring in the best way, then coach people inside them.

  • 200+

    production releases, none took the platform down

    Conway Investment Research, 2019 to 2024. Sole engineer for the first three years on a live financial advisory platform.

    See how
  • 50%

    shorter release cycle

    Storee Construction, 2024 to 2026. Four ASP.NET applications onto one .NET 10 platform on Azure, with a four-person team I hired and mentored.

    See how

01Verified

Steven Stout

A real person, and the work is mine.

  • Identity

    Checked by LinkedIn, not by me.

    LinkedIn verified my government ID.

  • Running system

    You are looking at it.

    Version 1.0.5.273 is live. Nothing ships unless it passes the automated gates first.

That's who I am. Here's how I work.

02Strengths

Ten strengths, each with the proof beside it. The numbers match my resume and LinkedIn, and the live ones are read from this site as you look.

  • 01

    Keeps production alive

    200+ releases on a live financial platform, and none took it down. Sole engineer for the first three years.

    See the Conway work

  • 02

    Simplifies messy systems

    Four ASP.NET applications onto one .NET 10 platform on Azure, and a release cycle 50% shorter.

    See the Storee work

  • 03

    Marries dev and infrastructure

    Blue-green releases at Storee that flipped in about 5 seconds with nobody signed out, and Azure Front Door at two employers.

    See this site's cloud

  • 04

    Designs data that holds up

    White-label clients on one shared database, the isolation built into the data, and no cross-client issues.

    See the Conway work

  • 05

    Keeps AI-written code honest

    15 quality numbers that may only improve: 273 releases in a row with none worse.

    See the quality numbers

  • 06

    Resourceful

    $30,000+ cut from Azure and vendor spend at Conway. This site's Azure bill is public, resource by resource.

    See the bill

  • 07

    Builds people up

    Hired and mentored a four-person team. 13 colleagues recommend me by name.

    Read the recommendations

  • 08

    Takes ideas to production

    This site: designed, built and run solo, with 352 versions measured through one gate.

    How it was built

  • 09

    Writes clearly

    Posts on real engineering problems, in plain words.

    Read the blog

  • 10

    Owns decisions

    153 decision records, each with its tradeoff and the call I made.

    See the decision records

Built with AI. Gated so quality never slides.

Steven Stout’s showcase: a used-vehicle auction on .NET and React, built and run by one engineer, live on Azure, with its decisions written down.

No quality number has gotten worse at any release since 1.0.5.1 on 10 November: 273 releases in a row.

One engineer, an AI agent and a gate that checks 15 quality numbers on every release. 352 versions measured, with every result public, the worst days included.

82 releases in the last 7 days, each through the same gate.

Async methods with no CancellationToken, may only fall

11091.0.3.1391.0.5.2731.0.4.115, the ratchet
Every number, on the Quality page

TheYard, right nowLive

Answering in

unread

02505007501,000

server time at p95, the usual five minutes of the last day.

Azure this month

unread

the bill, by resource, read from Azure. The Admin tab shows every line.

Since the last roll

unread

 

rolled in place by the pipeline, behind one gate.

People who have visited

unread

30 days agotoday

Scanners, my own tools' and my own reads left out.

03Start here

04Where teams are heading

How I see engineering with AI, and the setup on this site that backs it.

AI-augmented teams · Architecture and ownership

AI writes more of the code. Someone still has to own what ships.

Teams are going to be heavily AI-augmented. That moves the senior job toward architecture and technical ownership: deciding what to build in pieces small enough to verify, and owning what ships.

  • Task tracking will get automated too. Judgment stays human: seeing a design fail at scale before it does.
  • On this site the AI's first design held the whole catalogue in memory. I caught it when the App Service plan hit 82 per cent and moved the work to the store.

What the AI wrote, what I decided

07Tech stack

  •    
  •    
  •    

Read from the build, never typed by hand

What TheYard runs on

What we use, where it runs, its AWS twin, the version as built, and the file that proves it.

Cloud patterns, not one vendor: every Azure piece in this stack has a named AWS twin. Mapped, not yet run on AWS.

  • .NET 1114 projects
  • React 19.3TypeScript 7.0
  • Azure9 Bicep files
  • 11GitHub Actions workflows
The whole stack, with the file that proves each line

The last release the gate stopped was 1.0.5.258 on 2 December, at its browser 1 of 2 job.

08How it is built

09How it is run

10Who and why

Next step

11What has to work, where is it today, and what does success look like?

Book 20 minutes opens an email to me with those three questions in it, and I answer with a time.

Book 20 minutes

Your email app should have opened with this message. If it did not, copy it and send it from any mailbox.

Or message me on LinkedIn