Skip to content

Fix file upload security loopholes#14

Merged
nehabagdia merged 7 commits intomainfrom
fix/file_upload_security
Feb 29, 2024
Merged

Fix file upload security loopholes#14
nehabagdia merged 7 commits intomainfrom
fix/file_upload_security

Conversation

@gaya3-zipstack
Copy link
Copy Markdown
Contributor

What

While a file is uploaded to Prompt studio for indexing, file checks are missing and hence this can cause security issues.

Why

Security loopholes will enable attackers to upload malicious content and in turn cause various types of attacks on the Unstract system.

How

Prevented using the following types of checks

  • file extension check (only pdf supported)
  • file content type check (only pdf supported)
  • file size limitation check

Relevant Docs

Related Issues or PRs

Dependencies Versions / Env Variables

Notes on Testing

  • Uploading a file with wrong extension
  • Uploading file with right extension but wring content type
  • Uploading files with size greater than specification

Screenshots

...

Checklist

I have read and understood the Contribution Guidelines.

@gaya3-zipstack gaya3-zipstack marked this pull request as ready for review February 29, 2024 09:35
@nehabagdia nehabagdia merged commit e8df8ab into main Feb 29, 2024
@nehabagdia nehabagdia deleted the fix/file_upload_security branch February 29, 2024 09:44

from django.core.exceptions import ValidationError
from django.template.defaultfilters import filesizeformat
from django.utils.translation import gettext_lazy as _
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaya3-zipstack are these imports used? Did you run it against pre-commit


class FileUploadSerializer(serializers.Serializer):
file = serializers.ListField(child=serializers.FileField(), required=True)
file = serializers.ListField(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gaya3-zipstack will this impact file upload for workflows / API deployment as well? We'll have other file types to allow in that case

pk-zipstack pushed a commit that referenced this pull request Aug 20, 2025
* Add file upload validation

* Code formatting

* Code formatting

* Change values to constants
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.

4 participants