Skip to content

Commit 8230fbf

Browse files
committed
fix(daytona): reject oversized base64 uploads before decoding
1 parent 7e40d68 commit 8230fbf

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

  • apps/sim/app/api/tools/daytona/upload

apps/sim/app/api/tools/daytona/upload/route.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ export const POST = withRouteHandler(async (request: NextRequest) => {
6464
fileName = params.fileName || userFile.name
6565
} else if (params.fileContent) {
6666
logger.info(`[${requestId}] Using legacy base64 content input`)
67+
const estimatedSize = Math.floor((params.fileContent.length * 3) / 4)
68+
if (estimatedSize > MAX_UPLOAD_SIZE_BYTES) {
69+
const sizeMB = (estimatedSize / (1024 * 1024)).toFixed(2)
70+
return NextResponse.json(
71+
{ success: false, error: `File size (${sizeMB}MB) exceeds upload limit of 100MB` },
72+
{ status: 400 }
73+
)
74+
}
6775
fileBuffer = Buffer.from(params.fileContent, 'base64')
6876
fileName = params.fileName || 'file'
6977
} else {

0 commit comments

Comments
 (0)