You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/node/src/sql-injection.test.ts
+15Lines changed: 15 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -105,6 +105,21 @@ for (const dialect of DIALECTS) {
105
105
awaitctx.db.executeQuery(query)
106
106
awaitassertDidNotDropTable(ctx,'person')
107
107
})
108
+
109
+
it('should not allow SQL injection via backslash escape in string literals',async()=>{
110
+
constinjection=`\\'; drop table ${identifierWrapper}person${identifierWrapper}; -- `
111
+
112
+
constquery=ctx.db
113
+
.selectFrom('person')
114
+
.where('first_name','=',sql.lit(injection))
115
+
.selectAll()
116
+
117
+
expect(query.compile().sql).to.equal(
118
+
`select * from ${identifierWrapper}person${identifierWrapper} where ${identifierWrapper}first_name${identifierWrapper} = '\\\\''; drop table ${identifierWrapper}person${identifierWrapper}; -- '`,
0 commit comments