Dev.to Security 🔐 Cybersecurity 👁 0 📖 5 min read

A guessed password exposed data on 190K exchange customers. Here's a k-anonymity breach check in plain Node.js

On November 26, the Latin American crypto exchange Buda disclosed that an attacker had got into its accounting system (Odoo, kept separate from the trading platform) through an external collaborator's account, after gues

On November 26, the Latin American crypto exchange Buda disclosed that an attacker had got into its accounting system (Odoo, kept separate from the trading platform) through an external collaborator's account, after guessing that person's password. Billing data on about 190,000 people in Chile, Colombia and Peru was copied: names, national ID numbers, billed commissions and, for some customers, emails, phone numbers and addresses (Buda's notice, in Spanish; Cointelegraph). Buda says it found no evidence of access to the platform, wallets or funds.

The notice doesn't say what the password was or whether the account had a second factor, so I won't guess about this particular login. The pattern itself is familiar: a back-office account, held by someone outside the company, protected by a password that could be guessed.

What "guessed" usually means

Online guessing is slow, so attackers spend their attempts on the passwords people choose most often, and the biggest lists of those come from earlier breaches. That's why NIST's current guidance, SP 800-63B-4 (final since July 2025), tells verifiers to compare every new password against a blocklist of commonly used, expected or compromised passwords: breach corpuses, dictionary words, and context words such as the service name or the username.

The same section drops some old habits. The minimum length is 15 characters when the password is the only factor and 8 when it's part of MFA. Composition rules ("one uppercase, one symbol") are out, and so are forced periodic changes, though a change is required when there's evidence the password was compromised. Section 3.2.2 adds rate limiting: no more than 100 consecutive failed attempts on one account.

The blocklist is the awkward part, because checking a password against breach data seems to require sending the password somewhere.

k-anonymity in one request

Have I Been Pwned's Pwned Passwords API gets around that. You hash the password with SHA-1 and send only the first 5 of its 40 hex characters:

GET https://api.pwnedpasswords.com/range/CBFDA

The server answers with the remaining 35 characters of every hash in its corpus that starts with that prefix, each followed by a count. In my runs on November 30, that was about 2,000 rows per prefix. You look for your own suffix locally, so the full hash never leaves your machine and the server can't tell which of those rows you were after.

According to the docs, the API needs no key and has no rate limit. An Add-Padding: true header mixes in extra rows with a count of 0, so someone watching the encrypted traffic can't work out the prefix from the size of the response, and those rows can be discarded.

The script

No dependencies. Node 18+ for the global fetch.

// pwned-check.mjs
import { createHash } from 'node:crypto';

const API = 'https://api.pwnedpasswords.com/range/';

export const sha1Hex = (s) => createHash('sha1').update(s, 'utf8').digest('hex').toUpperCase();

// The API answers with "SUFFIX:COUNT" lines. With Add-Padding, extra rows with a count of 0 are mixed in.
export function parseRange(body) {
  const hits = new Map();
  let padding = 0;
  for (const line of body.split(/\r?\n/)) {
    const [suffix, n] = line.trim().split(':');
    if (!suffix || n === undefined) continue;
    const count = Number(n);
    if (count === 0) { padding++; continue; }
    hits.set(suffix.toUpperCase(), count);
  }
  return { hits, padding };
}

export async function pwnedCount(password, { timeoutMs = 5000 } = {}) {
  const hash = sha1Hex(password);
  const prefix = hash.slice(0, 5);
  const suffix = hash.slice(5);
  const res = await fetch(API + prefix, {
    headers: { 'Add-Padding': 'true', 'User-Agent': 'pwned-check-example' },
    signal: AbortSignal.timeout(timeoutMs),
  });
  if (!res.ok) throw new Error(`range API answered HTTP ${res.status}`);
  const { hits, padding } = parseRange(await res.text());
  return { prefix, count: hits.get(suffix) ?? 0, rows: hits.size + padding, padding };
}

// What a verifier checks when a password is set or changed (NIST SP 800-63B-4, section 3.1.1.2):
// a minimum length (15 if the password is the only factor, 8 if it's part of MFA), no composition rules,
// and a blocklist that covers breached passwords and context words such as the service name or username.
export async function checkNewPassword(password, { context = [], withMfa = false, failOpen = false } = {}) {
  const problems = [];
  const min = withMfa ? 8 : 15;
  if ([...password].length < min) problems.push(`shorter than ${min} characters`);
  const lower = password.toLowerCase();
  for (const word of context) if (word && lower.includes(word.toLowerCase())) problems.push(`contains "${word}"`);
  try {
    const { count } = await pwnedCount(password);
    if (count > 0) problems.push(`appears ${count.toLocaleString('en-US')} times in breach data`);
  } catch (e) {
    if (!failOpen) problems.push(`breach check unavailable (${e.message})`);
  }
  return { ok: problems.length === 0, problems };
}

The full file adds a small CLI. --selftest runs offline: it checks SHA-1 against the FIPS 180 example for "abc" and checks that the parser drops padding rows. --demo queries a few well-known weak passwords plus a fresh random one. - reads one password from stdin, which keeps it out of your shell history and the process list.

Running it

$ node pwned-check.mjs --selftest
PASS SHA-1("abc") matches the FIPS 180 example
PASS parser keeps real rows and drops padding rows
PASS only the 5-character prefix would be sent

$ node pwned-check.mjs --demo
"password123"                    sent CBFDA  got 2030 rows (58 padding)  seen 2,266,677 times
"Summer2026!"                    sent F1DF7  got 2084 rows (107 padding)  seen 150 times
"correct horse battery staple"   sent ABF7A  got 2065 rows (51 padding)  seen 391 times
<random 24 chars>                sent 16413  got 2036 rows (79 padding)  seen 0 times

checkNewPassword("Summer2026!") -> {"ok":false,"problems":["shorter than 15 characters","appears 150 times in breach data"]}

$ printf '%s' "password123" | node pwned-check.mjs -
found: seen 2,266,677 times in breach data

Counts are from November 30, 2026 and can grow as the corpus does. The padding count changes on every request.

Summer2026! is the interesting one. It has an uppercase letter, a symbol and digits, so it passes the composition rules plenty of sign-up forms still enforce, and it has turned up 150 times in breach data. The length rule rejects it as well.

Where to call it, and what it doesn't cover

  • Call it on sign-up and on every password change, before you hash and store the password. Store passwords with a slow, salted hash such as Argon2id, scrypt or bcrypt. SHA-1 here is only a lookup key.
  • Call it at login too if you want to catch passwords that showed up in a breach after they were set. NIST requires a forced change when there's evidence of compromise, and I'd count a hit as that evidence.
  • Decide what happens when the API is unreachable. checkNewPassword fails closed by default: it returns a "breach check unavailable" problem, so the password isn't accepted. Pass failOpen: true to let it through instead.
  • For Windows domains, the same endpoint returns NTLM hashes with ?mode=ntlm.

A blocklist takes the easiest guesses off the table, and the rate limit and a second factor deal with the rest. Buda gave its customers the user-side version of that advice: turn on the second factor and don't reuse passwords. The same rules belong on every outside account that can log in to a back-office system, contractors included, since that's the kind of login that was guessed here.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.