<!-- Source: @site/projects/sqlens-for-laravel/docs/rules/sec-auth-role-no-password-locked.md -->
<!-- Canonical: https://docs.pushery.com/sqlens-for-laravel/rules/sec-auth-role-no-password-locked/ -->

# SEC.AUTH.ROLE_NO_PASSWORD_LOCKED — A locked account with nothing behind the lock

> Unlocking is one statement, and what comes back is an account anyone who knows its name can log into.

- **Category:** security
- **Severity:** low
- **Level:** 0
- **Confidence:** deterministic
- **Downtime class:** none — the finding is about an account, not about a statement
- **Stability:** stable
- **Suites:** audit
- **Applies to:** MySQL 8.4

## Why this is reported at all

The account cannot be used as it stands, so it is not the thing to fix first — hence `low`. It is
reported rather than skipped because of what the lock actually is: a flag,
`ALTER USER … ACCOUNT UNLOCK` clears it, and it changes nothing about the stored credential. What
comes back is an account anyone who knows its name can log into.

A report that stayed silent here would let `ACCOUNT LOCK` read as a fix for a missing password. It
is not a fix; it is a door held shut by a latch somebody can lift.

## Bad

```sql
-- Locked, and with nothing behind the lock.
CREATE USER 'legacy_import'@'%' IDENTIFIED WITH caching_sha2_password;
ALTER USER 'legacy_import'@'%' ACCOUNT LOCK;
```

## Good

```sql
-- Give it a password while it is out of use…
ALTER USER 'legacy_import'@'%' IDENTIFIED BY 'a real secret';

-- …or drop it, if nothing needs it any more.
DROP USER 'legacy_import'@'%';
```

## Why a separate rule rather than a lower severity

Severity in this package is metadata on the **rule**, so "the same finding, less urgent" cannot be
said by one rule reading its subject twice — it has to be a second id. That constraint turns out to
be the right shape here anyway: the two findings have different fixes and belong in different places
on a work list. Exactly one of the two ever speaks about a given account.

## What is not reported

The same three exclusions as [`SEC.AUTH.ROLE_NO_PASSWORD`](https://docs.pushery.com/sqlens-for-laravel/rules/sec-auth-role-no-password.md): an account
whose credential lives outside the database, the engine's own system accounts, and an account whose
credential state could not be read — the last one as **undetermined**, never as an account without a
password.

An account deliberately parked and about to be dropped does show up here. That is intended rather
than a miss: dropping it is one of the two fixes above.

## Related

- [`SEC.AUTH.ROLE_NO_PASSWORD`](https://docs.pushery.com/sqlens-for-laravel/rules/sec-auth-role-no-password.md) — the same missing password on an account
  that can log in right now.
- [`SEC.AUTH.ROLE_DEPRECATED_PASSWORD_HASH_LOCKED`](https://docs.pushery.com/sqlens-for-laravel/rules/sec-auth-role-deprecated-password-hash-locked.md) —
  the parallel case for a password that exists but is stored under a retired verifier.
