Skip to content

Commit 580cec2

Browse files
authored
fix: prevent SQL injection in the NOTIFY payload (#1)
1 parent e2c8fe8 commit 580cec2

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/index.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,10 @@ export class PostgresAdapter extends Adapter {
422422
document.type,
423423
this.channel
424424
);
425-
await this.pool.query(`NOTIFY "${this.channel}", '${payload}'`);
425+
await this.pool.query(`SELECT pg_notify($1, $2)`, [
426+
this.channel,
427+
payload,
428+
]);
426429

427430
this.scheduleHeartbeat();
428431
} catch (err) {
@@ -448,7 +451,7 @@ export class PostgresAdapter extends Adapter {
448451
type: document.type,
449452
attachmentId,
450453
});
451-
this.pool.query(`NOTIFY "${this.channel}", '${headerPayload}'`);
454+
this.pool.query(`SELECT pg_notify($1, $2)`, [this.channel, headerPayload]);
452455
}
453456

454457
/**

0 commit comments

Comments
 (0)