Cryptography Weaknesses
Overview
Cryptography is a key area of security used to keep secrets confidential. However, when implemented incorrectly, these secrets can be leaked or the cryptographic protections can be manipulated to bypass security controls. This module explores three critical cryptographic weaknesses:- Encoding vs. Encryption - Using XOR encoding instead of proper encryption
- ECB Mode Vulnerabilities - Block cipher exploitation through cut-and-paste attacks
- Padding Oracle Attacks - Exploiting CBC mode padding validation
Objective
Exploit weak cryptographic implementations at each security level to gain unauthorized access or elevate privileges.Security Levels
Low Level: XOR “Encryption”
Vulnerable Code
The low level uses XOR encoding, which is fundamentally insecure:vulnerabilities/cryptography/source/medium.php:2-42
Token Format
vulnerabilities/cryptography/source/high.php:3-69
Exploitation
The system is vulnerable to padding oracle attacks against AES-CBC:- Server validates PKCS#7 padding
- Different errors reveal padding validity
- Attacker can decrypt ciphertext byte-by-byte
- Attacker can forge valid ciphertexts
- Intercept encrypted token
- Modify ciphertext bytes systematically
- Observe server responses (valid/invalid padding)
- Use padding information to decrypt or forge tokens
- Cryptopals: Exploiting CBC Padding Oracles
- Download
source/download_oracle_attack.phpfor working exploit
Key Vulnerability
Padding oracle attacks exploit the difference in error messages when:- Padding is invalid → “Padding error”
- Padding is valid but data is wrong → “Authentication error”
