Blooming Password

Blooming Password

A program that implements the NIST 800-63-3b Banned Password Check using a bloom filter built from the Have I been pwned SHA1 password hash list. The Have I Been Pwned v6 list contains 572611621 password hashes and is 24GB uncompressed (as of 13 Jun 2020). A bloom filter of this list is only 982MB(with 1 in 1000 False Positive Rate https://hur.st/bloomfilter/?n=572611621&p=0.001&m=&k=10) and will fit entirely into memory on a virtual machine or Docker container with just 4GB of RAM.

Why a Bloom Filter?

It's one of the simplest, smallest and fastest data structures for this task. Bloom filters have constant time O(1) performance (where K is the constant) for insertion and lookup. K is the number of times a password is hashed. Bloom filters can easily handle billions of banned password hashes with very modest resources. When a test for membership returns 418 (I'm a teapot) then it's safe to use that password.

Partial SHA1 Hashes

SHA1 hashes are 20 bytes of raw binary data and thus typically hex encoded for a total of 40 characters. Blooming Password uses just the first 16 hex encoded characters of the hashes to build the bloom filter and to test the filter for membership. The program rejects complete hashes if they are sent. False positive rates in the bloom filter are not impacted by the shortening of the SHA1 password hashes. The cardinality of the set is unchanged. The FP rate is .001 (1 in 1000 https://hur.st/bloomfilter/?n=572611621&p=0.001&m=&k=10). You may verify the cardinality is unchanged after truncating the hashes.

  $ wc -l pwned-passwords-sha1-ordered-by-count-v6.txt
  572611621 pwned-passwords-sha1-ordered-by-count-v6.txt

  $ sort -T /tmp/ -u 1-16-pwned-passwords-sha1-ordered-by-count-v6.txt | wc -l
  572611621

How to Construct the Partial SHA1 Hash List

  $ 7z e pwned-passwords-sha1-ordered-by-count-v6.7z

  $ cut -c 1-16 pwned-passwords-sha1-ordered-by-count-v6.txt > 1-16-pwned-passwords-sha1-ordered-by-count-v6.txt

  $ head 1-16-pwned-passwords-sha1-ordered-by-count-v6.txt
	7C4A8D09CA3762AF
	F7C3BC1D808E0473
	B1B3773A05C0ED01
	5BAA61E4C9B93F3F
	3D4F2BF07DC1BE38
  ...

How to Create the Bloom Filter

  $ tools/blooming-password-filter-create /path/to/1-16-pwned-passwords-sha1-ordered-by-count-v6.txt /path/to/1-16-pwned-passwords-sha1-ordered-by-count-v6.filter

Test the Bloom Filter for Membership

Send the first 16 characters of the hex encoded SHA1 hash to the Blooming Password program. Some examples using curl:

Return Codes

  • 200 - OK. The hash is probably in the bloom filter.
  • 400 - Bad request. The client sent a bad request.
  • 418 - I'm a teapot. The hash is definitely not in the bloom filter.

Note: If the value is in the filter, the server will return a 200 status code, otherwise a 418 (I'm a teapot). The latter is used to be distinguishable from a 404 that you might receive for other reasons (e.g. misconfigured servers).

Benchmark

Server used is AWS t3.medium instance and one of the previous version(5) of HaveIBeenPwned Pwned Passwords list, which was latest when test was performed.

root@ip-10-20-19-7:~# ./vegeta attack -targets=benchmark-test.txt -rate=50 -duration=60s | ./vegeta report -type=text
Requests      [total, rate, throughput]         3000, 50.02, 5.35
Duration      [total, attack, wait]             59.98s, 59.98s, 503.579µs
Latencies     [min, mean, 50, 90, 95, 99, max]  359.298µs, 602.367µs, 548.977µs, 633.498µs, 661.026µs, 798.467µs, 58.958ms
Bytes In      [total, mean]                     72491, 24.16
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           10.70%
Status Codes  [code:count]                      200:321  418:2679
Error Set:
418 I'm a teapot
root@ip-10-20-19-7:~# ./vegeta attack -targets=benchmark-test.txt -rate=100 -duration=60s | ./vegeta report -type=text
Requests      [total, rate, throughput]         6000, 100.02, 10.70
Duration      [total, attack, wait]             59.99s, 59.99s, 370.664µs
Latencies     [min, mean, 50, 90, 95, 99, max]  314.501µs, 515.238µs, 451.698µs, 546.85µs, 593.354µs, 939.655µs, 59.576ms
Bytes In      [total, mean]                     144982, 24.16
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           10.70%
Status Codes  [code:count]                      200:642  418:5358
Error Set:
418 I'm a teapot
root@ip-10-20-19-7:~# ./vegeta attack -targets=benchmark-test.txt -rate=200 -duration=60s | ./vegeta report -type=text
Requests      [total, rate, throughput]         12000, 200.02, 21.40
Duration      [total, attack, wait]             59.995s, 59.995s, 329.075µs
Latencies     [min, mean, 50, 90, 95, 99, max]  289.114µs, 671.934µs, 359.274µs, 444.906µs, 506.313µs, 3.164ms, 102.726ms
Bytes In      [total, mean]                     289964, 24.16
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           10.70%
Status Codes  [code:count]                      200:1284  418:10716
Error Set:
418 I'm a teapot
root@ip-10-20-19-7:~# ./vegeta attack -targets=benchmark-test.txt -rate=400 -duration=60s | ./vegeta report -type=text
Requests      [total, rate, throughput]         24000, 400.02, 42.85
Duration      [total, attack, wait]             59.998s, 59.998s, 879.735µs
Latencies     [min, mean, 50, 90, 95, 99, max]  271.21µs, 481.118ms, 360.287µs, 2.016s, 2.995s, 3.475s, 3.867s
Bytes In      [total, mean]                     580241, 24.18
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           10.71%
Status Codes  [code:count]                      200:2571  418:21429
Error Set:
418 I'm a teapot
root@ip-10-20-19-7:~# ./vegeta attack -targets=benchmark-test.txt -rate=800 -duration=60s | ./vegeta report -type=text
Requests      [total, rate, throughput]         48000, 800.02, 85.70
Duration      [total, attack, wait]             59.999s, 59.999s, 362.645µs
Latencies     [min, mean, 50, 90, 95, 99, max]  265.386µs, 819.493ms, 335.5µs, 3.358s, 4.978s, 6.553s, 7.988s
Bytes In      [total, mean]                     1160482, 24.18
Bytes Out     [total, mean]                     0, 0.00
Success       [ratio]                           10.71%
Status Codes  [code:count]                      200:5142  418:42858
Error Set:
418 I'm a teapot

Blooming Password - Create filter

The Create filter program creates a new bloom filter. It takes two arguments.

  1. Path to the text file containing partial SHA1 hashes (one hash per line). The partial SHA1 hashes must be UPPERCASE.
  2. Path to where you'd like to save the bloom filter.

What the partial SHA1 hash file should look like

head 1-16-pwned-passwords-sha1-ordered-by-count-v6.txt
7C4A8D09CA3762AF
F7C3BC1D808E0473
B1B3773A05C0ED01
5BAA61E4C9B93F3F
3D4F2BF07DC1BE38
...

How to run Create filter

./tools/blooming-password-filter-create /path/to/1-16-pwned-passwords-sha1-ordered-by-count-v6.txt /path/to/1-16-pwned-passwords-sha1-ordered-by-count-v6.filter

Docker

Add - https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources

docker build -t blooming-password .
docker run --cap-drop=all --security-opt=no-new-privileges:true --read-only -v /etc/ssl/:/etc/ssl/:ro --publish 9379:9379 --detach --name BP-Server blooming-password
docker logs BP-Server

Notes

  • The Blooming Password blooming-password-server.go program reads the bloom filter produced by tools/blooming-password-filter-create.go.
  • Blooming Password is written in Go.
  • It uses willf's excellent bloom filter implementation.
Similar Resources

A password manager as a CLI, where you can use a master password to retrieve a specified password and store it in your clipboard

A password manager as a CLI, where you can use a master password to retrieve a specified password and store it in your clipboard

Password manager Description CLI to store and retrieve passwords. The retrieved password will be stored on your clipboard! Usage 1.Start with Go go ru

Dec 16, 2021

Time-Based One-Time Password (TOTP) and HMAC-Based One-Time Password (HOTP) library for Go.

otpgo HMAC-Based and Time-Based One-Time Password (HOTP and TOTP) library for Go. Implements RFC 4226 and RFC 6238. Contents Supported Operations Read

Dec 19, 2022

Chrome-Password-Dumper - Chrome password dumper written in Go for Linux and Windows

Chrome-Password-Dumper Chrome password dumper written in Go for Linux and Window

Dec 19, 2022

Package go-otp implements one-time-password generators used in 2-factor authentication systems like RSA-tokens. Currently this supports both HOTP (RFC-4226), TOTP (RFC-6238) and Base32 encoding (RFC-3548) for Google Authenticator compatibility

OTP Package go-otp implements one-time-password generators used in 2-factor authentication systems like RSA-tokens and Google Authenticator. Currently

Oct 8, 2022

The slightly more awesome standard unix password manager for teams

The slightly more awesome standard unix password manager for teams

gopass Introduction gopass is a password manager for the command line written in Go. It supports all major operating systems (Linux, MacOS, BSD) as we

Jan 4, 2023

Commandline Utility To Create Secure Password Hashes (scrypt / bcrypt / pbkdf2)

passhash Create Secure Password Hashes with different algorithms. I/O format is base64 conforming to RFC 4648 (also known as url safe base64 encoding)

Oct 10, 2022

A light package for generating and comparing password hashing with argon2 in Go

argon2-hashing argon2-hashing provides a light wrapper around Go's argon2 package. Argon2 was the winner of the Password Hashing Competition that make

Sep 27, 2022

Argon2 password hashing package for go with constant time hash comparison

argon2pw Argon2 password hashing package with constant time hash comparison Preface: Argon2 was selected as the winner of the Password Hashing Competi

Sep 27, 2022

Password generator written in Go

go-generate-password Password generator written in Go. Use as a library or as a CLI. Usage CLI go-generate-password can be used on the cli, just insta

Dec 19, 2022

Validate the Strength of a Password in Go

Validate the Strength of a Password in Go

go-password-validator Simple password validator using raw entropy values. Hit the project with a star if you find it useful ⭐ Supported by Qvault This

Jan 6, 2023

:key: Idiotproof golang password validation library inspired by Python's passlib

passlib for go Python's passlib is quite an amazing library. I'm not sure there's a password library in existence with more thought put into it, or wi

Dec 30, 2022

A convenience library for generating, comparing and inspecting password hashes using the scrypt KDF in Go 🔑

simple-scrypt simple-scrypt provides a convenience wrapper around Go's existing scrypt package that makes it easier to securely derive strong keys ("h

Dec 22, 2022

simple-jwt-provider - Simple and lightweight provider which exhibits JWTs, supports login, password-reset (via mail) and user management.

Simple and lightweight JWT-Provider written in go (golang). It exhibits JWT for the in postgres persisted user, which can be managed via api. Also, a password-reset flow via mail verification is available. User specific custom-claims also available for jwt-generation and mail rendering.

Dec 18, 2022

A quick and easy password protected web server for your files. httpfolder makes downloading/uploading files from your current working directory easy, even for fairly large files.

httpfolder A quick and easy password protected web server for your files. httpfolder makes downloading/uploading files from your current working direc

Sep 12, 2022

A simple Go script to brute force or parse a password-protected PKCS#12 (PFX/P12) file.

A simple Go script to brute force or parse a password-protected PKCS#12 (PFX/P12) file.

A simple Go script to brute force or parse a password-protected PKCS#12 (PFX/P12) file.

Oct 14, 2022

A simple and lightweight encrypted password manager written in Go.

A simple and lightweight encrypted password manager written in Go.

Osiris Password Manager A simple and lightweight encrypted password manager written in Go

Jun 16, 2022

A simple and lightweight encrypted password manager written in Go.

A simple and lightweight encrypted password manager written in Go.

A simple and lightweight encrypted password manager written in Go.

Jun 16, 2022

Secure, private and feature-rich CLI password manager

Secure, private and feature-rich CLI password manager

Kure Kure is a free and open-source password manager for the command-line. This project aims to offer the most secure and private way of operating wit

Nov 17, 2022
A simple and lightweight encrypted password manager written in Go.
A simple and lightweight encrypted password manager written in Go.

Osiris Password Manager A simple and lightweight encrypted password manager written in Go

Jun 16, 2022
Secret - Encrypt anything with a password
 Secret - Encrypt anything with a password

Secret - Encrypt anything with a password Ever wanted to hide a file? Now you can do it really easily! Usage secret {-e/--encrypt | -d/--decrypt} <sou

Aug 10, 2022
:key: Idiotproof golang password validation library inspired by Python's passlib

passlib for go 100% modules-free. Python's passlib is quite an amazing library. I'm not sure there's a password library in existence with more thought

Dec 19, 2022
A convenience library for generating, comparing and inspecting password hashes using the scrypt KDF in Go 🔑

simple-scrypt simple-scrypt provides a convenience wrapper around Go's existing scrypt package that makes it easier to securely derive strong keys ("h

Dec 22, 2022
 🚀 cpwd is create password tool
 🚀 cpwd is create password tool

cpwd ?? cpwd is create password tool Install source code git clone https://github.com/songqii/cpwd_code.git cd $GOPATH/src/cpwd_code go build brew br

Dec 29, 2021
Use the HashPassword function to generate a hashed value for the provided password

hasher Use the 'HashPassword' function to generate a hashed value for the provided password. h, err := hasher.HashPassword("password") // h == XohImNo

Nov 1, 2021
eval the strength of a password

mpasswordeval eval the strength of a password 校验密码的安全性 包含以下几点校验 常规规则校验 密码长度 (必须指定) 是否包含数字 是否包含大写字母 是否包含小写字母 是否包含特殊符号 是否通过zxcvbn 是否通过pwned 是否在常用弱密码 使用示

Nov 22, 2022
profane password? generator

profaneword profane password generator (probably insecure), as suggested by u/gatestone. This is still missing some requirements: special characters e

Apr 21, 2022
A tiny secure-random password generator
A tiny secure-random password generator

go-psw A tiny golang tool for generating a crypto-random password in a terminal. Installation go install github.com/hedhyw/go-psw/cmd/psw@latest Usage

Jun 23, 2022