Skip to content

Commit 31dca47

Browse files
authored
Merge pull request #521 from ShaneIsrael/main
Sync main / develop
2 parents 9b92500 + b769156 commit 31dca47

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

app/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fireshare",
3-
"version": "1.5.2",
3+
"version": "1.5.3",
44
"private": true,
55
"dependencies": {
66
"@emotion/react": "^11.9.0",

app/server/fireshare/api.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,9 @@ def public_upload_videoChunked():
15191519
blob = request.files.get('blob')
15201520
chunkPart = int(request.form.get('chunkPart'))
15211521
totalChunks = int(request.form.get('totalChunks'))
1522-
checkSum = request.form.get('checkSum')
1522+
checkSum = re.sub(r'[^a-zA-Z0-9_-]', '', request.form.get('checkSum'))
1523+
if not checkSum:
1524+
return Response(status=400)
15231525
if not blob.filename or blob.filename.strip() == '' or blob.filename == 'blob':
15241526
return Response(status=400)
15251527
filename = secure_filename(blob.filename)
@@ -1528,11 +1530,14 @@ def public_upload_videoChunked():
15281530
filetype = filename.split('.')[-1] # TODO, probe filetype with fmpeg instead and remux to supporrted
15291531
if not filetype in SUPPORTED_FILE_TYPES:
15301532
return Response(status=400)
1531-
1533+
15321534
upload_directory = paths['video'] / upload_folder
15331535
if not os.path.exists(upload_directory):
1534-
os.makedirs(upload_directory)
1536+
os.makedirs(upload_directory)
15351537
tempPath = os.path.join(upload_directory, f"{checkSum}.{filetype}")
1538+
# Guard against path traversal: ensure the resolved path stays within upload_directory
1539+
if not os.path.realpath(tempPath).startswith(os.path.realpath(upload_directory) + os.sep):
1540+
return Response(status=400)
15361541
with open(tempPath, 'ab') as f:
15371542
f.write(blob.read())
15381543
if chunkPart < totalChunks:

0 commit comments

Comments
 (0)