Skip to content

feat: add file size limits and magic bytes validation for CDN upload#921

Open
frankosakwe wants to merge 8 commits into
rinafcode:mainfrom
frankosakwe:feature/file-validation-magic-bytes
Open

feat: add file size limits and magic bytes validation for CDN upload#921
frankosakwe wants to merge 8 commits into
rinafcode:mainfrom
frankosakwe:feature/file-validation-magic-bytes

Conversation

@frankosakwe

Copy link
Copy Markdown
  • Add file-type package dependency for magic bytes detection
  • Create CDN controller with upload endpoint
  • Implement file size validation (10MB images, 500MB videos)
  • Implement magic bytes validation to detect MIME type mismatches
  • Update media-processing.worker.ts with validation
  • Add comprehensive unit tests for size limits and MIME validation
  • Update file size limits to match specifications

Security improvements:

  • Reject files exceeding size limits with 413 error
  • Reject files with wrong magic bytes with 415 error
  • Prevent PHP scripts disguised as video files
  • Validate declared MIME type against actual file content

closes #850

- Add file-type package dependency for magic bytes detection
- Create CDN controller with upload endpoint
- Implement file size validation (10MB images, 500MB videos)
- Implement magic bytes validation to detect MIME type mismatches
- Update media-processing.worker.ts with validation
- Add comprehensive unit tests for size limits and MIME validation
- Update file size limits to match specifications

Security improvements:
- Reject files exceeding size limits with 413 error
- Reject files with wrong magic bytes with 415 error
- Prevent PHP scripts disguised as video files
- Validate declared MIME type against actual file content
@drips-wave

drips-wave Bot commented Jun 28, 2026

Copy link
Copy Markdown

@frankosakwe Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Great work on this PR
I really appreciate the effort you put into this—everything
kindly fix your workflow

- Remove trailing spaces in test files
- Remove unused import in cdn.controller.ts
- Fix parameter formatting in uploadContent method
- Break long line in getMaxSizeForType for readability
- Format imports in media-processing.worker.spec.ts
@frankosakwe

Copy link
Copy Markdown
Author

done you can pls check

@frankosakwe

Copy link
Copy Markdown
Author

can you help me check pls

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

There is conflict

@frankosakwe

Copy link
Copy Markdown
Author
Screenshot 2026-06-29 170429 Screenshot 2026-06-29 170612 this is what it shows me when i try to resolve the issue

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

You cant resolve with Github because it is too complex, use your editor to resolve the conflict.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add content-length validation and file type enforcement for media uploads

2 participants