Skip to content

Commit 179313a

Browse files
Christian PaulHalf-Shot
Christian Paul
andauthored
Prevent low-risk SQL injection from roomId values when entered into the config (#1619)
* Prevent SQL injection from roomId values when checking room visibility * Add newsfile * Update newsfile * Update 1619.bugfix Co-authored-by: Will Hunt <[email protected]>
1 parent 8fdffdd commit 179313a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

changelog.d/1619.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Prevent possible attack by provisisioning a room with a specific roomID.

src/datastore/postgres/PgDataStore.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,9 @@ export class PgDataStore implements DataStore {
661661

662662
public async getRoomsVisibility(roomIds: string[]) {
663663
const map: {[roomId: string]: "public"|"private"} = {};
664-
const list = `('${roomIds.join("','")}')`;
665-
const res = await this.pgPool.query(`SELECT room_id, visibility FROM room_visibility WHERE room_id IN ${list}`);
664+
const res = await this.pgPool.query("SELECT room_id, visibility FROM room_visibility WHERE room_id IN $1", [
665+
roomIds,
666+
]);
666667
for (const row of res.rows) {
667668
map[row.room_id] = row.visibility ? "public" : "private";
668669
}

0 commit comments

Comments
 (0)