# Log Injection / Log Forging - ID: go-log-injection - Severity: MEDIUM - CWE: Log Injection (CWE-117) - Languages: Go - Frameworks: stdlib, gin, echo, fiber, chi, gorilla ## Description Detects unsanitized user input flowing into log statements, enabling log forging attacks. ## Detection Message Untrusted input from {source} reaches log statement at {sink}. This allows an attacker to forge log entries or inject malicious content. ## Remediation Remove newlines and control characters from user input before logging. ```go sanitized := strings.ReplaceAll(userInput, "\n", "") sanitized = strings.ReplaceAll(sanitized, "\r", "") log.Printf("User action: %s", sanitized) ``` Learn more: https://shoulder.dev/learn/go/cwe-117/log-injection ## Documentation [object Object] ## Related Rules - **Log Injection** [LOW]: - **Log Injection** [MEDIUM]: - **Log Injection / Log Forging** [MEDIUM]: