-
-
Notifications
You must be signed in to change notification settings - Fork 625
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(security): sanitize timezone parameter value to prevent code inje…
…ction (#2608) * fix(security): sanitize timezone parameter value to prevent code injection. Discovered by zhaoyudi (Nebulalab)
- Loading branch information
Showing
4 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
test/esm/unit/parsers/timezone-binary-sanitization.test.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { describe, test, assert } from 'poku'; | ||
import { createConnection, describeOptions } from '../../../common.test.cjs'; | ||
|
||
const connection = createConnection().promise(); | ||
|
||
describe('Binary Parser: timezone Sanitization', describeOptions); | ||
|
||
Promise.all([ | ||
test(async () => { | ||
process.env.TEST_ENV_VALUE = 'secure'; | ||
await connection.execute({ | ||
sql: 'SELECT NOW()', | ||
timezone: `'); process.env.TEST_ENV_VALUE = "not so much"; //`, | ||
}); | ||
|
||
assert.strictEqual( | ||
process.env.TEST_ENV_VALUE, | ||
'secure', | ||
'Timezone sanitization failed - code injection possible', | ||
); | ||
}), | ||
]).then(async () => { | ||
await connection.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { describe, test, assert } from 'poku'; | ||
import { createConnection, describeOptions } from '../../../common.test.cjs'; | ||
|
||
const connection = createConnection().promise(); | ||
|
||
describe('Text Parser: timezone Sanitization', describeOptions); | ||
|
||
Promise.all([ | ||
test(async () => { | ||
process.env.TEST_ENV_VALUE = 'secure'; | ||
await connection.query({ | ||
sql: 'SELECT NOW()', | ||
timezone: `'); process.env.TEST_ENV_VALUE = "not so much"; //`, | ||
}); | ||
|
||
assert.strictEqual( | ||
process.env.TEST_ENV_VALUE, | ||
'secure', | ||
'Timezone sanitization failed - code injection possible', | ||
); | ||
}), | ||
]).then(async () => { | ||
await connection.end(); | ||
}); |