Skip to main content

Check cryptographic keys for known weaknesses

Project description

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.

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.

badkeys is currently funded through the NGI0 Core Fund, a fund established by NLnet with financial support from the European Commission's Next Generation Internet programme, under the aegis of DG Communications Networks, Content and Technology under grant agreement No 101092990.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

badkeys-0.0.17.tar.gz (399.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

badkeys-0.0.17-py3-none-any.whl (371.7 kB view details)

Uploaded Python 3

File details

Details for the file badkeys-0.0.17.tar.gz.

File metadata

  • Download URL: badkeys-0.0.17.tar.gz
  • Upload date:
  • Size: 399.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for badkeys-0.0.17.tar.gz
Algorithm Hash digest
SHA256 5562f2276a0343c5cfa5ecc54dc0e658e1b65fd36016858c04af9f33f7e9f826
MD5 e651c6b49bc4d6e8d769b7435b0d0841
BLAKE2b-256 5bb89c5fdec4eb0b0a8b2e6a5a7a2d6da0fa5a905601a5e6a8c1f2aecb22f5c7

See more details on using hashes here.

File details

Details for the file badkeys-0.0.17-py3-none-any.whl.

File metadata

  • Download URL: badkeys-0.0.17-py3-none-any.whl
  • Upload date:
  • Size: 371.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for badkeys-0.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 cb44bffc4ebc43c2f59914365407693078482f4ee9d25f46ee11ce63ce7dda77
MD5 40e73304dbd8cbbc41fffa2fc9a77a28
BLAKE2b-256 df2d0e18872a51a16dc6757e6569305ab5e45352cdf9be12a102ef8443074b7a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page