Skip to content

[BUG] Actual uploaded file size is not validated before ingestion #333

Description

@Yehor-Makarenko

[BUG] Actual uploaded file size is not validated before ingestion
Summary
The 500 MiB file-size limit can be bypassed by sending an incorrect fileBytes value when creating a document. After uploading a file whose actual size exceeds the limit, the ingestion endpoint accepts it with 200 OK.
The backend appears to trust client-provided metadata without verifying the actual S3 object size.
Test data used: https://drive.google.com/file/d/1-6D_yIDToffrz07RUpEkEwISAuJ0Aq-4/view?usp=drive_link

Steps to reproduce

Sign in with a valid user account.
Prepare a valid PDF with an actual size of 524,298,486 bytes (500.01 MiB).
Send POST /api/v1/documents but specify a smaller fileBytes value:
{
"title": "pdf over 500 mb",
"presetId": 1,
"fileName": "invalid-pdf-500.01-MiB.pdf",
"fileBytes": 52429848
}
Note the created document ID and presigned upload URL.
Upload the actual 524,298,486-byte PDF through the presigned URL.
Wait until the S3 PUT request completes successfully.
Send:
POST http://98.90.162.1/api/v1/documents/139/ingest
Content-Type: application/json
{file}
Observe the response.
Expected result
The system verifies the actual uploaded object size instead of relying only on the client-provided fileBytes.
A file larger than 524,288,000 bytes (500 MiB) is rejected either during upload or before ingestion. The ingestion endpoint returns a controlled 4xx response, preferably 413 Content Too Large, and no pages are created.

Actual result
The ingestion endpoint accepts the oversized PDF:
Status: 200 OK
Response: null
The actual file is 524,298,486 bytes, even though the document creation request declared only 52,429,848 bytes.

Environment
Application: http://98.90.162.1/
API: http://98.90.162.1/api/v1
Document ID: 139
Declared size: 52,429,848 bytes
Actual size: 524,298,486 bytes (500.01 MiB)
OS: macOS 26.5.1 (25F80)

Severity / priority
High / High

Screenshots or logs
POST /api/v1/documents
{
"title": "pdf over 500 mb",
"presetId": 1,
"fileName": "invalid-pdf-500.01-MiB.pdf",
"fileBytes": 52429848
}

PUT
Uploaded file size: 524,298,486 bytes
Status: Successful

POST /api/v1/documents/139/ingest
Payload: {}
Status: 200 OK
Response: null

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

backendBackend applicationbugSomething isn't working

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions