# Improper Verification of Cryptographic Signature (CWE-347) The product does not verify, or incorrectly verifies, the cryptographic signature for data. **Stack:** Go - Prevalence: Wysoka Często wykorzystywana - Impact: Krytyczny 1 reguł o krytycznym poziomie - Prevention: Udokumentowane 4 przykładów poprawek **OWASP:** Cryptographic Failures (A02:2021-Cryptographic Failures) - #2 ## Description Cryptographic signatures are used to verify the authenticity and integrity of data. When signature verification is missing or incorrectly implemented, attackers can forge or tamper with data. ## Prevention Strategie zapobiegania dla Improper Signature Verification oparte na 1 regułach detekcji Shoulder. ### Go Validate JWT algorithm explicitly, use strong secrets, and set expiration ## Warning Signs - [HIGH] JWT implementation has security weaknesses ## Consequences - Obejście mechanizmu ochrony - Wykonanie nieautoryzowanego kodu - Modyfikacja danych aplikacji ## Mitigations - Zanim zaufasz danym, zawsze weryfikuj podpisy - Do weryfikacji podpisów używaj dobrze przetestowanych bibliotek kryptograficznych - W JWT zawsze weryfikuj podpis i sprawdzaj algorytm ## Detection - Total rules: 4 - Critical: 1 - Languages: python, go, javascript, typescript ## Rules by Language ### Go (1 rules) - **JWT Security Vulnerabilities** [HIGH]: JWT allows "none" algorithm, uses weak secret, or lacks expiration. - Remediation: Validate algorithm explicitly and set token expiration. ```go token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) { if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok { return nil, fmt.Errorf("unexpected method: %v", token.Header["alg"]) } return []byte(os.Getenv("JWT_SECRET")), nil }) ``` Learn more: https://shoulder.dev/learn/go/cwe-347/jwt-vulnerabilities