Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V5906. OWASP. Possible SQL...
menu mobile close menu
Analyzing projects
Additional information
toggle menu Contents

V5906. OWASP. Possible SQL injection. Potentially tainted data is used to create an SQL command.

Nov 26 2026

The analyzer has detected that an SQL statement was created using unverified data obtained from an external source. If this data is compromised, it may cause an SQL injection.

Such vulnerabilities fall under A5:2025 Injection in the OWASP Top 10 Application Security Risks 2025.

The example:

func ProcessUser(db *sql.DB, r *http.Request) {
  name := r.URL.Query().Get("name")
  query := fmt.Sprintf("SELECT id, name FROM users WHERE name = '%s'", name)
  rows, err := db.Query(query)
  ....
}

The value of the name variable obtained from the HTTP request is used when an SQL command is created. Using external data without any verification is dangerous, as it exposes the system to attackers who can inject commands.

For example, instead of entering the expected username, an attacker might enter a special query. The database will then retrieve all users' data, which will be processed further.

An example of a compromised query string for the query shown above:

' OR '1'='1

To prevent such queries, pass name separately from the SQL query text:

func ProcessUser(db *sql.DB, r *http.Request) {
  name := r.URL.Query().Get("name")
  query := "SELECT id, name FROM users WHERE name = ?"
  rows, err := db.Query(query, name)
  ....
}

In this case, name is passed as an argument to the Query method. According to the documentation, this approach is safe.

This diagnostic rule is classified as: