01 //Introduction to SSL/TLS Misconfiguration
SSL/TLS (Secure Sockets Layer / Transport Layer Security) is the encryption protocol that protects data in transit between clients and servers. Every HTTPS connection relies on TLS to provide confidentiality, integrity, and authentication. When TLS is misconfigured, attackers can intercept, read, and modify all traffic — including credentials, session tokens, personal data, and API calls.
In this guide, you'll learn how TLS works and where the handshake can be compromised, which protocol versions and cipher suites are vulnerable, how certificate misconfigurations enable MITM attacks, why HSTS is critical for preventing HTTP downgrade attacks, how to identify TLS issues in code, configurations, and dependencies, and how to harden server TLS configurations.
What is the primary security goal that TLS achieves for web traffic?
02 //TLS Fundamentals
Understanding TLS versions and the handshake process is essential for identifying misconfigurations. Here is the current landscape.
TLS/SSL Protocol Version Status
| Protocol | Year | Status | Known Vulnerabilities |
|---|---|---|---|
| SSL 2.0 | 1995 | ❌ Deprecated — MUST NOT use | DROWN, no integrity protection, insecure MAC |
| SSL 3.0 | 1996 | ❌ Deprecated — MUST NOT use | POODLE, CBC padding oracle, no AEAD |
| TLS 1.0 | 1999 | ❌ Deprecated — should disable | BEAST, Lucky13, weak CBC, no AEAD requirement |
| TLS 1.1 | 2006 | ❌ Deprecated — should disable | No known critical flaws but lacks modern ciphers, no AEAD requirement |
| TLS 1.2 | 2008 | ✅ Acceptable — widely supported | Secure when configured correctly (AEAD ciphers, no CBC, no RC4) |
| TLS 1.3 | 2018 | ✅ Recommended — strongest | Removed all weak ciphers, only AEAD, 1-RTT handshake, no renegotiation |
TLS 1.3 simplifications: TLS 1.3 removed support for all weak cryptographic primitives. There are no RSA key exchanges (only ephemeral Diffie-Hellman for forward secrecy), no CBC mode ciphers (only AEAD), no compression (prevents CRIME/BREACH), no renegotiation (prevents renegotiation attacks), and only 5 cipher suites (all strong). This means TLS 1.3 is very hard to misconfigure — most issues arise from supporting older TLS versions alongside it.
1# TLS 1.3 only allows these 5 cipher suites — all AEAD:
2TLS_AES_256_GCM_SHA384 # AES-256 in GCM mode
3TLS_AES_128_GCM_SHA256 # AES-128 in GCM mode
4TLS_CHACHA20_POLY1305_SHA256 # ChaCha20 stream cipher (great on mobile)
5TLS_AES_128_CCM_SHA256 # AES-128 in CCM mode
6TLS_AES_128_CCM_8_SHA256 # AES-128 in CCM mode (8-byte tag)
7
8# Compare with TLS 1.2 which supports 300+ cipher suites,
9# many of which are weak or broken.TLS_RSA_WITH_AES_256_CBC_SHA) does NOT provide forward secrecy. During code review, flag any TLS 1.2 configuration that includes non-ECDHE/DHE cipher suites.03 //Protocol Version Vulnerabilities
Supporting outdated TLS/SSL versions exposes the application to well-known attacks. A protocol downgrade attack forces the connection to use an older, vulnerable version even when both client and server support newer versions.
Protocol Version Attacks
| Attack | Affected Protocol | Impact | CVE |
|---|---|---|---|
| POODLE | SSL 3.0 | Decrypt HTTPS traffic byte-by-byte via CBC padding oracle | CVE-2014-3566 |
| BEAST | TLS 1.0 | Decrypt HTTPS traffic via predictable CBC IV | CVE-2011-3389 |
| DROWN | SSL 2.0 | Decrypt TLS traffic if server also supports SSLv2 (even on a different port) | CVE-2016-0800 |
| Lucky13 | TLS 1.0–1.2 (CBC) | Timing side-channel on CBC padding validation | CVE-2013-0169 |
| CRIME | TLS 1.0–1.2 (with compression) | Recover session cookies via compression ratio oracle | CVE-2012-4929 |
| Downgrade to TLS 1.0 | All (if TLS 1.0 enabled) | MITM strips TLS version in ClientHello to force weaker protocol | N/A |
1# Normal connection (TLS 1.3):
2Client → Server: ClientHello (TLS 1.3, strong ciphers)
3Server → Client: ServerHello (TLS 1.3, AES-256-GCM)
4# ✅ Secure connection established
5
6# MITM downgrade attack (if server supports TLS 1.0):
7Client → MITM → Server: ClientHello (TLS 1.3, strong ciphers)
8MITM modifies: ClientHello (TLS 1.0, weak ciphers)
9Server → MITM → Client: ServerHello (TLS 1.0, RC4-SHA)
10# ❌ Weak connection — MITM can decrypt traffic!
11
12# Prevention: TLS_FALLBACK_SCSV (RFC 7507) detects downgrades
13# But the real fix: disable TLS 1.0 and 1.1 entirelyYour server supports TLS 1.0, 1.1, 1.2, and 1.3. Modern browsers use TLS 1.3. A colleague argues: 'TLS 1.0 is only there for legacy clients — modern browsers are fine.' What's the risk?
04 //Weak Cipher Suites
Even with TLS 1.2, the security depends entirely on which cipher suites are enabled. A cipher suite specifies the key exchange algorithm, the bulk encryption algorithm, and the message authentication code (MAC).
Cipher Suite Security Classification
| Classification | Examples | Issue |
|---|---|---|
| ❌ NULL ciphers | TLS_RSA_WITH_NULL_SHA, TLS_NULL_WITH_NULL_NULL | No encryption at all — plaintext traffic |
| ❌ EXPORT ciphers | TLS_RSA_EXPORT_WITH_RC4_40_MD5 | 40/56-bit keys — trivially brute-forced (FREAK/Logjam attacks) |
| ❌ DES / 3DES | TLS_RSA_WITH_3DES_EDE_CBC_SHA | 64-bit block size vulnerable to Sweet32 birthday attack |
| ❌ RC4 | TLS_RSA_WITH_RC4_128_SHA | Statistical biases enable plaintext recovery (RFC 7465 prohibits RC4) |
| ❌ Static RSA | TLS_RSA_WITH_AES_256_CBC_SHA256 | No forward secrecy — compromised key decrypts all past traffic |
| ❌ CBC mode (TLS 1.0) | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA | Vulnerable to BEAST/Lucky13 in TLS 1.0, padding oracle attacks |
| ⚠️ CBC mode (TLS 1.2) | TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 | Generally safe in TLS 1.2 but AEAD preferred |
| ✅ AEAD ciphers | TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 | Authenticated encryption — no padding oracle, forward secrecy with ECDHE |
| ✅ ChaCha20-Poly1305 | TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 | Fast on devices without AES hardware, strong security |
1# ✅ Strong cipher suite list for TLS 1.2 (Mozilla "Modern" profile):
2TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
3TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
4TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
5TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256
6TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
7TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
8
9# Key properties of ALL recommended suites:
10# - ECDHE: Ephemeral key exchange → forward secrecy ✓
11# - GCM or POLY1305: AEAD encryption → no padding oracle ✓
12# - AES-128/256 or ChaCha20: Strong symmetric encryption ✓
13
14# ❌ Cipher suites to NEVER enable:
15# - Anything with NULL, EXPORT, DES, 3DES, RC4
16# - Anything with RSA key exchange (not ECDHE_RSA — static RSA)
17# - Anything with MD5 MACYou see this cipher suite in a server config: TLS_RSA_WITH_AES_256_GCM_SHA384. It uses AES-256 and GCM mode. Is it secure?
05 //Certificate Misconfigurations
TLS certificates provide authentication — they prove the server is who it claims to be. Certificate misconfigurations undermine this trust, enabling man-in-the-middle attacks.
Common Certificate Issues
| Issue | What Happens | Attack Scenario |
|---|---|---|
| Expired certificate | Browsers show warning, users may click through | Users trained to ignore warnings → click through attacker's cert too |
| Self-signed certificate | Not trusted by any CA — browser warning | If users accept self-signed certs, they'll accept attacker's self-signed cert |
| Wrong hostname (CN/SAN mismatch) | Certificate is for a different domain | Indicates misconfigured server or potential impersonation |
| Incomplete certificate chain | Missing intermediate CA certificates | Some clients fail validation → fall back to HTTP or skip verification |
| Wildcard certificate overuse | *.example.com on all servers | Compromise of one server exposes private key for all subdomains |
| Weak signature algorithm (SHA-1) | Certificate signed with SHA-1 | Collision attacks can forge certificates (deprecated since 2017) |
| Long-lived certificates | Certificates valid for years | More time for key compromise; misses CA revocation cycles |
1// ❌ CRITICAL: Disabling TLS certificate verification
2// This is the most dangerous TLS mistake in application code
3
4// Node.js — disabling verification globally
5process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
6
7// Node.js — per-request
8const https = require('https');
9const agent = new https.Agent({ rejectUnauthorized: false });
10fetch('https://api.example.com', { agent });
11
12// Python requests
13import requests
14requests.get('https://api.example.com', verify=False)
15
16// Java
17TrustManager[] trustAll = new TrustManager[] {
18 new X509TrustManager() {
19 public X509Certificate[] getAcceptedIssuers() { return null; }
20 public void checkClientTrusted(X509Certificate[] c, String t) {}
21 public void checkServerTrusted(X509Certificate[] c, String t) {}
22 }
23};
24
25// Go
26http.Client{
27 Transport: &http.Transport{
28 TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
29 },
30}
31
32// All of the above: COMPLETELY DISABLES CERTIFICATE VERIFICATION
33// A MITM attacker can present ANY certificate and it will be accepted!rejectUnauthorized: false or verify=False to bypass self-signed certs in dev/staging, then forget to remove it before deployment. Use proper certificates in all environments — tools like mkcert generate locally-trusted certs for development without disabling verification.06 //HSTS & HTTP Downgrade Attacks
HTTP Strict Transport Security (HSTS) tells browsers to only connect to the site over HTTPS — never HTTP. Without HSTS, the first connection to a site (or any connection after the HSTS max-age expires) is vulnerable to an SSL stripping attack.
1# User types "example.com" in browser (no https:// prefix):
2# 1. Browser sends HTTP request to http://example.com
3# 2. Server redirects: HTTP 301 → https://example.com
4# 3. Browser follows redirect to HTTPS
5
6# SSL Stripping MITM attack (Moxie Marlinspike, 2009):
7# 1. User sends HTTP request to http://example.com
8# 2. MITM intercepts and connects to https://example.com on user's behalf
9# 3. MITM returns HTTP response to user (not HTTPS!)
10# 4. User sees http://example.com — no padlock, but many users don't notice
11# 5. ALL traffic flows through MITM in plaintext — credentials stolen!
12
13# The user thinks they're on the real site.
14# The server thinks it's talking to the user over HTTPS.
15# The MITM reads everything.1# ✅ HSTS tells the browser: "NEVER connect over HTTP"
2Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
3
4# max-age=31536000 → Remember for 1 year (in seconds)
5# includeSubDomains → Apply to all subdomains too
6# preload → Eligible for browser's built-in HSTS preload list
7
8# After receiving this header over HTTPS, the browser will:
9# - Automatically convert ALL http:// requests to https://
10# - Refuse to connect if the certificate is invalid (no "click through")
11# - Remember this policy for max-age seconds
12
13# ❌ INSECURE: Common mistakes
14Strict-Transport-Security: max-age=0 # Disables HSTS!
15Strict-Transport-Security: max-age=3600 # Only 1 hour — too short
16# Missing entirely # No HSTS protection at allhstspreload.org. Requirements: serve a valid HTTPS certificate, redirect HTTP to HTTPS, serve the HSTS header with max-age ≥ 31536000, includeSubDomains, and preload.Your server redirects HTTP to HTTPS (301 redirect) but does not set the HSTS header. A colleague says the redirect is sufficient. Is this correct?
07 //Detection During Code Review
TLS misconfigurations appear in multiple places: server configuration files, application code making HTTPS requests, and missing security headers. Here is a systematic detection approach.
Code Review Detection Patterns
| Pattern | What to Look For | Risk |
|---|---|---|
| rejectUnauthorized: false | Node.js HTTPS requests with disabled cert verification | Critical |
| verify=False | Python requests library with disabled cert verification | Critical |
| InsecureSkipVerify: true | Go HTTP client with disabled cert verification | Critical |
| NODE_TLS_REJECT_UNAUTHORIZED=0 | Global TLS bypass via environment variable | Critical |
| SSLv3 / TLSv1.0 / TLSv1.1 | Server configs enabling deprecated protocols | High |
| RC4 / DES / 3DES / NULL / EXPORT | Weak cipher suites in server config | Critical |
| Missing HSTS header | No Strict-Transport-Security in response headers | High |
| Mixed content (http:// in HTTPS page) | HTTP resources loaded on HTTPS pages | High |
| Self-signed certs in production | Custom CA trust stores or cert pinning workarounds | Critical |
| Hardcoded certificates/keys | Private keys or certificates in source code | Critical |
1# Disabled certificate verification
2grep -rn "rejectUnauthorized.*false\|REJECT_UNAUTHORIZED.*0" \
3 --include="*.js" --include="*.ts" --include="*.env"
4
5grep -rn "verify.*=.*False\|verify.*False" \
6 --include="*.py"
7
8grep -rn "InsecureSkipVerify.*true" \
9 --include="*.go"
10
11# Weak protocols in config
12grep -rn "SSLv2\|SSLv3\|TLSv1\.0\|TLSv1\.1\|ssl_protocols.*TLSv1[^.]" \
13 --include="*.conf" --include="*.yaml" --include="*.yml"
14
15# Weak ciphers
16grep -rn "RC4\|DES\|NULL\|EXPORT\|3DES\|aNULL\|eNULL" \
17 --include="*.conf" --include="*.yaml" --include="*.yml"
18
19# Missing HSTS (check server framework middleware)
20grep -rn "strict-transport\|hsts\|Strict-Transport" \
21 --include="*.js" --include="*.ts" --include="*.conf"
22
23# Mixed content
24grep -rn "http://" --include="*.html" --include="*.tsx" --include="*.jsx" \
25 | grep -v "localhost\|127.0.0.1\|http://schemas"
26
27# External scan: SSL Labs server test
28# https://www.ssllabs.com/ssltest/You find this in an environment file: NODE_TLS_REJECT_UNAUTHORIZED=0. The developer says it's only for the staging environment. Should you flag this?
08 //Code-Level TLS Mistakes
Beyond server configuration, application code frequently contains TLS misconfigurations — especially in microservices that make HTTPS requests to other services, APIs, or external providers.
1// ❌ CRITICAL: Global TLS bypass (affects ALL HTTPS in the process)
2process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
3
4// ❌ CRITICAL: Per-request bypass via custom agent
5import https from 'https';
6const unsafeAgent = new https.Agent({ rejectUnauthorized: false });
7const response = await fetch('https://api.partner.com/data', {
8 agent: unsafeAgent,
9});
10
11// ❌ HIGH: Ignoring certificate errors in axios
12import axios from 'axios';
13const client = axios.create({
14 httpsAgent: new https.Agent({ rejectUnauthorized: false }),
15});
16
17// ✅ SECURE: Use proper CA bundle for internal services
18const secureAgent = new https.Agent({
19 ca: fs.readFileSync('/etc/ssl/certs/internal-ca.pem'),
20 // rejectUnauthorized defaults to true — leave it!
21});
22
23// ✅ SECURE: Use mTLS for service-to-service authentication
24const mtlsAgent = new https.Agent({
25 cert: fs.readFileSync('/etc/ssl/certs/client.pem'),
26 key: fs.readFileSync('/etc/ssl/private/client-key.pem'),
27 ca: fs.readFileSync('/etc/ssl/certs/internal-ca.pem'),
28 rejectUnauthorized: true,
29});1# ❌ CRITICAL: Disable verification globally
2import urllib3
3urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
4
5import requests
6response = requests.get('https://api.example.com', verify=False)
7
8# ❌ HIGH: Custom SSL context with weakened settings
9import ssl
10ctx = ssl.create_default_context()
11ctx.check_hostname = False
12ctx.verify_mode = ssl.CERT_NONE # Accepts ANY certificate!
13
14# ✅ SECURE: Use custom CA for internal services
15response = requests.get(
16 'https://internal-api.corp.com',
17 verify='/etc/ssl/certs/internal-ca-bundle.pem'
18)
19
20# ✅ SECURE: mTLS
21response = requests.get(
22 'https://internal-api.corp.com',
23 cert=('/path/to/client.cert', '/path/to/client.key'),
24 verify='/etc/ssl/certs/internal-ca.pem'
25)- Private keys in source code: Search for
-----BEGIN PRIVATE KEY-----or-----BEGIN RSA PRIVATE KEY-----in the codebase. Keys should be loaded from secure storage (environment variables, secret managers), never committed. - Hardcoded certificate fingerprints: While certificate pinning can enhance security, hardcoded fingerprints make rotation painful and often lead to outages when certificates are renewed.
- Mixed HTTP/HTTPS in service URLs: Check configuration files for internal service URLs using
http://instead ofhttps://— even internal traffic should be encrypted (zero-trust networking). - Missing TLS on database connections: Check database connection strings for
sslmode=disable(PostgreSQL),useSSL=false(MySQL), or missing TLS configuration.
09 //Server Configuration Hardening
Server TLS configuration is the first line of defense. Here are hardened configurations for the most common web servers and load balancers.
1# /etc/nginx/conf.d/tls.conf
2
3# Only TLS 1.2 and 1.3
4ssl_protocols TLSv1.2 TLSv1.3;
5
6# Strong cipher suites only (AEAD with forward secrecy)
7ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256';
8ssl_prefer_server_ciphers on;
9
10# ECDH curve
11ssl_ecdh_curve X25519:secp384r1;
12
13# OCSP Stapling (prove cert isn't revoked without client contacting CA)
14ssl_stapling on;
15ssl_stapling_verify on;
16resolver 8.8.8.8 8.8.4.4 valid=300s;
17
18# Session settings
19ssl_session_timeout 1d;
20ssl_session_cache shared:SSL:10m;
21ssl_session_tickets off; # Disable for forward secrecy
22
23# HSTS
24add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
25
26# Redirect all HTTP to HTTPS
27server {
28 listen 80;
29 server_name example.com;
30 return 301 https://$server_name$request_uri;
31}1# /etc/apache2/conf-available/tls-hardening.conf
2
3SSLProtocol -all +TLSv1.2 +TLSv1.3
4SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256
5SSLHonorCipherOrder on
6
7# OCSP Stapling
8SSLUseStapling on
9SSLStaplingCache "shmcb:/var/run/ocsp(128000)"
10
11# HSTS
12Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"ssl-config.mozilla.org that generates hardened TLS configurations for Nginx, Apache, HAProxy, AWS ALB, Caddy, and more. It offers three profiles: Modern (TLS 1.3 only), Intermediate (TLS 1.2 + 1.3), and Old (for legacy compatibility). Use "Intermediate" for most production deployments and "Modern" for new applications.10 //Certificate Transparency & Pinning
Certificate Transparency (CT) is a framework that requires Certificate Authorities to publicly log every certificate they issue. This enables domain owners to detect rogue or misissued certificates — for example, if a compromised CA issues a certificate for your domain to an attacker.
Since 2018, Chrome requires all publicly-trusted certificates to be logged in at least two CT logs. If a certificate isn't in CT logs, Chrome shows a warning. This means any attacker who obtains a fraudulent certificate for your domain will create a publicly visible record.
- Monitor CT logs for your domains: Use tools like
crt.sh, Facebook's CT monitor, or Certspotter to receive alerts when new certificates are issued for your domain. - Expect-CT header (deprecated): Previously used to enforce CT, but now superseded by browser-built-in CT requirements. No longer needed.
- CAA DNS records: Add Certificate Authority Authorization (CAA) records to your DNS to specify which CAs are allowed to issue certificates for your domain. This prevents a compromised CA that's not on your CAA list from issuing a valid cert.
1# Check CT logs for your domain
2# https://crt.sh/?q=example.com
3
4# Add CAA DNS record to restrict which CAs can issue certs:
5example.com. IN CAA 0 issue "letsencrypt.org"
6example.com. IN CAA 0 issuewild "letsencrypt.org"
7example.com. IN CAA 0 iodef "mailto:security@example.com"
8
9# This means:
10# - Only Let's Encrypt can issue certificates for example.com
11# - Only Let's Encrypt can issue wildcard certificates
12# - Security team is notified of policy violations11 //Real-World Case Studies
12 //Conclusion & Checklist
TLS misconfiguration is one of the most impactful yet often overlooked vulnerability classes. A single weak cipher suite, a disabled certificate check, or a missing HSTS header can expose all traffic to interception. Use this checklist during every code review and deployment.
SSL/TLS Security Checklist
| Category | Check | Priority |
|---|---|---|
| Protocols | Are SSL 2.0, SSL 3.0, TLS 1.0, and TLS 1.1 disabled? | Critical |
| Protocols | Is TLS 1.3 enabled and preferred? | High |
| Ciphers | Are NULL, EXPORT, DES, 3DES, and RC4 ciphers disabled? | Critical |
| Ciphers | Do all enabled cipher suites use ECDHE for forward secrecy? | Critical |
| Ciphers | Are only AEAD cipher suites (GCM, ChaCha20-Poly1305) enabled? | High |
| Certificates | Is the certificate valid, not expired, and from a trusted CA? | Critical |
| Certificates | Does the certificate CN/SAN match the actual hostname? | Critical |
| Certificates | Is the full certificate chain served (including intermediates)? | High |
| Certificates | Are CAA DNS records configured to restrict certificate issuance? | Medium |
| Headers | Is HSTS set with max-age ≥ 31536000, includeSubDomains, preload? | Critical |
| Code | Is certificate verification NEVER disabled (rejectUnauthorized, verify=False)? | Critical |
| Code | Are private keys NOT hardcoded in source code? | Critical |
| Code | Do database connections use TLS (sslmode=require, useSSL=true)? | High |
| Code | Are all internal service-to-service calls over HTTPS? | High |
| Monitoring | Is CT log monitoring set up for your domains? | Medium |
| Testing | Does SSL Labs report an A or A+ grade? | High |