-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -661,7 +661,7 @@ function startServer() { | |
|
||
// Rec_test_2024_08_03_16_17_01.webm | ||
|
||
if (!isValidRecFileNameFormat(fileName)) { | ||
if (!fileName.startsWith('Rec_') && !fileName.endsWith('.webm')) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
realArcherL
|
||
log.warn('[RecSync] - Invalid file name', fileName); | ||
return res.status(400).send('Invalid file name'); | ||
} | ||
|
@@ -2960,12 +2960,4 @@ function startServer() { | |
} | ||
} | ||
} | ||
|
||
// Utils... | ||
|
||
function isValidRecFileNameFormat(input) { | ||
const pattern = | ||
/^Rec_(?:[A-Za-z0-9-_]+|[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})_\d{4}_\d{2}_\d{2}_\d{2}_\d{2}_\d{2}\.(webm)$/; | ||
return pattern.test(input); | ||
} | ||
} |
I think this would still leave room for errors. I think we should filter out the special symbols as well. Allow, only "_" and remove everything else.
I worked on a quick fix for CVE-2024-39918 . Maybe using something like a function which the author used in their file here: https://github.com/jasonraimondi/url-to-png/blob/main/src/lib/utils.ts#L17C1-L26C2
Or methods suggested in this article: https://www.stackhawk.com/blog/node-js-path-traversal-guide-examples-and-prevention/