mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Added input sanitization for backup path
- We need to limit the allowed filename accepted by the method to avoid opening up path traversal attack
This commit is contained in:
parent
d5c61c7eea
commit
70cf2b2c86
1 changed files with 3 additions and 2 deletions
|
@ -18,8 +18,9 @@ writeExportFile = function writeExportFile(exportResult) {
|
|||
};
|
||||
|
||||
const readBackup = async (filename) => {
|
||||
// TODO: prevent from directory traversal - need to sanitize the filename probably on validation layer
|
||||
var backupPath = path.resolve(urlUtils.urlJoin(config.get('paths').contentPath, 'data', filename));
|
||||
const parsedFileName = path.parse(filename);
|
||||
const sanitized = `${parsedFileName.name}${parsedFileName.ext}`;
|
||||
const backupPath = path.resolve(urlUtils.urlJoin(config.get('paths').contentPath, 'data', sanitized));
|
||||
|
||||
const exists = await fs.pathExists(backupPath);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue