# SQL Injection (CWE-89) User input is concatenated directly into SQL queries, allowing attackers to modify the query logic and access or manipulate data. This is one of the oldest and most dangerous vulnerability classes, responsible for some of the largest data breaches in history. **Stack:** Go - Prevalence: Very Common OWASP Top 10 since 2010 - Impact: Critical Data breach, auth bypass, RCE - Prevention: Well understood Parameterized queries **OWASP:** Injection (A03:2021-Injection) - #3 ## Description Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data. This can be used to alter query logic to bypass security checks, or to insert additional statements that modify the back-end database. ## Prevention 基于 1 条 Shoulder 检测规则的 SQL Injection 预防策略。 ### Go Use parameterized queries with $1 (PostgreSQL) or ? (MySQL/SQLite) placeholders ## Warning Signs - [CRITICAL] user input flowing to SQL queries without parameterization ## Consequences - 读取应用程序数据 - 修改应用程序数据 - 绕过保护机制 - 执行未授权命令 ## Mitigations - 使用参数化查询或预处理语句 - 对存储过程使用参数化查询 - 使用数据库专用的转义函数对所有用户输入进行转义 ## Detection - Total rules: 7 - Critical: 6 - Languages: go, javascript, typescript, python ## Rules by Language ### Go (1 rules) - **SQL Injection via Database Queries** [CRITICAL]: Detects user input flowing to SQL queries without parameterization. - Remediation: Use parameterized queries with placeholders instead of string concatenation. ```go rows, err := db.Query("SELECT * FROM users WHERE id = $1", userID) ``` Learn more: https://shoulder.dev/learn/go/cwe-89/sql-injection