{keyword};select Pg_sleep(5)-- Here
: Use Modern Object-Relational Mappers (ORMs) like TypeORM or Sequelize , which use parameterized queries by default.
Likely the intended legitimate input for a search or filter feature. ; {KEYWORD};SELECT PG_SLEEP(5)--
: Strict allow-listing for expected formats (e.g., ensuring a "keyword" only contains alphanumeric characters). : Use Modern Object-Relational Mappers (ORMs) like TypeORM
// UNSAFE: Vulnerable to the injection provided const query = "SELECT * FROM articles WHERE topic = '" + userInput + "'"; // SAFE: Parameterized query const query = "SELECT * FROM articles WHERE topic = $1"; const values = [userInput]; db.query(query, values, (err, res) => { // The database treats $1 strictly as data, even if it contains "SELECT PG_SLEEP(5)" }); Use code with caution. Copied to clipboard const values = [userInput]