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.

Release files for badkeys 0.0.20

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.20
File Size Uploaded
badkeys-0.0.20.tar.gz 412.9 kB Details

Built distribution (wheel)

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

Total release size: 787.4 kB

Release files / badkeys-0.0.20.tar.gz

Download URL badkeys-0.0.20.tar.gz
Size 412.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b1cbf5722dd3daf34d7dd205b33d0a57650608ce7a3ce6d6be595c6cfa5d27f2
BLAKE2b-256 checksum
How to use checksums
4371e2a8f3e504f3cdaeded9c4726dff0929d38ec4ab447560019c690a4777a3
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.20-py3-none-any.whl

Download URL badkeys-0.0.20-py3-none-any.whl
Size 374.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dd75fffb6f1ca4b6b33684ef16dde5542e436cae0312a0f0e4c8f192f98d5dd1
BLAKE2b-256 checksum
How to use checksums
b0a29b73a5d629320382fea851f685f627f54c24122b82d3f72a78b30d3a20f4
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.20 This release

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