Skip to main content

badkeys

Tool and library to check cryptographic public keys for known vulnerabilities

what?

badkeys checks public keys in various formats for known vulnerabilities. A web version can be found at badkeys.info.

install

badkeys can be installed via pip:

pip3 install badkeys

You may want to use a virtual environment. For details about different installation options, please check the official Python documentation. Alternatively, you can directly call ./badkeys-cli directly from the git repository.

You can find an overview of badkeys packages for Linux distributions and other operating systems on Repology.

usage

Before using badkeys, you need to download the blocklist data:

badkeys --update-bl

After that, you can call badkeys and pass files with cryptographic public keys as the parameter:

badkeys test.crt my.key

It will automatically try to detect the file format. Supported are public and private keys in PEM format (both PKCS #1 and PKCS #8), X.509 certificates, certificate signing requests (CSRs) and SSH public keys. You can find some test keys in the tests/data directory.

By default, badkeys will only output information about vulnerable keys, meaning no output will be generated if no vulnerabilities are found. The -a parameter creates output for all keys.

The command line tool will return 0 if keys were scanned, no errors occurred, and no vulnerabilities were detected. It returns 1 for application errors, 2 if any input could not be scanned (parser errors, unsupported key types, files without a key), and 4 if a vulnerable key was found. Return codes can be combined as a bitmask. (E.g., 2|4=6 indicates that some keys were vulnerable and some could not be scanned.)

scanning

badkeys can scan SSH and TLS hosts and automatically check their public keys. This can be enabled with the parameters -s (SSH) and -t (TLS). By default, SSH will be scanned on port 22 and TLS will be scanned on several ports for common protocols (https/443, smtps/465, ldaps/636, ftps/990, imaps/993, pop3s/995 and 8443, which is commonly used as a non-standard https port).

Alternative ports can be configured with --tls-ports and --ssh-ports.

TLS and SSH scanning can be combined:

badkeys -ts example.org

Note that the scanning modes have limitations. It is often more desirable to use other tools to collect TLS/SSH keys and scan them locally with badkeys.

SSH scanning needs paramiko as an additional dependency.

TLS scanning can't detect multiple certificates on one host (e.g. ECDSA and RSA). This is a limitation of Python's ssl.get_server_certificate() function.

Python module and API

badkeys can also be used as a Python module. However, currently the software is in beta state and the API may change regularly.

about

badkeys was written by Hanno Böck.

This work was initially funded in 2022 by Industriens Fond through the CIDI project (Cybersecure IOT in Danish Industry) and the Center for Information Security and Trust (CISAT) at the IT University of Copenhagen, Denmark. In 2025/2026, badkeys was supported by NLnet's NGI0 Core Fund.

Metadata

Release files for badkeys 0.0.21

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for badkeys 0.0.21
File Size Uploaded
badkeys-0.0.21.tar.gz 414.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for badkeys 0.0.21
File Interpreter ABI Platform
badkeys-0.0.21-py3-none-any.whl Python 3 none any Details

Total release size: 789.0 kB

Release files / badkeys-0.0.21.tar.gz

Download URL badkeys-0.0.21.tar.gz
Size 414.2 kB
Tags Source
SHA-256 checksum
How to use checksums
a4323c2a3de67e81786e87271d8c1cb302eed89054b770f85dbf1f95ce4264ad
BLAKE2b-256 checksum
How to use checksums
a1056f1939e3fb4b7cdf7799d7a200c0151ca6a1662042a283b658fe98627f9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / badkeys-0.0.21-py3-none-any.whl

Download URL badkeys-0.0.21-py3-none-any.whl
Size 374.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c7cf80bd855d1b6c98cd53fb40a5c4c56b3deb845bb85586ecbd0eed65fd764
BLAKE2b-256 checksum
How to use checksums
2ea2a1622e0637766f4166473a21eb9d50016f871180495f85e00cec0bb53f0a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

0.0.21 This release

2 release files

0.0.20

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page