OWASP WSTG: Part 10 - Weak Cryptography
WSTG v4.2 section 4.9 explained: weak transport layer security (TLS), padding oracle attacks, sensitive information over unencrypted channels, and weak encryption or hashing, with test commands and fixes.
Cryptography protects data in transit and at rest, but only when it is configured and used correctly. A valid TLS certificate on an outdated protocol, a cookie encrypted with a flawed mode, or passwords stored with MD5 all give a false sense of safety. “Cryptographic Failures” is number 2 in the OWASP Top 10 2021.
Weak Cryptography testing (WSTG section 4.9, IDs WSTG-CRYP-*) checks the TLS configuration, looks for padding-oracle weaknesses, hunts sensitive data sent in the clear, and reviews the encryption and hashing the application uses.
Source: WSTG v4.2 §4.9 Testing for Weak Cryptography (CC BY-SA 4.0), explained and expanded. Only test systems you are authorised to test.
Key Takeaways
- Test the TLS configuration, not just “is there HTTPS”: protocol versions, cipher suites, certificate validity.
- A padding oracle turns an error message into a decryption key: small leaks about padding break the whole ciphertext.
- Find sensitive data travelling or stored in the clear: HTTP, Basic Auth over HTTP, secrets in source or storage.
- Old algorithms are findings: SSL/early TLS, RC4, 3DES, MD5, SHA-1, ECB mode, unsalted hashes.
- Fix with modern defaults: TLS 1.2/1.3, strong ciphers, authenticated encryption (AES-GCM), and slow salted password hashing (bcrypt/argon2).
Where Crypto Goes Wrong
flowchart TD
T["Transport: TLS config<br/>versions, ciphers, certs (CRYP-01)"] --> CH["Clear-text leaks<br/>HTTP, Basic Auth, source (CRYP-03)"]
T --> PO["Padding oracle<br/>client-side encrypted state (CRYP-02)"]
CH --> WE["Weak algorithms<br/>MD5/SHA-1, RC4/3DES, ECB,<br/>unsalted hashes (CRYP-04)"]
WSTG-CRYP-01: Weak Transport Layer Security
What it checks: that TLS is configured strongly: good protocol versions, strong cipher suites, a valid certificate, and no way to bypass it.
How to test: scan the TLS endpoint.
1
2
3
testssl.sh https://example.com
sslscan example.com:443
nmap --script ssl-enum-ciphers -p 443 example.com
Look for:
- Protocols: SSLv2/SSLv3, TLS 1.0 and TLS 1.1 are deprecated; only TLS 1.2 and 1.3 should be enabled.
- Cipher suites: no RC4, no 3DES, no export/NULL ciphers; forward secrecy (ECDHE) preferred.
- Certificate: not expired, matches the hostname, trusted chain, strong key (RSA ≥ 2048 or ECDSA), signed with SHA-256+.
- Known issues: Heartbleed, ROBOT, and downgrade protection.
Also test implementation at the application level:
- Mixed content: an HTTPS page loading scripts/CSS over HTTP (breaks the protection).
- HTTP → HTTPS redirect and HSTS (ties to Part 3, CONF-07).
- Secure cookies (ties to Part 7, SESS-02).
Fix: disable old protocols and weak ciphers, use a modern config (Mozilla SSL Configuration Generator), keep certificates valid and strong, eliminate mixed content, and enforce HTTPS + HSTS.
WSTG-CRYP-02: Padding Oracle
What it checks: whether the application reveals, through different responses or errors, whether the padding of decrypted data is valid. With a CBC-mode cipher, that single bit of feedback lets an attacker decrypt (and sometimes forge) ciphertext without the key.
Where it appears: anything the client holds that the server decrypts: encrypted cookies, ViewState, “remember me” tokens, encrypted URL parameters, hidden fields.
How to test:
- Find a parameter that looks like encrypted data (base64, length a multiple of 8/16 bytes).
- Tamper with the last bytes and compare responses: a different error/status/time for “bad padding” vs “bad data” is the oracle.
- Confirm/exploit with a tool:
1
padbuster "https://example.com/app?token=<b64ct>" "<b64ct>" 16 -cookies "SESS=..."
What a finding looks like: an encrypted token where flipping a byte yields a distinct “padding invalid” response, allowing full decryption of session state.
Fix: use authenticated encryption (AES-GCM or encrypt-then-MAC); verify the MAC before decrypting; return a single generic error regardless of why decryption failed; keep secrets server-side instead of in client tokens.
WSTG-CRYP-03: Sensitive Information over Unencrypted Channels
What it checks: sensitive data sent (or stored) without proper encryption, so it can be read on the network or on disk.
How to test: watch traffic and inspect storage for:
- Basic Authentication over HTTP: credentials are only base64-encoded, trivially decoded.
- Form login over HTTP, or a session cookie sent over HTTP (ties to CRYP-01/SESS).
- Sensitive data in the URL (tokens, IDs, PII), which lands in logs and
Referer. - Secrets in source, comments or client storage: API keys, passwords in JavaScript,
localStorage. - Unencrypted back-end channels (app-to-DB, internal APIs) where in scope.
1
2
# Is any auth/sensitive endpoint reachable or posting over plain HTTP?
curl -si http://example.com/login -d 'u=a&p=b' | head
Fix: HTTPS everywhere with HSTS, never put secrets in URLs or client code, use POST for sensitive data, and encrypt sensitive data at rest and on internal channels.
WSTG-CRYP-04: Weak Encryption
What it checks: use of broken or outdated cryptographic algorithms and bad practices, in how the application encrypts data and hashes passwords.
How to test (black box signals + gray-box source review):
| Problem | What to look for |
|---|---|
| Weak hashes | MD5, SHA-1 used for integrity or passwords |
| Fast hashes for passwords | Plain SHA-256 instead of bcrypt/scrypt/argon2 |
| Unsalted / globally salted hashes | Identical hashes for identical passwords |
| Weak ciphers | DES, 3DES, RC4 |
| Insecure mode | ECB (identical plaintext blocks → identical ciphertext), reused IV/nonce |
| Hard-coded keys | Keys/secrets in source or config in the repo |
| Weak randomness | rand()/Math.random() for tokens instead of a CSPRNG |
For password hashes you recover elsewhere, the format often reveals the algorithm ($2y$ bcrypt, $argon2id$, a bare 32-hex string = likely MD5).
Fix: passwords with bcrypt, scrypt or argon2 (unique per-user salt, sensible cost); data with AES-256-GCM; strong random IVs/nonces, never reused; tokens from a CSPRNG; keys in a secrets manager, rotated; retire MD5/SHA-1/DES/3DES/RC4/ECB.
Worked Example: Password Storage Done Wrong, Then Right (CRYP-04)
If a database is ever leaked, the difference between a minor incident and mass account takeover is entirely in how the passwords were hashed.
Vulnerable — a fast, unsalted hash:
1
2
3
4
import hashlib
def store(pw):
return hashlib.md5(pw.encode()).hexdigest() # fast, unsalted -> instantly cracked
# "password" -> 5f4dcc3b5aa765d61d8327deb882cf99 (same for every user, in every wordlist)
Why it is fatal once leaked:
1
2
3
# an attacker cracks millions of MD5/SHA-1 hashes per second on a single GPU
hashcat -m 0 -a 0 leaked_md5.txt rockyou.txt # MD5
# unsalted means identical passwords share a hash -> sort | uniq -c reveals the common ones
Fixed — a slow, salted, purpose-built password hash (bcrypt, scrypt or argon2):
1
2
3
4
5
6
7
import bcrypt
def store(pw):
# bcrypt generates a unique salt per user and is deliberately slow (cost=12)
return bcrypt.hashpw(pw.encode(), bcrypt.gensalt(rounds=12)).decode()
def verify(pw, stored):
return bcrypt.checkpw(pw.encode(), stored.encode())
1
2
3
4
// Node equivalent with argon2id (the current first choice)
const argon2 = require('argon2');
const hash = await argon2.hash(password, { type: argon2.argon2id });
const ok = await argon2.verify(hash, password);
The same “fast vs authenticated/strong” theme runs through the whole category: use AES-256-GCM (not ECB) for data, unique random IVs/nonces, a CSPRNG for tokens (secrets/crypto.randomBytes, never rand()/Math.random()), and keys in a secrets manager.
Real-world case. Breaches that exposed MD5/SHA-1 or unsalted hashes (LinkedIn 2012, and many since) led to tens of millions of passwords being cracked within days, feeding the credential-stuffing lists that drive the attacks in Part 5. The hash choice made at development time decided the blast radius years later.
Hands-on Practice
- PortSwigger Academy — the authentication and JWT labs touch weak-secret and algorithm issues; test TLS config against your own host with
testssl.sh. - CryptoHack (cryptohack.org) — hands-on crypto challenges including padding oracles and weak modes.
- Point
testssl.sh/sslscanat a deliberately weak TLS endpoint (e.g. badssl.com) to see every flag a scan can raise.
Checklist: Weak Cryptography
| ID | Test | Main tools |
|---|---|---|
| WSTG-CRYP-01 | Weak transport layer security | testssl.sh, sslscan, nmap ssl-enum-ciphers |
| WSTG-CRYP-02 | Padding oracle | padbuster, PadBuster/Burp, manual byte-flipping |
| WSTG-CRYP-03 | Sensitive info over unencrypted channels | Burp/ZAP, curl, source review |
| WSTG-CRYP-04 | Weak encryption | Source review, hash-identifier, config review |
Previous: Part 9 - Error Handling · Next: Part 11 - Business Logic
References
- WSTG-CRYP-01 Weak Transport Layer Security
- WSTG-CRYP-02 Padding Oracle
- WSTG-CRYP-03 Sensitive Information Sent via Unencrypted Channels
- WSTG-CRYP-04 Weak Encryption
- Mozilla SSL Configuration Generator
- OWASP Cheat Sheets: Transport Layer Protection · Password Storage · Cryptographic Storage
Further reading
- OWASP Top 10 2021 — A02 Cryptographic Failures.
- NIST SP 800-52r2 (TLS guidance) and the SSL Labs test for a public grade.
- Serious Cryptography (Jean-Philippe Aumasson) — the best accessible reference for why these rules exist.
Comments
Questions, corrections or another approach? Comment with your GitHub account.