Security
Critical security rules for preventing vulnerabilities
Run All Security Rules
pathfinder scan --ruleset golang/security --project .Rules
Use of MD5 Weak Hash Algorithm
HIGHDetects use of MD5 (crypto/md5) which is cryptographically broken — collision attacks are feasible in seconds and GPU cracking reaches 164 billion hashes/second.
Use of SHA1 Weak Hash Algorithm
HIGHDetects use of SHA1 (crypto/sha1) which has a proven collision (SHAttered, 2017) and is deprecated by NIST for all applications through 2030.
Use of DES or 3DES Weak Cipher
HIGHDetects use of DES/3DES (crypto/des) — DES uses a 56-bit key exhausted in 22 hours (1999); 3DES is vulnerable to the SWEET32 birthday attack and disallowed by NIST after December 31, 2023.
Use of RC4 Stream Cipher
HIGHDetects use of RC4 (crypto/rc4) which is prohibited in TLS by RFC 7465 (2015), has known statistical keystream biases, and is labeled "cryptographically broken" in the Go standard library.
MD5 Used for Password Hashing
CRITICALMD5 hash output flows into password-related functions — MD5 runs at 164 billion hashes/second on a single GPU, making any MD5-hashed password database crackable in seconds to minutes.
SQL Injection via GORM Raw/Exec
CRITICALUser-controlled input flows into GORM Raw() or Exec() raw SQL methods without parameterization — GORM's ORM safety guarantees do not apply to Raw/Exec with string concatenation.
SQL Injection via GORM Query Builder Methods
HIGHUser-controlled input flows into GORM query builder methods (Order, Where, Group, Having) that accept raw SQL string fragments — GORM does not escape these clause arguments.
JWT Parsed Without Signature Verification
HIGHjwt.ParseUnverified() skips signature validation entirely — any attacker can forge arbitrary JWT claims (sub, role, admin) without knowing the signing key.
HTTP Server Without TLS
HIGHDetects http.ListenAndServe() starting an unencrypted HTTP server — all traffic including credentials and session tokens travels in plaintext, interceptable by any network observer.
gRPC Client Without TLS
HIGHDetects gRPC client using grpc.WithInsecure() or grpc.WithNoTLS() which disables transport encryption — all RPC calls including auth tokens and payloads travel in plaintext.
Path Traversal via HTTP Input
HIGHUser-controlled HTTP input reaches file system operations without path validation — filepath.Clean() alone is insufficient; filepath.Join("/uploads", "/etc/passwd") returns "/etc/passwd" in Go.
Open Redirect via User-Controlled URL
HIGHUser-controlled input flows into HTTP redirect functions without URL validation — open redirect enables phishing, OAuth token theft, and malware distribution via trusted-domain URLs.
SQL Injection via database/sql
CRITICALUser-controlled input reaches database/sql query methods without parameterization, enabling SQL injection — ranked
OS Command Injection via HTTP Input
CRITICALUser-controlled HTTP request input reaches os/exec command execution — the critical pattern is exec.Command("sh", "-c", userInput) which enables full shell injection with metacharacters.
Hardcoded Credentials in Source Code
HIGHDetects credential-named variables (password, secret, api_key, token) being assigned or passed as arguments — hardcoded secrets are exposed in git history, compiled binaries, container images, and CI/CD logs.
SQL Injection via sqlx
CRITICALUser-controlled input reaches sqlx query methods without parameterization — sqlx's convenience wrappers (Get, Select, NamedExec) are also vulnerable when used with raw string concatenation.
Server-Side Request Forgery via go-resty HTTP Client
HIGHUser-controlled input flows into go-resty HTTP client calls without URL validation, enabling SSRF attacks that steal cloud metadata credentials or probe internal services.
SSRF via Outbound net/http Client Calls
HIGHUser-controlled input flows into net/http standard library client methods without URL validation, enabling SSRF attacks against internal services and cloud metadata endpoints.
XSS via Unsafe html/template Type Conversions
HIGHUser input cast to template.HTML, template.CSS, template.JS, or template.URL bypasses Go's context-aware auto-escaping, allowing raw attacker payload to reach the browser.
XSS via fmt.Fprintf to http.ResponseWriter
HIGHUser input flows into fmt.Fprintf/Fprintln/Fprint writing directly to ResponseWriter — fmt functions perform no HTML escaping, any user-controlled format argument renders as raw HTML in the browser.
XSS via io.WriteString to http.ResponseWriter
HIGHUser input flows into io.WriteString writing directly to ResponseWriter without HTML escaping — io.WriteString is a raw byte writer that performs no HTML neutralization.