Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

## 2024-05-19 - SQL Injection in PRAGMA table_info
**Vulnerability:** SQL injection via unparameterized string concatenation in PRAGMA table_info queries.
**Learning:** SQLite's PRAGMA statements cannot be directly parameterized. However, modern SQLite provides table-valued functions like `pragma_table_info(?)` which allow for safe parameterized queries. The "notnull" column must be quoted since it's a reserved keyword.
**Prevention:** Always use table-valued functions (`pragma_*()`) instead of PRAGMA statements when checking schema metadata to ensure user input can be safely parameterized.
2 changes: 1 addition & 1 deletion internal/storage/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ LIMIT 1;
}

func sqliteColumnExists(ctx context.Context, db *sql.DB, table, column string) (bool, error) {
cols, err := db.QueryContext(ctx, fmt.Sprintf("PRAGMA table_info(%s);", table))
cols, err := db.QueryContext(ctx, "SELECT cid, name, type, \"notnull\", dflt_value, pk FROM pragma_table_info(?);", table)
if err != nil {
return false, err
}
Expand Down
Loading