Why it matters
Data encrypted with these ciphers can be recovered by an attacker who captures enough of it, so the encryption no longer keeps it confidential.
How to fix it
Use AES-GCM (crypto/aes with cipher.NewGCM) or golang.org/x/crypto/chacha20poly1305.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
package fixture
import (
"crypto/cipher"
"crypto/des"
)
func block(key []byte) (cipher.Block, error) {
return des.NewCipher(key)
}package fixture
import (
"crypto/aes"
"crypto/cipher"
)
func aead(key []byte) (cipher.AEAD, error) {
b, err := aes.NewCipher(key)
if err != nil {
return nil, err
}
return cipher.NewGCM(b)
}What TrustIvan reads
Runs on repository scans of Go source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- Weak hash (Go)
GoSeverity: Medium
trustivan-go-weak-hash - Math rand secret (Go)
GoSeverity: Medium
trustivan-go-math-rand-secret - SQL string formatting (Go)
GoSeverity: Medium
trustivan-go-sql-string-formatting - TLS old minimum version (Go)
GoSeverity: Medium
trustivan-go-tls-old-minimum-version - Template injection from request input (Go)
GoSeverity: High
trustivan-go-taint-template-injection - SSH host key not verified (Go)
GoSeverity: High
trustivan-go-ssh-host-key-not-verified
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation