Interactive Playground
Experiment with the vulnerable code and security rule below. Edit the code to see how the rule detects different vulnerability patterns.
pathfinder scan --ruleset python/PYTHON-CRYPTO-SEC-005 --project .About This Rule
Understanding the vulnerability and how it is detected
This rule detects calls to `Crypto.Cipher.DES.new()` from the PyCryptodome library. DES (Data Encryption Standard) uses a 56-bit key. In 1999, the EFF's Deep Crack machine broke a DES-encrypted challenge in 22 hours. Modern GPU clusters can exhaust the entire DES keyspace in minutes. The algorithm is completely broken for confidentiality purposes.
DES was standardized in 1977 and was already under brute-force pressure by the late 1990s. FIPS 46-3 (the DES standard) was formally withdrawn in 2005. NIST SP 800-131A disallows DES for all uses. The 64-bit block size also exposes DES to the Sweet32 birthday attack for any key, and its eight S-boxes have been studied extensively with differential and linear cryptanalysis.
The rule matches `PyCryptoCipherDES.method("new")`. There is no safe way to use single DES. See PYTHON-CRYPTO-SEC-005a for the companion rule covering 3DES.
Security Implications
Potential attack scenarios if this vulnerability is exploited
56-Bit Key Brute-Forceable in Under 24 Hours
DES's 56-bit key space (2^56 = ~72 quadrillion keys) was publicly brute-forced in 22 hours in 1999 using the EFF DES Cracker costing $250,000. Modern commodity GPU clusters perform this attack in minutes. Any DES-encrypted data should be considered compromised if an attacker had access to the ciphertext.
FIPS 46-3 Formally Withdrawn in 2005
The DES standard FIPS 46-3 was withdrawn by NIST in 2005 and is no longer approved for any federal information processing use. Systems that encrypt sensitive data with DES are automatically non-compliant with FISMA, FedRAMP, HIPAA Security Rule technical safeguards, and PCI DSS.
64-Bit Block Size Adds Sweet32 Exposure
Beyond the key length problem, DES uses a 64-bit block size. Under sustained encryption with the same key, block collisions become probable after ~32GB -- enabling birthday-bound plaintext recovery attacks. A single encryption session is unlikely to reach this limit, but long-running services that reuse DES keys accumulate ciphertext toward this threshold.
No Authentication -- Vulnerable to Chosen-Ciphertext Attacks
DES in any mode available via PyCryptodome (CBC, CFB, OFB, ECB) provides no integrity or authentication. CBC mode DES without a MAC is vulnerable to padding oracle and chosen-ciphertext attacks. ECB mode leaks plaintext patterns directly. Neither mode is safe for any use case.
How to Fix
Recommended remediation steps
- 1Replace Crypto.Cipher.DES with AES in GCM mode (AES.new(key, AES.MODE_GCM)) for authenticated encryption
- 2Use ChaCha20-Poly1305 via the cryptography library as an alternative when AES hardware acceleration is unavailable
- 3Treat all data previously encrypted with DES as potentially compromised and assess exposure accordingly
- 4Generate 256-bit (32-byte) AES keys using os.urandom(32) or a proper KDF like PBKDF2/scrypt/Argon2
- 5Audit all key derivation and storage code when migrating from DES -- a DES key is 8 bytes; an AES-256 key is 32 bytes
Detection Scope
How Code Pathfinder analyzes your code for this vulnerability
This rule matches calls to `Crypto.Cipher.DES.new()` in PyCryptodome via the QueryType pattern `PyCryptoCipherDES.method("new")`. It fires on any single-DES cipher object instantiation regardless of mode (CBC, ECB, CFB, OFB, CTR). There is no safe configuration for single DES. The companion rule PYTHON-CRYPTO-SEC-005a covers Triple DES (3DES, DES3) in PyCryptodome.
Compliance & Standards
Industry frameworks and regulations that require detection of this vulnerability
References
External resources and documentation
Similar Rules
Explore related security rules for Python
Triple DES (3DES) Cipher Usage via PyCryptodome
Detects use of Triple DES (3DES) through PyCryptodome, which has a 64-bit block size vulnerable to Sweet32 birthday attacks and was deprecated by NIST after 2023.
RC4 (ARC4) Cipher Usage via cryptography Library
Detects use of the RC4 stream cipher through the cryptography library's ARC4 algorithm, which has known keystream biases and is prohibited by RFC 7465.
RC4 (ARC4) Cipher Usage via PyCryptodome
Detects use of the RC4 stream cipher through PyCryptodome's ARC4 module, which has known keystream biases and is prohibited by RFC 7465.
Frequently Asked Questions
Common questions about DES Cipher Usage via PyCryptodome
New feature
Get these findings posted directly on your GitHub pull requests
The DES Cipher Usage via PyCryptodome rule runs in CI and posts inline review comments on the exact lines — no dashboard, no SARIF viewer.