0

I am using below code for update but i need to prevent sql injection in this query.

const query1 = `UPDATE Table SET name='xyz' WHERE id=1`;
const saveEditPost = await sequelizeWrite.query(query1, { type: sequelizeWrite.QueryTypes.UPDATE });

How to prevent sql injection in the code using sequelize? i have used sequelize in my entire projects to change the package will be a challenge.

James Z
  • 12,209
  • 10
  • 24
  • 44
  • What the difference between Sequelize 7.x and previous versions in this aspect? You still can use `bind` or `replacements` options to achieve your goal. – Anatoly Jan 13 '23 at 19:43
  • @Anatoly make sure you update to the latest version because there was recently SQL injection on `replacements` https://www.redpacketsecurity.com/node-js-sequelize-module-sql-injection/ – prospector Jan 14 '23 at 06:49
  • 1
    @prospector the link says it would be sufficient to install 6.19.1 or later. – Anatoly Jan 14 '23 at 09:40

0 Answers0