How to Identify Weak Ciphers and Deprecated Protocols Using testssl.sh
testssl.sh identifies weak ciphers and deprecated protocols through a three-stage pipeline that enumerates TLS versions, tests cipher suites per protocol, and applies grade caps when cipher strength falls below 112 bits or weak DH parameters are detected.
The open-source tool testssl.sh by drwetter provides comprehensive TLS/SSL security scanning capabilities for security professionals and system administrators. This guide explains how to identify weak ciphers and deprecated protocols using testssl.sh by examining its core detection logic, command-line options, and grading system implemented in the drwetter/testssl.sh repository.
Three-Stage Detection Pipeline
testssl.sh discovers insecure configurations through protocol enumeration, cipher-suite testing, and automated grading.
Protocol Enumeration
The scanner first determines which protocols a server supports. In testssl.sh, the function has_server_protocol() (lines 5895-5916) checks the PROTOS_OFFERED array to determine if a protocol is offered, not offered, or unknown. The main orchestrator run_protocols() (lines 5625-5640) iterates through all protocol versions from SSLv2 to TLS 1.3, calling has_server_protocol() for each to build the complete protocol support matrix.
Cipher-Suite Testing Per Protocol
For each detected protocol, testssl.sh executes specialized cipher tests using static lists generated by utils/generate_static_cipher_lists.sh. The core logic resides in run_std_cipherlists(), which processes these lists against the target server.
Specific vulnerability checks include:
- FREAK:
run_freak()tests for export-RSA ciphers using lists fromget_export_rsa_ciphers()(lines 309-327). - Logjam:
run_logjam()detects weak Diffie-Hellman parameters usingget_weak_dh_ciphers()(lines 29-44). - BEAST:
run_beast()identifies CBC-only ciphers viaget_cbc_ciphers()(lines 303-315).
All these functions call either OpenSSL (openssl s_client) or the native bash socket implementation, then parse the server response to determine cipher support.
Grading and Weak Cipher Detection
The script assigns security grades and caps them when weak configurations are found. When cipher strength falls below 112 bits, set_grade_cap "F" is invoked (line 1222). For weak DH groups detected during Logjam testing, set_grade_cap "B" is called (line 24215). These grade caps make weak ciphers immediately visible in the final report, providing clear pass/fail indicators for security audits.
Command-Line Options for Weak Cipher Detection
Use these flags to target specific weak cipher categories:
# Enumerate all protocols including deprecated SSLv2/SSLv3
testssl.sh -p example.com
# Display all ciphers per protocol with color-coded strength (weak ciphers appear in red)
testssl.sh -e --color 3 example.com
# Test specifically for FREAK (export RSA) and Logjam (weak DH) vulnerabilities
testssl.sh --freak --logjam example.com
# Full default scan including BEAST, POODLE, and cipher strength checks
testssl.sh example.com
# Export JSON results for automated CI/CD integration
testssl.sh --jsonfile result.json example.com
Key Source Files and Functions
| File | Role |
|---|---|
testssl.sh |
Core orchestration including run_protocols(), has_server_protocol(), and grading logic. |
utils/generate_static_cipher_lists.sh |
Generates static cipher lists including get_weak_dh_ciphers() (lines 29-44) and get_export_rsa_ciphers() (lines 309-327). |
etc/cipher-mapping.txt |
Maps OpenSSL cipher names to RFC identifiers for weakness classification. |
Summary
- testssl.sh identifies weak ciphers through a three-stage pipeline: protocol enumeration, cipher-suite testing, and grade capping.
- The
has_server_protocol()function (lines 5895-5916) determines protocol support, whilerun_std_cipherlists()tests cipher strength per protocol. - Weak ciphers below 112 bits trigger a grade F via
set_grade_cap, while weak DH parameters trigger grade B. - Use
-pto check for deprecated protocols like SSLv2/SSLv3, and-ewith--color 3to visualize weak ciphers in red.
Frequently Asked Questions
What is the minimum cipher strength threshold in testssl.sh?
testssl.sh caps the grade at F when it detects cipher strength below 112 bits. This threshold is enforced in the main testing loop at line 1222 of testssl.sh through the set_grade_cap "F" function call.
How does testssl.sh detect deprecated SSL protocols?
The script uses has_server_protocol() (lines 5895-5916) to check the PROTOS_OFFERED array for each protocol version. When you run testssl.sh -p, the run_protocols() function (lines 5625-5640) iterates through SSLv2, SSLv3, and all TLS versions to report which deprecated protocols remain enabled.
What is the difference between FREAK and Logjam detection in testssl.sh?
FREAK detection targets export-grade RSA ciphers using run_freak() and cipher lists from get_export_rsa_ciphers() (lines 309-327). Logjam detection targets weak Diffie-Hellman parameters using run_logjam() and get_weak_dh_ciphers() (lines 29-44). While FREAK exploits RSA key exchange weaknesses, Logjam exploits weak DH primes commonly shared across servers.
How can I automate weak cipher detection in CI/CD pipelines?
Use the --jsonfile or --csvfile flags to export machine-readable results. For example, testssl.sh --jsonfile result.json example.com generates structured output that CI systems can parse to fail builds when set_grade_cap reports grade F or B, or when deprecated protocols like SSLv3 appear in the PROTOS_OFFERED results.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →