Skip to content
SQL injection Write-up Beginner

Sql Injection Vulnerability In Golang Code 2

The code concatenates user input directly into an SQL query, allowing an attacker to inject malicious SQL. This could let an attacker read or modify database data.

Aswin KV Follow

Published on infosecwriteups.com

The vulnerable code snippet concatenates user-provided input directly into an SQL statement, making it susceptible to malicious SQL injection attacks.

Aswin KV, on infosecwriteups.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The code uses string formatting to insert user input into an SQL statement instead of using parameterised queries.

Impact

An attacker could inject SQL to read or alter data in the database, though the text does not demonstrate a specific exploit.

What the attacker needed

Access to the search endpoint

The fix

The code should be fixed by using prepared statements with placeholders, as shown in the secure version.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

SQL injection is when a program builds a database command by gluing user input straight into the command text. An attacker can type special characters that change the command's meaning, like adding extra instructions. Here, the search box input is placed directly into the database query without any separation.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

More by Aswin KV

View all

10 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.