Commit 457584d
🛡️ Sentinel: [CRITICAL] Fix SQL injection in metadata generation
Identified and resolved a critical SQL injection vulnerability in `metadata_generator.py`.
The `save_file_metadata` method was using user-provided metadata keys directly as column names in a dynamic `INSERT OR REPLACE INTO file_metadata` query.
Since parameterization (`?`) only works for values, not identifiers like column names, an attacker supplying crafted dictionary keys could execute arbitrary SQL commands.
Fixed by querying `PRAGMA table_info` to fetch the actual safe schema and filtering the input metadata dictionary against this whitelist.
Co-authored-by: thebearwithabite <216692431+thebearwithabite@users.noreply.github.com>1 parent 613e4ba commit 457584d
2 files changed
Lines changed: 24 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
467 | 467 | | |
468 | 468 | | |
469 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
470 | 481 | | |
471 | | - | |
472 | | - | |
| 482 | + | |
| 483 | + | |
473 | 484 | | |
474 | 485 | | |
475 | 486 | | |
| |||
0 commit comments