mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2026-09-03 20:53:09 -05:00
Check zip entry filename validity
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { createWriteStream } from 'fs'
|
||||
import { ensureDir } from 'fs-extra/esm'
|
||||
import { dirname, join } from 'path'
|
||||
import { dirname, isAbsolute, join, relative } from 'path'
|
||||
import { pipeline } from 'stream'
|
||||
import * as yauzl from 'yauzl'
|
||||
import { logger, loggerTagsFactory } from './logger.js'
|
||||
@@ -45,6 +45,11 @@ export async function unzip (options: {
|
||||
}
|
||||
|
||||
const entryPath = join(destination, entry.fileName)
|
||||
const rel = relative(destination, entryPath)
|
||||
if (rel.startsWith('..') || isAbsolute(rel)) {
|
||||
zipFile.close()
|
||||
return rej(new Error('Unsafe zip entry'))
|
||||
}
|
||||
|
||||
try {
|
||||
if (entry.fileName.endsWith('/')) {
|
||||
|
||||
Reference in New Issue
Block a user