Skip to content

Commit 80522df

Browse files
committed
fix(scratchpad): vulnerable to sql injection
1 parent 979712a commit 80522df

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/plugins/scratchpad/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { renderPage } from '../../layoutManager.js';
99
const queries = {
1010
select: (roomId: string) =>
1111
`SELECT message FROM Scratchpad WHERE roomId='${roomId}'`,
12-
upsert: (roomId: string, message: string) =>
13-
`INSERT OR REPLACE INTO Scratchpad (roomId, message) VALUES ('${roomId}', '${message}')`,
12+
upsert:
13+
'INSERT OR REPLACE INTO Scratchpad (roomId, message) VALUES (?, ?)',
1414
};
1515

1616
const scratchpadRedirect: MiddlewarePlugin<'scratchpad'> = async ({ res }) => {
@@ -52,7 +52,7 @@ const onScratchpadConnection: WebsocketPlugin<'scratchpad'> = async ({
5252
socket.on('scratchpad', async (message, roomId) => {
5353
if (!roomId) return;
5454
socket.to(roomId).emit('scratchpad', message, socket.id);
55-
await db?.exec(queries.upsert(roomId, message));
55+
await db?.exec(queries.upsert, roomId, message);
5656
});
5757
};
5858

0 commit comments

Comments
 (0)