Skip to content

Commit

Permalink
Limit upload size to 5GB
Browse files Browse the repository at this point in the history
AWS has a limit of 5GB uploads for single-part uploads, which is the
reason 5GB was selected here.

This does not necessarily prevent the risk of a DOS but it does require
a user to start multiple simultaneous uploads.

Issue #145 A user could create a DOS by uploading files that are too
large
  • Loading branch information
slifty committed Aug 3, 2023
1 parent bacbfda commit 860daf7
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/classes/SftpSessionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,24 @@ export class SftpSessionHandler {
this.sftpConnection.status(reqId, SFTP_STATUS_CODE.FAILURE);
return;
}

if (offset + data.length > 5368709120) { // 5 GB
logger.verbose(
'Response: Status (FAILURE)',
{
reqId,
code: SFTP_STATUS_CODE.FAILURE,
path: temporaryFile.virtualPath,
},
);
this.sftpConnection.status(
reqId,
SFTP_STATUS_CODE.FAILURE,
'You cannot upload files larger then 5 GB.',
);
return;
}

fs.write(
temporaryFile.fd,
data,
Expand Down

0 comments on commit 860daf7

Please sign in to comment.