From ba28aa09cebfba17fd16de2af6fedf7ecc76eea5 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 15 Apr 2024 19:11:11 +0200 Subject: Adding upstream version 3.2~rc3+dfsg. Signed-off-by: Daniel Baumann --- .dockerignore | 11 + .editorconfig | 10 + .gitattributes | 11 + .github/ISSUE_TEMPLATE/bug_report.md | 33 + .github/ISSUE_TEMPLATE/feature_request.md | 26 + .github/ISSUE_TEMPLATE/other-issues---question.md | 11 + .github/dependabot.yml | 12 + .github/workflows/codespell.yml | 16 + .github/workflows/docker-3.2.yml | 63 + .github/workflows/test.yml | 40 + .gitignore | 32 + CHANGELOG.md | 531 + CONTRIBUTING.md | 21 + CREDITS.md | 200 + Coding_Convention.md | 72 + Dockerfile | 40 + Dockerfile.git | 24 + Dockerfile.md | 49 + LICENSE | 339 + Readme.md | 137 + bin/OPENSSL-LICENSE.txt | 127 + bin/Readme.md | 136 + bin/fedora-dirk-ipv6.diff | 531 + bin/krb5-ciphers.txt | 54 + bin/new-ciphers.diffed2vanilla.txt | 102 + bin/new-ciphers.std_distro.txt | 188 + bin/openssl-Vall.krb.txt | 144 + bin/openssl-Vall.txt | 192 + doc/Makefile | 17 + doc/template.html | 47 + doc/testssl.1 | 606 + doc/testssl.1.html | 690 + doc/testssl.1.md | 586 + etc/Apple.pem | 4335 ++++ etc/DST Root CA X3.txt | 20 + etc/Java.pem | 2623 +++ etc/Linux.pem | 3228 +++ etc/Microsoft.pem | 12231 ++++++++++ etc/Mozilla.pem | 3451 +++ etc/README.md | 52 + etc/SSLSocketClient.java | 91 + etc/ca_hashes.txt | 427 + etc/cipher-mapping.txt | 370 + etc/client-simulation.txt | 3443 +++ etc/client-simulation.wiresharked.md | 26 + etc/client-simulation.wiresharked.txt | 816 + etc/common-primes.txt | 308 + etc/curves-mapping.txt | 47 + etc/curves.txt | 34 + etc/openssl.cnf | 346 + etc/tls_data.txt | 343 + openssl-iana.mapping.html | 477 + t/00_testssl_help.t | 63 + t/01_testssl_banner.t | 49 + t/02_clientsim_txt_parsable.t | 27 + t/05_ca_hashes_up_to_date.t | 16 + t/10_baseline_ipv4_http.t | 73 + t/11_baseline_ipv6_http.t.DISABLED | 61 + t/21_baseline_starttls.t | 193 + t/23_client_simulation.t | 79 + t/31_isJSON_valid.t | 88 + t/32_isHTML_valid.t | 92 + t/33_isJSON_severitylevel_valid.t | 69 + t/51_badssl.com.t | 147 + t/59_hpkp.t.tmpDISABLED | 84 + t/61_diff_testsslsh.t | 70 + t/Readme.md | 10 + t/baseline_data/default_testssl.csvfile | 140 + testssl.sh | 24133 ++++++++++++++++++++ utils/00_unittest_baseline.sh | 104 + utils/ccs-injection.bash | 356 + utils/checkcert.sh | 343 + utils/create_ca_hashes.sh | 47 + utils/curves.bash | 94 + utils/docker-debian10.tls13only.start.sh | 33 + utils/docker-nginx.tls13-earlydata.start.sh | 56 + utils/generate_static_cipher_lists.sh | 372 + utils/gmap2testssl.sh | 168 + utils/heartbleed.bash | 307 + utils/hexstream2cipher.sh | 38 + utils/hexstream2curves.sh | 38 + utils/make-openssl.sh | 160 + utils/make-openssl111.sh | 98 + utils/parse_client_ciphers.pl | 45 + utils/prototype.ssl2proto-check.bash | 232 + utils/prototype.tls-protocol-checker.bash | 372 + utils/resume.sh | 22 + utils/ticketbleed.bash | 352 + utils/update_client_sim_data.pl | 506 + 89 files changed, 66903 insertions(+) create mode 100644 .dockerignore create mode 100644 .editorconfig create mode 100644 .gitattributes create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md create mode 100644 .github/ISSUE_TEMPLATE/other-issues---question.md create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/codespell.yml create mode 100644 .github/workflows/docker-3.2.yml create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 CONTRIBUTING.md create mode 100644 CREDITS.md create mode 100644 Coding_Convention.md create mode 100644 Dockerfile create mode 100644 Dockerfile.git create mode 100644 Dockerfile.md create mode 100644 LICENSE create mode 100644 Readme.md create mode 100644 bin/OPENSSL-LICENSE.txt create mode 100644 bin/Readme.md create mode 100644 bin/fedora-dirk-ipv6.diff create mode 100644 bin/krb5-ciphers.txt create mode 100644 bin/new-ciphers.diffed2vanilla.txt create mode 100644 bin/new-ciphers.std_distro.txt create mode 100644 bin/openssl-Vall.krb.txt create mode 100644 bin/openssl-Vall.txt create mode 100644 doc/Makefile create mode 100644 doc/template.html create mode 100644 doc/testssl.1 create mode 100644 doc/testssl.1.html create mode 100644 doc/testssl.1.md create mode 100644 etc/Apple.pem create mode 100644 etc/DST Root CA X3.txt create mode 100644 etc/Java.pem create mode 100644 etc/Linux.pem create mode 100644 etc/Microsoft.pem create mode 100644 etc/Mozilla.pem create mode 100644 etc/README.md create mode 100644 etc/SSLSocketClient.java create mode 100644 etc/ca_hashes.txt create mode 100644 etc/cipher-mapping.txt create mode 100644 etc/client-simulation.txt create mode 100644 etc/client-simulation.wiresharked.md create mode 100644 etc/client-simulation.wiresharked.txt create mode 100644 etc/common-primes.txt create mode 100644 etc/curves-mapping.txt create mode 100644 etc/curves.txt create mode 100644 etc/openssl.cnf create mode 100644 etc/tls_data.txt create mode 100644 openssl-iana.mapping.html create mode 100755 t/00_testssl_help.t create mode 100755 t/01_testssl_banner.t create mode 100755 t/02_clientsim_txt_parsable.t create mode 100755 t/05_ca_hashes_up_to_date.t create mode 100755 t/10_baseline_ipv4_http.t create mode 100755 t/11_baseline_ipv6_http.t.DISABLED create mode 100755 t/21_baseline_starttls.t create mode 100755 t/23_client_simulation.t create mode 100755 t/31_isJSON_valid.t create mode 100755 t/32_isHTML_valid.t create mode 100755 t/33_isJSON_severitylevel_valid.t create mode 100755 t/51_badssl.com.t create mode 100755 t/59_hpkp.t.tmpDISABLED create mode 100755 t/61_diff_testsslsh.t create mode 100644 t/Readme.md create mode 100644 t/baseline_data/default_testssl.csvfile create mode 100755 testssl.sh create mode 100755 utils/00_unittest_baseline.sh create mode 100755 utils/ccs-injection.bash create mode 100755 utils/checkcert.sh create mode 100755 utils/create_ca_hashes.sh create mode 100755 utils/curves.bash create mode 100755 utils/docker-debian10.tls13only.start.sh create mode 100755 utils/docker-nginx.tls13-earlydata.start.sh create mode 100755 utils/generate_static_cipher_lists.sh create mode 100755 utils/gmap2testssl.sh create mode 100755 utils/heartbleed.bash create mode 100755 utils/hexstream2cipher.sh create mode 100755 utils/hexstream2curves.sh create mode 100755 utils/make-openssl.sh create mode 100755 utils/make-openssl111.sh create mode 100755 utils/parse_client_ciphers.pl create mode 100755 utils/prototype.ssl2proto-check.bash create mode 100755 utils/prototype.tls-protocol-checker.bash create mode 100755 utils/resume.sh create mode 100755 utils/ticketbleed.bash create mode 100755 utils/update_client_sim_data.pl diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..bbc4f67 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +# Exclude everything from the Docker build context: +* + +# Except for this content: +!bin/ +!etc/ +!testssl.sh + +# But additionally exclude this nested content: +bin/openssl.Darwin.* +bin/openssl.FreeBSD.* diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9eba8be --- /dev/null +++ b/.editorconfig @@ -0,0 +1,10 @@ +root = true + +[*] +indent_style = space + +[*.md] +indent_size = 2 + +[*.{t,pl,sh,bash}] +indent_size = 5 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..a9646a5 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,11 @@ +*.sh eol=lf +*.bash eol=lf +*.md eol=lf +*.html eol=lf +*.txt eol=lf +*.txt eol=lf +*.1 eol=lf +*.t eol=lf +*.yml eol=lf +Dockerfile* eol=lf +*.csvfile eol=lf diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..8adda54 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,33 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[BUG / possible BUG]" +labels: '' +assignees: '' + +--- + + +**Before you open an issue please check which version you are running and whether it is the latest in stable / dev branch** +I am running version ( ``git log | head -1`` / ``testssl.sh -v | grep from``) + +**Before you open an issue please whether this is a known problem by searching the issues** +Is related to / couldn't find anything + +**Command line / docker command to reproduce** +Which was your command line? In addition the target of your scan would be helpful. If you don't want to disclose it publicly: ``grep SWCONTACT testssl.sh``. + +**Expected behavior** +A clear and concise description of what you expected to happen. + + +**Your system (please complete the following information):** + - OS: ``awk -F\" '/PRETTY_NAME/ { print $2 }' /etc/os-release`` + - Platform: ``uname -srm`` + - OpenSSL: ``testssl.sh -b 2>/dev/null | awk -F':' '/openssl/ { print $2}'`` + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..a7d15e3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,26 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[Feature request]" +labels: '' +assignees: '' + +--- + + +**Which version are you referring to** +3.0.x or 3.2? + + +**Please check this repo whether this is a known feature request** +If in doubt check the git log and/or check whether you run the latest version from the git repo. Maybe this was solved already? + +**Describe your feature request (if it's a technical feature)** + +**If your feature request otherwise is related to a usage problem, please describe it** +A clear and concise description of what the problem is. Example: I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen instead. diff --git a/.github/ISSUE_TEMPLATE/other-issues---question.md b/.github/ISSUE_TEMPLATE/other-issues---question.md new file mode 100644 index 0000000..490a660 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/other-issues---question.md @@ -0,0 +1,11 @@ +--- +name: Other issues / Question +about: Anything else which is not covered by a bug report or feature request +title: '' +labels: '' +assignees: '' + +--- + +**Which version are you referring to** +3.0.x or 3.2? (please check also how old your version is compare to the ones here) diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4cff4d6 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 0000000..c41d337 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,16 @@ +--- +name: Codespell +on: [push, pull_request] +permissions: + contents: read + +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: codespell-project/actions-codespell@master + with: + skip: ca_hashes.txt,tls_data.txt,*.pem,OPENSSL-LICENSE.txt,CREDITS.md,openssl.cnf + ignore_words_list: borken,gost,ciph,ba,bloc,isnt,chello,fo,alle,anull diff --git a/.github/workflows/docker-3.2.yml b/.github/workflows/docker-3.2.yml new file mode 100644 index 0000000..8f01da6 --- /dev/null +++ b/.github/workflows/docker-3.2.yml @@ -0,0 +1,63 @@ +name: docker-3.2 + +on: + push: + branches: + - 3.2 + workflow_dispatch: + schedule: + - cron: "0 8 * * 1" + +env: + BUILD_VERSION: "3.2" + DOCKER_CLI_EXPERIMENTAL: enabled + +jobs: + + deploy: + runs-on: ubuntu-22.04 + + steps: + - name: Source checkout + uses: actions/checkout@v4 + + - name: Setup QEMU + id: qemu + uses: docker/setup-qemu-action@v3.0.0 + + - name: Setup Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Set Docker metadata + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: ${{ github.repository }} + labels: | + org.opencontainers.image.version=${{ env.BUILD_VERSION }} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.title=${{ github.repository }} + + - name: GitHub login + if: ${{ github.event_name != 'pull_request' }} + uses: docker/login-action@v3.0.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5.0.0 + with: + push: ${{ github.event_name != 'pull_request' }} + context: . + file: Dockerfile.git + platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7,linux/arm/v6,linux/ppc64le + build-args: BUILD_VERSION + cache-from: type=gha, scope=${{ github.workflow }} + cache-to: type=gha, scope=${{ github.workflow }} + labels: ${{ steps.docker_meta.outputs.labels }} + tags: | + ghcr.io/${{ github.repository }}:${{ env.BUILD_VERSION }} + ghcr.io/${{ github.repository }}:latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..bb69122 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,40 @@ +name: testssl.sh CI + +on: + pull_request: + paths-ignore: + - 'utils/**' + - 'doc/**' + - 'bin/**' + - '**.md' + - '**.pem' + - '**.pdf' + - '**.html' + - 'LICENSE' + - 'Dockerfile' + +permissions: + contents: read + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ['ubuntu-22.04'] + perl: ['5.26'] + name: Perl ${{ matrix.perl }} on ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Set up perl + uses: shogo82148/actions-setup-perl@v1 + with: + perl-version: ${{ matrix.perl }} + - run: perl -V + - name: Install deps + run: sudo apt install dnsutils jsonlint + - run: cpanm --notest Test::More + - run: cpanm --notest Data::Dumper + - run: cpanm --notest JSON + - run: cpanm --notest Text::Diff + - run: prove -v diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d0ba2b --- /dev/null +++ b/.gitignore @@ -0,0 +1,32 @@ +.DS_Store +._.DS_Store +tmp.json +tmp.html +*_p*-????????-????.html +*.bak +*.json +*.csv +*.log +*.xml +*.iml +*.script +*.swp +*.swo +*~ +*.orig +*.org +.directory +.idea/ +*.tar.* +*.patch +*.diff +*.rej +*.asc +*.crt +*.pem +*.der +*.csr +*.p12 +thumbs.db +todo.md +2do.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..c20aa5c --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,531 @@ + +## Change Log + +### Features implemented / improvements in 3.2 + +* Rating (SSL Labs, not complete) +* Extend Server (cipher) preference: always now in wide mode instead of running all ciphers in the end (per default) +* Remove "negotiated cipher / protocol" +* Provide a better verdict wrt to server order: Now per protocol and ciphers are weighted for each protocol +* Switched to multi-stage docker image with opensuse base to avoid musl libc issues, performance gain also +* Improved compatibility with OpenSSL 3.0 +* Improved compatibility with Open/LibreSSL versions not supporting TLS 1.0-1.1 anymore +* Renamed PFS/perfect forward secrecy --> FS/forward secrecy +* Cipher list straightening +* Improved mass testing +* Better align colors of ciphers with standard cipherlists +* Save a few cycles for ROBOT +* Several ciphers more colorized +* Percent output char problem fixed +* Several display/output fixes +* BREACH check: list all compression methods and add brotli +* Test for old winshock vulnerability +* Test for STARTTLS injection vulnerabilities (SMTP, POP3, IMAP) +* STARTTLS: XMPP server support, plus new set of OpenSSL-bad binaries +* Several code improvements to STARTTLS, also better detection when no STARTTLS is offered +* STARTTLS on active directory service support +* Security fixes: DNS and other input from servers +* Don't penalize missing trust in rating when CA not in Java store +* Added support for certificates with EdDSA signatures and public keys +* Extract CA list shows supported certification authorities sent by the server +* TLS 1.2 and TLS 1.3 sig algs added +* Check for ffdhe groups +* Show server supported signature algorithms +* --add-ca can also now be a directory with \*.pem files +* Warning of 398 day limit for certificates issued after 2020/9/1 +* Added environment variable for amount of attempts for ssl renegotiation check +* Added --user-agent argument to support using a custom User Agent +* Added --overwrite argument to support overwriting output files without warning +* Headerflag X-XSS-Protection is now labeled as INFO +* Strict parser for HSTS +* DNS via proxy improvements +* Client simulation runs in wide mode which is even better readable +* Added --reqheader to support custom headers in HTTP requests +* Test for support for RFC 8879 certificate compression +* Deprecating --fast and --ssl-native (warning but still av) +* Compatible to GNU grep 3.8 +* Don't use external pwd command anymore +* Doesn't hang anymore when there's no local resolver + + +### Features implemented / improvements in 3.0 + +* Full support of TLS 1.3, shows also drafts supported +* Extended protocol downgrade checks +* ROBOT check +* Better TLS extension support +* Better OpenSSL 1.1.1 and higher versions support as well as LibreSSL >3 +* More robustness for OpenBSD +* DNS over Proxy and other proxy improvements +* Decoding of unencrypted BIG IP cookies +* Initial client certificate support +* Warning of 825 day limit for certificates issued after 2018/3/1 +* Socket timeouts (``--connect-timeout``) +* IDN/IDN2 servername/URI + emoji support, supposed libidn/idn2 is installed and DNS resolver is recent) support +* Initial support for certificate compression +* Better JSON output: renamed IDs and findings shorter/better parsable, also includes certificate +* JSON output now valid also for non-responding servers +* Testing now per default 370 ciphers +* Further improving the robustness of TLS sockets (sending and parsing) +* Support of supplying timeout value for `openssl connect` -- useful for batch/mass scanning +* File input for serial or parallel mass testing can be also in nmap grep(p)able (-oG) format +* LOGJAM: now checking also for DH and FFDHE groups (TLS 1.2) +* PFS: Display of elliptical curves supported, DH and FFDHE groups (TLS 1.2 + TLS 1.3) +* Check for session resumption (Ticket, ID) +* TLS Robustness check GREASE and more +* Server preference distinguishes between TLS 1.3 and lower protocols +* Mark TLS 1.0 and TLS 1.1 as deprecated +* Does a few startup checks which make later tests easier and faster (``determine_optimal_\*()``) +* Expect-CT Header Detection +* `--phone-out` does certificate revocation checks via OCSP (LDAP+HTTP) and with CRL +* `--phone-out` checks whether the private key has been compromised via https://pwnedkeys.com/ +* Missing SAN warning +* Added support for private CAs +* Way better handling of connectivity problems (counting those, if threshold exceeded -> bye) +* Fixed TCP fragmentation +* Added `--ids-friendly` switch +* Exit codes better: 0 for running without error, 1+n for small errors, >240 for major errors. +* Better error msg suppression (not fully installed OpenSSL) +* Better parsing of HTTP headers & better output of longer HTTP headers +* Display more HTTP security headers +* HTTP Basic Auth support for HTTP header +* experimental "eTLS" detection +* Dockerfile and repo @ docker hub with that file (see above) +* Java Root CA store added +* Better support for XMPP via STARTTLS & faster +* Certificate check for to-name in stream of XMPP +* Support for NNTP and LMTP via STARTTLS, fixes for MySQL and PostgresQL +* Support for SNI and STARTTLS +* More robustness for any STARTTLS protocol (fall back to plaintext while in TLS caused problems) +* Renegotiation checks improved, also no false positive for Node.js anymore +* Major update of client simulations with self-collected up-to-date data +* Update of CA certificate stores +* Lots of bug fixes +* More travis/CI checks -- still place for improvements +* Man page reviewed + +### Features implemented / improvements in 2.9.5 + +* Way better coverage of ciphers as most checks are done via bash sockets where ever possible +* Further tests via TLS sockets and improvements (handshake parsing, completeness, robustness) +* Testing 359 default ciphers (``testssl.sh -e/-E``) with a mixture of sockets and openssl. Same speed as with openssl only but additional ciphers such as post-quantum ciphers, new CHAHA20/POLY1305, CamelliaGCM etc. +* TLS 1.2 protocol check via sockets in production +* Finding more TLS extensions via sockets +* TLS Supported Groups Registry (RFC 7919), key shares extension +* Non-flat JSON output support +* File output (CSV, JSON flat, JSON non-flat) supports a minimum severity level (only above supplied level there will be output) +* Native HTML support instead going through 'aha' +* LUCKY13 and SWEET32 checks +* Ticketbleed check +* LOGJAM: now checking also for known DH parameters +* Support of supplying timeout value for ``openssl connect`` -- useful for batch/mass scanning +* Parallel mass testing +* Check for CAA RR +* Check for OCSP must staple +* Check for Certificate Transparency +* Check for session resumption (Ticket, ID) +* Better formatting of output (indentation) +* Choice showing the RFC naming scheme only +* File input for mass testing can be also in nmap grep(p)able (-oG) format +* Postgres und MySQL STARTTLS support +* Man page + +### New in 2.8 + +* Trust chain check against certificate stores from Apple (OS), Linux (OS), + Microsoft (OS), Mozilla (Firefox Browser), works for openssl >=1.0.1 +* IPv6 (status: 80% working, details see + https://github.com/drwetter/testssl.sh/issues/11 +* works now on servers requiring a x509 certificate for authentication +* extensive CN <--> hostname check +* SSL Session ID check +* Avahi/mDNS based name resolution +* HTTP2/ALPN protocol check +* Logging to a file / dir +* Logging to (flat) JSON + CSV +* HPKP checks now also for Root, intermediate SPKIs +* Check for multiple server certificates +* Browser cipher simulation: what client will connect with which cipher + protocol +* GOST cipher+certificate improvements +* Assistance for color-blind users +* Even more compatibility improvements for FreeBSD, NetBSD, Gentoo, RH-ish, F5 and Cisco systems +* Considerable speed improvements for each cipher runs (-e/-E) +* More robust SSLv2 + TLS socket interface +* separate check for curves +* OpenSSL 1.1.0 compliant +* check for DROWN +* Whole number of bugs squashed + +### New in 2.6 + + * Display matching host key (HPKP) + * LOGJAM 1: check DHE_EXPORT cipher + * LOGJAM 2: displays DH(/ECDH) bits in wide mode on negotiated ciphers + * "wide mode" option for checks like RC4, BEAST. PFS. Displays hexcode, kx, strength, DH bits, RFC name + * binary directory provides out of the box better binaries (Linux 32+64 Bit, Darwin 64 bit, FreeBSD 64 bit) + * OS X binaries (@jvehent, new builds: @jpluimers) + * ARM binary (@f-s) + * FreeBSD binary + * TLS_FALLBACK_SCSV check -- thx @JonnyHightower + * (HTTP) proxy support! Also with sockets -- thx @jnewbigin + * Extended validation certificate detection + * Run in default mode through all ciphers at the end of a default run + * will test multiple IP addresses of one supplied server name in one shot, --ip= restricts it accordingly + * new mass testing file option --file option where testssl.sh commands are being read from, see https://twitter.com/drwetter/status/627619848344989696 + * TLS time and HTTP time stamps + * TLS time displayed also for STARTTLS protocols + * support of sockets for STARTTLS protocols + * TLS 1.0-1.1 as socket checks per default in production + * further detection of security relevant headers (reverse proxy, IPv4 addresses), proprietary banners (OWA, Liferay etc.) + * can scan STARTTLS+XMPP by also supplying the XMPP domain (to-option in XML streams). + * quite some LibreSSL fixes, still not recommended to use though (see https://testssl.sh/) + * lots of fixes, code improvements, even more robust + +Full log @ https://github.com/drwetter/testssl.sh/commits/2.6/testssl.sh + +### New in 2.4 + * "only one cmd line option at a time" is completely gone + * several tuning parameters on the cmd line (only available through environment variables b4): --assuming-http, --ssl-native, --sneaky, --warnings, --color, -- debug, --long + * certificate information + * more HTTP header infos (cookies+security headers) + * protocol check via bash sockets for SSLv2+v3 + * debug handling significantly improved (verbosity/each function leaves files in $TEMPDIR) + * BEAST check + * FREAK check + * check for Secure Client-Initiated Renegotiation + * lots of cosmetic and maintainability code cleanups + * bugfixing + +Full changelog: https://github.com/drwetter/testssl.sh/commits/2.4/testssl.sh + +### 2.2. new features: + * Works fully under FreeBSD (openssl >=1.0) + * single cipher check (-x) with pattern of hexcode/cipher + * check for POODLE SSL + * HPKP check + * OCSP stapling + * GOST and CHACHA20 POLY1305 cipher support + * service detection (HTTP, IMAP, POP, SMTP) + * runs now with all colors, b/w screen, no escape codes at all + * protocol check better + * job control removes stalling + * RFC <---> OpenSSL name space mapping of ciphers everywhere + * includes a lot of fixes + +Full changelog @ https://github.com/drwetter/testssl.sh/commits/2.2/testssl.sh + +### 2.0 major release, new features: + * SNI + * STARTTLS fully supported + * RC4 check + * (P)FS check + * SPDY check + * color codes make more sense now + * cipher hexcodes are shown + * tests ciphers per protocol + * HSTS + * web and application server banner + * server preferences + * TLS server extensions + * server key size + * cipher suite mapping from openssl to RFC + * heartbleed check + * CCS injection check + +### Historical releases + +1.112 +- IPv6 display fix + +1.111 +- NEW: tested under FreeBSD (works with exception of xxd in CCS) +- getent now works under Linux and FreeBSD +- sed -i in hsts sacrificed for compatibility +- removed query for IP for finishing banner, is now called once in parse_hn_port +- GOST warning after banner +- empty build date is not displayed anymore +- long build date strings minimized +- FIXED: IPv6 address are displayed again + +1.110 +- NEW: adding Russian GOST cipher support by providing a config file on the fly +- adding the compile date of openssl in the banner + +1.109 +- minor IPv6 fixes + +1.108 +- NEW: Major rewrite of output functions. Now using printf instead of "echo -e" for BSD and MacOSX compatibility + +1.107 +- improved IP address stuff + +1.106 +- minor fixes + +1.105 +- NEW: working prototype for CCS injection + +1.104 +- NEW: everywhere *also* RFC style ciphers -- if the mapping file is found +- unitary calls to display cipher suites + +1.103 +- NEW: telnet support for STARTTLS (works only with a patched openssl version) + --> not tested (lack of server) + +1.102 +- NEW: test for BREACH (experimental) + +.101 +- BUGFIX: muted too verbose output of which on CentOS/RHEL +- BUGFIX: muted too verbose output of netcat/nc on CentOS/RHEL+Debian + +1.100 +- further cleanup + - starttls now tests allciphers() instead of cipher_per_proto + (normal use case makes most sense here) + - ENV J_POSITIV --> SHOW_EACH_C +- finding mapping-rfc.txt is now a bit smarter +- preparations for ChaCha20-Poly1305 (would have provided binaries but + "openssl s_client -connect" with that ciphersuite fails currently with + a handshake error though client and server hello succeeded!) + +1.99 +- BUGFIX: now really really everywhere testing the IP with supplied name +- locking out openssl < 0.9.8f, new function called "old_fart" ;-) +- FEATURE: displaying PTR record of IP +- FEATURE: displaying further IPv4/IPv6 addresses +- bit of a cleanup + +1.98 +- http_header is in total only called once +- better parsing of default protocol (FIXME shouldn't appear anymore) + +1.97 +- reduced sleep time for server hello and payload reply (heartbleed) + +1.96 +- NEW: (experimental) heartbleed support with bash sockets (shell only SSL handshake!) + see also https://testssl.sh/bash-heartbleed.sh + +1.95 (2.0rc3) +- changed cmdline options for CRIME and renego vuln to uppercase +- NEW: displays server key size now +- NEW: displays TLS server extensions (might kill old openssl versions) +- brown warning if HSTS < 180 days +- brown warning if SSLv3 is offered as default protocol + +1.94 +- NEW: prototype of mapping to RFC cipher suite names, needed file mapping-rfc.txt in same dir + as of now only used for 'testssl.sh -V' +- internal renaming: it was supposed to be "cipherlists" instead of "ciphersuites" +- additional tests for cipherlists DES, 3DES, ADH + +1.93 +- BUGFIX: removed space in Server banner fixed (at the expense of showing just nothing if Server string is empty) + +1.92 +- BUGFIX: fixed error of faulty detected empty server string + +1.91 +- replaced most lcyan to brown (=not really bad but somehow) +- empty server string better displayed +- preferred CBC TLS 1.2 cipher is now brown (lucky13) + +1.90 +- fix for netweaver banner (server is lowercase) +- no server banner is no disadvantage (color code) + +1.89 +- reordered! : protocols + cipher come first +- colorized preferred server preference (e.g. CBC+RC4 is light red now, TLSv1.2 green) +- SSLv3 is now light cyan +- NEW: -P|--preference now in help menu +- light cyan is more appropriate than red for HSTS + +1.88 +- NEW: prototype for protocol and cipher preference +- prototype for session ticket + +1.87 +- changed just the version string to rc1 + +1.86 + - NEW: App banner now production, except 2 liners + - DEBUG: 1 is now true as everywhere else + - CRIME+Renego prettier + - last optical polish for RC4, PFS + +1.85 + - NEW: appbanner (also 2 lines like asp.net) + - OSSL_VER_MAJOR/MINOR/APPENDIX + - less bold because bold headlines as bold should be reserved for emphasize findings + - tabbed output also for protocols and cipher classes + - unify neat printing + +1.84 + - NEW: deprecating openssl version <0.98 + - displaying a warning >= 0.98 < 1.0 + - NEW: neat print also for all ciphers (-E,-e) + +1.83 +- BUGFIX: results from unit test: logical error in PFS+RC4 fixed +- headline of -V / PFS+RC4 ciphers unified + +1.82 +- NEW: output for -V now better (bits separate, spacing improved) + +1.81 +- output for RC4+PFS now better (with headline, bits separate, spacing improved) +- both also sorted by encr. strength .. umm ..err bits! + +1.80 +- order of finding supplied binary extended (first one wins): + 1. use supplied variable $OPENSSL + 2. use "openssl" in same path as testssl.sh + 3. use "openssl.`uname -m`" in same path as testssl.sh + 4. use anything in system $PATH (return value of "which" + +1.79 +- STARTTLS options w/o trailing 's' now (easier) +- commented code for CRIME SPDY +- issue a warning for openssl < 0.9.7 ( that version won't work anyway probably) + +1.78 +- -E, -e now sorted by encryption strength (note: it's only encr key length) +- -V now pretty prints all local ciphers +- -V now pretty prints all local ciphers matching pattern (plain string, no regex) +- bugfix: SSLv2 cipher hex codes has 3 bytes! + +1.77 +- removed legacy code (PROD_REL var) + +1.76 +- bash was gone!! disaster for Ubuntu, fixed +- starttls+rc4 check: bottom line was wrong +- starttls had too much output (certificate) at first a/v check + +1.75 +- location is now https://testssl.sh +- be nice: banner, version, help also works for BSD folks (on dash) +- bug in server banner fixed +- sneaky referer and user agent possible + +1.74 +- Debian 7 fix +- ident obsoleted + +1.72 +- removed obsolete GREP +- SWURL/SWCONTACT +- output for positive RC4 better + +1.71 +- workaround for buggy bash (RC4) +- colors improved + - blue is now reserved for headline + - magenta for local probs + - in RC4 removal of SSL protocol provided by openssl + +1.70 +- DEBUG in http_headers now as expected +- hostname check + - separate check for curves + - RFC 7919, key shares extension + - keyUsage extension in certificate + - experimental "eTLS" detection + - parallel mass testing! + - RFC <--> OpenSSL cipher name space switches for the command line + - better error msg suppression (not fully installed openssl) + - GREASE support + - Bleichenbacher / ROBOT vulnerability test + - several protocol preferences improvements + - pwnedkeys.com support + - CT support + - Extract CA list CertificateRequest message is encountered + - RFC 8879, certificate compression + - 128 cipher limit, padding + - compatibility for LibreSSL and different OpenSSL versions + - Check for ffdhe groups + - TLS 1.2 and TLS 1.3 sig algs added + - Show server supported signature algorithms + - Show supported certification authorities sent by the server when client auth is requested + - Provide a better verdict wrt to server order: Now per protocol and ciphers are weighted for each protocol + - Provide compatibility to every LibreSSL/OpenSSL versions + - Lots of fixes and improvements + +##### Further credits (in alphabetical order) + +* a666 + - Bugfix + +* Christoph Badura + - NetBSD fixes + +* Jim Blankendaal + - maximum certificate lifespan of 398 days + - ssl renegotiation amount variable + - custom http request headers + +* Frank Breedijk + - Detection of insecure redirects + - JSON and CSV output + - CA pinning + - Client simulations + - CI integration, some test cases for it + +* Steven Danneman + - Postgres and MySQL STARTTLS support + - MongoDB support + +* Christian Dresen + - Dockerfile + +* csett86 + - some MacOSX and Java client handshake data + +* Mark Felder + - lots of cleanups + - Shellcheck static analysis + +* Laine Gholson + - avahi/mDNS support + - HTTP2/ALPN + - bugfixes + - former ARM binary support + +* Maciej Grela + - colorless handling + +* Jac2NL + - initial support for skipping offensive vulnerability tests + +* Scott Johnson + - Bugfix F5 + +* Hubert Kario + - helped with avoiding accidental TCP fragmentation + +* Brennan Kinney + - refactored multistage Dockerfiles: performance gain+address bugs/inconsistencies + +* Magnus Larsen + - SSL Labs Rating + +* Jacco de Leeuw + - skip checks which might trigger an IDS ($OFFENSIVE / --ids-friendly) + +* Manuel + - HTTP basic auth + +* Markus Manzke + - Fix for HSTS + subdomains + - LibreSSL patch + +* Jean Marsault + - client auth: ideas, code snippets + +* Thomas Martens + - adding colorblind option + - no-rfc mapping + +* Peter Mosmans + - started way better cmd line parsing + - cleanups, fixes + - openssl sources support with the "missing" features + +* John Newbigin + - Proxy support (sockets and openssl) + +* Oleksandr Nosenko + - non-flat JSON support (--json-pretty) + - in file output (CSV, JSON flat, JSON non-flat) support of a minimum severity level + +* Jonathan Roach + - TLS_FALLBACK_SCSV checks + +* Jonathon Rossi + - fix for bash3 (Darwin) + - and other Darwin fixes + +* Дилян Палаузов + - bug fix for 3des report + - reported a tricky STARTTLS bug + +* Thomas Patzke: + - Support of supplying timeout value for openssl connect + +* Olivier Paroz + - conversion xxd --> hexdump stuff + +* Jeroen Wiert Pluimers + - Darwin binaries support + +* Joao Poupino + - Minimize false positive detection for Renegotiation checks against Node.js etc. + +* Rechi + - initial MX stuff + - fixes + +* Gonçalo Ribeiro + - --connect-timeout + +* Dmitri S + - inspiration & help for Darwin port + +* Jonas Schäfer + - XMPP server patch + +* Marcin Szychowski + - Quick'n'dirty client certificate support + +* Viktor Szépe + - color function maker + +* Julien Vehent + - supplied 1st Darwin binary + +* Thomas Ward + - add initial IDN support + +* @typingArtist + - improved BEAST detection + +* @f-s + - ARM binary support + +* @nvsofts (NV) + - LibreSSL patch for GOST + +* @w4ntun + - fixed DNS via proxy + +Probably more I forgot to mention which did give me feedback, bug reports and helped one way or another. + + +##### Last but not least: + +* OpenSSL team for providing openssl. + +* Ivan Ristic/Qualys for the liberal license which made it possible to make partly use of the client data + +* My family for supporting me doing this work diff --git a/Coding_Convention.md b/Coding_Convention.md new file mode 100644 index 0000000..72abadd --- /dev/null +++ b/Coding_Convention.md @@ -0,0 +1,72 @@ +## Coding Style + +### PR + +You'd make the life of the maintainers easier if you submit only _one_ patch with _one_ functional change per PR. + +### General + * Portability is important: Don't use highly system depended binaries (`rpm`, `ip/ifconfig`, ..) as it is not portable. Or it would require lots of efforts (like C's #ifdefs) to be portable plus the code gets ugly. + * Don't use additional binaries. + * If you really, really need to use an additional binary make sure it's available on the system before calling it. (Example: see `timeout`.) + * Keep in mind that binaries might come in different flavors. Especially with ``sed`` you need to be careful as GNU sed is only 80% compatible with BSD sed (`sed -i`,` \n`, `\t`, etc.). + * Avoid checking for the operating system when using a feature of a binary or an OS. E.g. FreeBSD or MacOSX may or may not have GNU binaries installed, so it's better to check a capability of the binary instead. See how `HAS_*` variables are set. + + +### Documentation + +Some people really read that ! New features would need to be documented in the appropriate section in `help()` and in `~/doc/testssl.1.md`. + +### Coding + +#### Shell / bash + +Bash is actually quite powerful -- not only with respect to sockets. It's not as mighty as perl or python, but there are a lot of neat features. Here's how you make use of them. Besides those short hints here there's a wealth of information of there. One good resource is the [bash hackers wiki](https://wiki.bash-hackers.org/start). + +* Don't use backticks anymore, use `$(..)` instead +* Use double square `[[]]` brackets (_conditional expressions)_ instead of single square `[]` brackets +* In double square brackets avoid quoting at the right hand side if not necessary, see [bash hackers wiki](https://wiki.bash-hackers.org/syntax/ccmd/conditional_expression). For regex matching (`=~`) you shouldn't quote at all. +* The [BashPitfalls](http://mywiki.wooledge.org/BashPitfalls) is a good read! +* Whenever possible try to avoid `tr` `sed` `awk` and use bash internal functions instead, see e.g. [bash shell parameter substitution](http://www.cyberciti.biz/tips/bash-shell-parameter-substitution-2.html). It slower as it forks, fopens and pipes back the result. +* `read` often can replace `awk`: `IFS=, read -ra a b c <<< "$line_with_comma"` +* Bash can also deal perfectly with regular expressions, see e.g. [here](https://www.networkworld.com/article/2693361/unix-tip-using-bash-s-regular-expressions.html) and [here](https://unix.stackexchange.com/questions/421460/bash-regex-and-https-regex101-com). You can as well have a look @ `is_ipv4addr()` or `is_ipv6addr()`. +* If you still need to use any of `tr`, `sed` and `awk`: try to avoid a mix of several external binaries e.g. if you can achieve the same with e.g. `awk`. +* Be careful with very advanced bash features. Mac OS X is still using bash version 3 ([differences](http://tldp.org/LDP/abs/html/bashver4.html), see also [bash hackers wiki](https://wiki.bash-hackers.org/scripting/bashchanges)). +* Always use a return value for a function/method. 0 means all is fine. +* Make use of [shellcheck](https://github.com/koalaman/shellcheck) if possible + + +#### Shell / testssl.sh specific +* Make use the short functions / methods (code starts from `###### START helper function definitions`) like + * `count_words()` / `count_lines()` / `count_ciphers()` + * `strip_lf()` / `strip_spaces()` + * `toupper()` / `tolower()` + * `newline_to_spaces()` + * `is_number()` / `is_ipv4addr()` + * .. and much more +* Security: + * Watch out for any input especially (but not only) supplied from the server. Input should never be trusted. + * Unless you're really sure where the values come from, variables need to be put in quotes. + * You can use `safe_echo()` when processing input which does some input validation. + * Use ``out()`` or similar output functions when writing something back to the user. +* Use `$OPENSSL` instead of `openssl`. The latter is highly system depended and also $OPENSSL is a binary which capabilities are checked internally before using it, independent whether the supplied one is being used or another one. + +#### Variables +* Use "speaking variables" but don't overdo it with the length +* No camelCase please. We distinguish between lowercase and uppercase only + * Global variables + * use them only when really necessary + * in CAPS + * initialize them + * use ``readonly`` and use typing (variable types) if possible +* Local variables + * are lower case + * declare them before usage (`local`) + * initialize them + +### Misc + +* If you're implementing a new feature a cmd line switch, there has to be also a global ENV variable which can be used without the switch (see e.g. `SNEAKY`, `ASSUME_HTTP` or `ADDTL_CA_FILES`) +* Test before doing a PR! Best if you check with two bad and two good examples which should then work as expected. Maybe compare results e.g. with SSLlabs. +* Unit tests are done automatically done with Perl using Travis. The trigger is `~/.travis.yml`. The general documentation for [Test::More](https://perldoc.perl.org/Test/More.html) is a good start. You are encouraged to write own checks. You can use e.g. `t/20_baseline_ipv4_http.t` as an example. +* If it's an OpenSSL feature you want to use and it could be not available for older OpenSSL versions testssl.sh needs to find out whether OpenSSL has that feature. Best do this with OpenSSL itself and not by checking the version as some vendors do backports. See the examples for `HAS_SSL2` or proxy option check of OpenSSL in `check_proxy()`. +* If a feature of OpenSSL is not available you need to tell this the user by using `pr_warning*()`. Or accordingly with `fatal()` if a continuation of the program doesn't make sense anymore. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1428352 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# syntax=docker.io/docker/dockerfile:1 + +ARG LEAP_VERSION=15.4 +ARG INSTALL_ROOT=/rootfs + +FROM opensuse/leap:${LEAP_VERSION} as builder +ARG CACHE_ZYPPER=/tmp/cache/zypper +ARG INSTALL_ROOT +# /etc/os-release provides $VERSION_ID +RUN source /etc/os-release \ + && export ZYPPER_OPTIONS=( --releasever "${VERSION_ID}" --installroot "${INSTALL_ROOT}" --cache-dir "${CACHE_ZYPPER}" ) \ + && zypper "${ZYPPER_OPTIONS[@]}" --gpg-auto-import-keys refresh \ + && zypper "${ZYPPER_OPTIONS[@]}" --non-interactive install --download-in-advance --no-recommends \ + bash procps grep gawk sed coreutils busybox-util-linux busybox-vi ldns libidn2-0 socat openssl curl \ + && zypper "${ZYPPER_OPTIONS[@]}" clean --all +## Cleanup (reclaim approx 13 MiB): +# None of this content should be relevant to the container: +RUN rm -r "${INSTALL_ROOT}/usr/share/"{licenses,man,locale,doc,help,info} +# Functionality that the container doesn't need: +RUN rm "${INSTALL_ROOT}/usr/share/misc/termcap" \ + && rm -r "${INSTALL_ROOT}/usr/lib/sysimage/rpm" + + +# Create a new image with the contents of $INSTALL_ROOT +FROM scratch +ARG INSTALL_ROOT +COPY --link --from=builder ${INSTALL_ROOT} / +# Link busybox to tar, see #2403. Create user + (home with SGID set): +RUN ln -s /usr/bin/busybox /usr/bin/tar \ + && echo 'testssl:x:1000:1000::/home/testssl:/bin/bash' >> /etc/passwd \ + && echo 'testssl:x:1000:' >> /etc/group \ + && echo 'testssl:!::0:::::' >> /etc/shadow \ + && install --mode 2755 --owner testssl --group testssl --directory /home/testssl \ + && ln -s /home/testssl/testssl.sh /usr/local/bin/ + +# Copy over build context (after filtered by .dockerignore): bin/ etc/ testssl.sh +COPY --chown=testssl:testssl . /home/testssl/ +USER testssl +ENTRYPOINT ["testssl.sh"] +CMD ["--help"] diff --git a/Dockerfile.git b/Dockerfile.git new file mode 100644 index 0000000..6411a17 --- /dev/null +++ b/Dockerfile.git @@ -0,0 +1,24 @@ +# Build using git repo + +FROM alpine:3.17 + +WORKDIR /home/testssl + +ARG BUILD_VERSION +ARG ARCHIVE_URL=https://github.com/drwetter/testssl.sh/archive/ +ARG URL=https://github.com/drwetter/testssl.sh.git + +RUN test -n "${BUILD_VERSION}" \ + && apk update \ + && apk add --no-cache bash procps drill git coreutils libidn curl socat openssl xxd \ + && git clone --depth 1 --branch ${BUILD_VERSION} $URL /home/testssl \ + && addgroup testssl \ + && adduser -G testssl -g "testssl user" -s /bin/bash -D testssl \ + && ln -s /home/testssl/testssl.sh /usr/local/bin/ \ + && mkdir -m 755 -p /home/testssl/etc /home/testssl/bin + +USER testssl + +ENTRYPOINT ["testssl.sh"] + +CMD ["--help"] diff --git a/Dockerfile.md b/Dockerfile.md new file mode 100644 index 0000000..27ab6b0 --- /dev/null +++ b/Dockerfile.md @@ -0,0 +1,49 @@ +## Usage + +### From git directory + +``` +docker build . +``` + +Catch is when you run without image tags you need to catch the ID when building + +``` +[..] +---> 889fa2f99933 +Successfully built 889fa2f99933 +``` + +More comfortable is + +``` +docker build -t mytestssl . +docker run --rm -t mytestssl example.com +``` + +You can also supply command line options like: + +``` +docker run -t mytestssl --help +docker run --rm -t mytestssl -p --header example.com +``` + +### From dockerhub + +You can pull the image from dockerhub and run: + +``` +docker run --rm -t drwetter/testssl.sh --fs example.com +``` + +Supported tags are: ``3.2`` and ``latest`, which are the same, i.e. the rolling release. ``3.0`` is the latest stable version from git which might have a few improvements (see git log) over the released version 3.0.X. + +``docker run --rm -t drwetter/testssl.sh:stable example.com``. + +Keep in mind that any output file (--log, --html, --json etc.) will be created within the container. If you wish to have this created in a local directory on your host you can mount a volume into the container and change the output prefix where the container user has write access to, e.g.: + +``` +docker run --rm -t -v /tmp:/data drwetter/testssl.sh --htmlfile /data/ example.com +``` + +which writes the HTML output to ``/tmp/example.com_p443--