Go Query String Sql Injection
Description
Detects SQL injection vulnerabilities in Go applications using the database/sql package. The detector identifies database query operations where unsanitized user input could be directly concatenated or interpolated into SQL statements, potentially allowing malicious SQL code execution.
Detection Strategy
• Verifies that the database/sql package is imported in the source code
• Identifies database query method calls (like .Query(), .QueryRow(), .Exec())
• Examines the first argument of these query methods for unsafe input
• Checks if the query string contains unsanitized user-controlled data
• Reports a vulnerability if the query parameter is constructed using unsafe string operations with user input
Vulnerable code example
package main
import (
"database/sql"
"fmt"
"net/http"
)
...✅ Secure code example
package main
import (
"database/sql"
"net/http"
)
func secureHandler(w http.ResponseWriter, r *http.Request) {...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.