Why it matters
Any site can read this API's responses with the user's cookies.
How to fix it
List the allowed origins explicitly when AllowCredentials is true.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
package main
import "github.com/rs/cors"
var c = cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowCredentials: true,
})package main
import "github.com/rs/cors"
var c = cors.New(cors.Options{
AllowedOrigins: []string{"https://app.example.com"},
AllowCredentials: true,
})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 RSA key (Go)
GoSeverity: Medium
trustivan-go-weak-rsa-key - JWT hardcoded secret (Go)
GoSeverity: High
trustivan-go-jwt-hardcoded-secret - JWT none algorithm (Go)
GoSeverity: High
trustivan-go-jwt-none-algorithm - CSRF insecure cookie (Go)
GoSeverity: Medium
trustivan-go-csrf-insecure-cookie - Code injection from request input (Go)
GoSeverity: High
trustivan-go-taint-code-injection - Template HTML non literal (Go)
GoSeverity: Medium
trustivan-go-template-html-non-literal
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