Security

Critical security rules for preventing vulnerabilities

21
Security Rules

Run All Security Rules

pathfinder scan --ruleset golang/security --project .

Rules

Use of MD5 Weak Hash Algorithm

HIGH

Detects use of MD5 (crypto/md5) which is cryptographically broken — collision attacks are feasible in seconds and GPU cracking reaches 164 billion hashes/second.

gosecuritycryptomd5weak-hashcollision-attackCWE-328OWASP-A02
CWE-328, CWE-916
Updated 2026-04-13

Use of SHA1 Weak Hash Algorithm

HIGH

Detects use of SHA1 (crypto/sha1) which has a proven collision (SHAttered, 2017) and is deprecated by NIST for all applications through 2030.

gosecuritycryptosha1weak-hashshatteredcollision-attackCWE-328OWASP-A02
CWE-328
Updated 2026-04-13

Use of DES or 3DES Weak Cipher

HIGH

Detects 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.

gosecuritycryptodes3destriple-dessweet32birthday-attackCWE-327OWASP-A02
CWE-327
Updated 2026-04-13

Use of RC4 Stream Cipher

HIGH

Detects 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.

gosecuritycryptorc4stream-cipherrfc7465wepfms-attackCWE-327OWASP-A02
CWE-327
Updated 2026-04-13

MD5 Used for Password Hashing

CRITICAL

MD5 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.

gosecuritycryptomd5password-hashingCWE-916CWE-327OWASP-A02OWASP-A07
CWE-916, CWE-327, CWE-328
Updated 2026-04-13

SQL Injection via GORM Raw/Exec

CRITICAL

User-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.

gosecuritysql-injectiongormraw-sqlCWE-89OWASP-A03
CWE-89
Updated 2026-04-13

SQL Injection via GORM Query Builder Methods

HIGH

User-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.

gosecuritysql-injectiongormquery-builderorder-by-injectionCWE-89OWASP-A03
CWE-89
Updated 2026-04-13

JWT Parsed Without Signature Verification

HIGH

jwt.ParseUnverified() skips signature validation entirely — any attacker can forge arbitrary JWT claims (sub, role, admin) without knowing the signing key.

gosecurityjwtparse-unverifiedauthentication-bypassCWE-345CWE-347OWASP-A08
CWE-345, CWE-347
Updated 2026-04-13

HTTP Server Without TLS

HIGH

Detects http.ListenAndServe() starting an unencrypted HTTP server — all traffic including credentials and session tokens travels in plaintext, interceptable by any network observer.

gosecuritytlshttpcleartextman-in-the-middleCWE-319OWASP-A02
CWE-319
Updated 2026-04-13

gRPC Client Without TLS

HIGH

Detects gRPC client using grpc.WithInsecure() or grpc.WithNoTLS() which disables transport encryption — all RPC calls including auth tokens and payloads travel in plaintext.

gosecuritygrpctlsinsecurecleartextmicroservicesCWE-300CWE-319OWASP-A02
CWE-300, CWE-319
Updated 2026-04-13

Path Traversal via HTTP Input

HIGH

User-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.

gosecuritypath-traversaldirectory-traversalzip-slipfile-systemCWE-22OWASP-A01
CWE-22
Updated 2026-04-13

Open Redirect via User-Controlled URL

HIGH

User-controlled input flows into HTTP redirect functions without URL validation — open redirect enables phishing, OAuth token theft, and malware distribution via trusted-domain URLs.

gosecurityopen-redirectphishingoauthCWE-601OWASP-A01
CWE-601
Updated 2026-04-13

SQL Injection via database/sql

CRITICAL

User-controlled input reaches database/sql query methods without parameterization, enabling SQL injection — ranked

gosecuritysql-injectiondatabase/sqlCWE-89OWASP-A03
CWE-89
Updated 2026-04-13

OS Command Injection via HTTP Input

CRITICAL

User-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.

gosecuritycommand-injectionos-execshell-injectionCWE-78OWASP-A03
CWE-78
Updated 2026-04-13

Hardcoded Credentials in Source Code

HIGH

Detects 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.

gosecurityhardcoded-credentialssecretsapi-keytokenpasswordCWE-798CWE-259CWE-321OWASP-A07OWASP-A02
CWE-798, CWE-259, CWE-321
Updated 2026-04-13

SQL Injection via sqlx

CRITICAL

User-controlled input reaches sqlx query methods without parameterization — sqlx's convenience wrappers (Get, Select, NamedExec) are also vulnerable when used with raw string concatenation.

gosecuritysql-injectionsqlxCWE-89OWASP-A03
CWE-89
Updated 2026-04-13

Server-Side Request Forgery via go-resty HTTP Client

HIGH

User-controlled input flows into go-resty HTTP client calls without URL validation, enabling SSRF attacks that steal cloud metadata credentials or probe internal services.

gosecurityssrfrestyhttp-clientcloud-metadataCWE-918OWASP-A10
CWE-918
Updated 2026-04-13

SSRF via Outbound net/http Client Calls

HIGH

User-controlled input flows into net/http standard library client methods without URL validation, enabling SSRF attacks against internal services and cloud metadata endpoints.

gosecurityssrfnet-httpcloud-metadataCWE-918OWASP-A10
CWE-918
Updated 2026-04-13

XSS via Unsafe html/template Type Conversions

HIGH

User 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.

gosecurityxssreflected-xssstored-xsstemplatehtml-templatecontext-aware-escapingCWE-79OWASP-A03
CWE-79, CWE-116
Updated 2026-04-13

XSS via fmt.Fprintf to http.ResponseWriter

HIGH

User 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.

gosecurityxssresponsewriterfmtreflected-xssCWE-79CWE-116OWASP-A03
CWE-79, CWE-116
Updated 2026-04-13

XSS via io.WriteString to http.ResponseWriter

HIGH

User input flows into io.WriteString writing directly to ResponseWriter without HTML escaping — io.WriteString is a raw byte writer that performs no HTML neutralization.

gosecurityxssresponsewriterioreflected-xssCWE-79CWE-116OWASP-A03
CWE-79, CWE-116
Updated 2026-04-13