Skip to content

Commit 6af60fa

Browse files
committed
fix: prevent SQL injection in timezone handling
Apply timezone validation before executing SET TIME ZONE command to prevent potential SQL injection vulnerabilities. Changes: - Import and use isValidTimeZone() validation - Throw error for invalid timezone strings - Maintain support for all legitimate timezone formats The validation ensures that only safe timezone strings are used in raw SQL execution while preserving functionality.
1 parent 0ff6d94 commit 6af60fa

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/PrismaQueue.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
escape,
1212
getCurrentTimeZone,
1313
getTableName,
14+
isValidTimeZone,
1415
serializeError,
1516
uncapitalize,
1617
waitFor,
@@ -320,6 +321,10 @@ export class PrismaQueue<
320321
await client.$queryRawUnsafe<[{ TimeZone: string }]>("SHOW TIME ZONE");
321322
const localTimeZone = getCurrentTimeZone();
322323
if (dbTimeZone !== localTimeZone) {
324+
// Validate timezone to prevent SQL injection
325+
if (!isValidTimeZone(localTimeZone)) {
326+
throw new Error(`Invalid timezone: ${localTimeZone}`);
327+
}
323328
debug(`aligning database timezone from ${dbTimeZone} to ${localTimeZone}!`);
324329
await client.$executeRawUnsafe(`SET LOCAL TIME ZONE '${localTimeZone}';`);
325330
}

0 commit comments

Comments
 (0)