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.22

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.22
File Size Uploaded Provenance Actions
badkeys-0.0.22.tar.gz 415.7 kB Without provenance Details for badkeys-0.0.22.tar.gz

Built distribution (wheel)

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

Total release size: 790.5 kB

Release files / badkeys-0.0.22.tar.gz

Download URL badkeys-0.0.22.tar.gz
Size 415.7 kB
Tags Source
SHA-256 checksum
How to use checksums
abf12aa9ecd253f7556959a966a4a39b35bd2d452c1a5b12e220b182fb0fb172
BLAKE2b-256 checksum
How to use checksums
7eb7b27f5d7e2c70301ed8f6bd743a5d830195aa1dd49b708d786261873e9b8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

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

Download URL badkeys-0.0.22-py3-none-any.whl
Size 374.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7f998b018c91be5a6a0140ce54be628c097aa4c880ae9aa28707f4aa11b54e8
BLAKE2b-256 checksum
How to use checksums
4d3b0774b1419650655a4fdfc2dd0dd817d8963b661889363e21fc111546032e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for badkeys 0.0.22

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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