Is There a Virus That Prevents Uploads
Does your website allow users to upload files? Learn secure file upload best practices and prevent unsafe vulnerabilities and attacks.
Almost every web application accepts user input, and one of the nigh common types of input is in the form of file uploads. Whether it'southward a consumer application where users are uploading photos, or a concern application that accepts pdfs and discussion documents, file uploads are an essential characteristic. However, they also open up up the site to a host of potential risks and vulnerabilities.
Exploited past a hacker, a file upload vulnerability tin can open a site to malware, unauthorized server access, attacks to website visitors, the hosting of illegal files, and much more.
Table of Contents
- Types of file upload attacks
- Important questions to ask
- How to secure file uploads
- Option one: How to use a third party
- Option 2: DIY secure file upload
- How to secure file uploads yourself
- Attack prevention tips
Types of file upload attacks
File upload attacks tin can exist grouped into 4 categories. When creating a system that accepts files from users, information technology's important to evaluate the risks associated with each category and add together security checks to defend confronting them:
- File metadata attacks – The path and file name can trick an application into copying the file to an unexpected location that could overwrite an important file and crusade unexpected behavior. For example, an attacker could utilise control characters in the filename to trick the system into overwriting an important configuration file.
- File size attacks – An unexpectedly big file can cause an application to overload or fail. For example, an attacker could employ a botnet to trigger the simultaneous uploads of very large (or very small-scale!) files that result in legitimate requests non being fulfilled.
- File content attacks – The content of the file tin be utilise to manipulate the behavior of the awarding. The outcome of this assault depends entirely on how the file is used and candy. For case, uploaded and executed malware could be used to reveal a central that gives an attacker access to the arrangement.
- File access attacks – The access rules effectually uploaded files tin be misconfigured, resulting in unauthorized. For example, a misconfigured AWS S3 configuration could consequence in private user photos existence accessible to the public.
To go a more detailed wait into the types of attacks that are possible, this talk by Yahoo security researcher Ebrahim Hegazy goes over 15 common scenarios in exploiting file upload pages:
Important questions to ask yourself
At present y'all that you know what attacks you are up against, information technology's time to start asking questions about your organization. Go through the post-obit checklist of questions to place potential vulnerabilities and prevent malicious uploaders from exploiting your organisation. The answers will give y'all insight into the risks that you are currently facing and assistance you determine the cost of a projection to secure whatsoever existing vulnerabilities.
- Which users should have the ability to upload a file?
- Which users should have the power to read the file?
- Is the file displayed anywhere, and if so, where?
- What kind of files tin can be uploaded?
- How is the metadata (file proper name and path) processed past the application?
- Is the file or whatever part of the file executed, and if so, where?
- What tertiary party libraries interact with the file?
How to secure your file uploads
Afterward you've answered the in a higher place questions for your arrangement, or if you lot are dealing with a project where you are developing a file upload feature from the ground up, there are technical decisions to make. Mainly, deciding whether it is ameliorate to employ an off-the-shelf system to secure file uploads, or build information technology in-business firm.
Option 1: Apply a 3rd party system
Using an off-the-shelf file upload system can be a fast way to achieve highly secure file uploads with minimal endeavor. If in that location are no special storage requirements or legacy systems to migrate, this choice can be a great style for organizations to support file uploads by users. Especially if development resource are constrained.
These services unremarkably offer enterprise-grade security with features such equally antivirus scanning, user access controls, and well-documented and updated libraries in many common languages. Creating a secure file upload system using a tertiary party is equally easy as integrating their JavaScript library into the application'south frontend, then using the backend libraries to access the files as necessary by the system.
In that location are many services on the marketplace that are bachelor for developers. The most popular include:
Filestack – Previously Filepicker.io, Filestack was/is one of the first popular file uploading services. Since and so, they've added advanced enterprise-level features while still maintaining an accessible free program.
Transloadit – Transloadit offers an open-source uploader widget that can optionally pair with their paid file hosting and processing services.
Cloudinary – Specializing in publishers where uploaded content mostly comes from within the organization, Cloudinary offers an image and video upload service that specializes in advanced transformations.
Uploadcare – A more affordable upstart that provides uploads, media processing, and adaptive commitment for spider web and mobile.
Tertiary party security considerations
Because a third party is treatment the upload, storage, and commitment, the security risks are significantly reduced. Files are no longer saved on your system's infrastructure and this reduces the chances of a organisation-wide vulnerability. All the same, admission control to the files and how the files are candy by the organisation after the upload are still potential risks that must exist assessed.
When making the determination to use a third party, at that place are a couple of import considerations:
Pros of using 3rd party file upload
- Accomplish a high level of security that is constantly being improved and updated to reflect the latest best practices
- Reduce monetary and fourth dimension costs to maintain a system by using a tertiary party that specializes in file uploads
- Increased scalability working with a specialist that powers file uploading for
Cons of using 3rd party file upload
- Less command as you lot practise not have direct admission to the infrastructure behind file storage
- Cannot be used for information that must be on-bounds
- Upwardly front toll to switch to a third party if there is an existing legacy file upload system
Option 2: DIY secure file upload
The other option is to handle file uploads in-house and build protections against the near common vulnerabilities. Choosing an in-house solution is a good pick for organizations that take special requirements for their information that foreclose third-party vendors from being used (for case, highly sensitive documents). An in-house solution is also a practiced option if the file upload system is part of a larger legacy arrangement that would result in a prohibitively expensive migration.
Pros of DIY File Uploads
- More command and extensibility for custom workflows
- Can be used for on-premises information
Cons of DIY File Uploads
- Security must be constantly updated to reflect new best practices
- More expensive to maintain as it requires in-firm expertise
- Harder to scale out since infrastructure needs to exist put together from scratch
How to secure file uploads yourself
If you do determine to implement the security yourself, these recommendations will help yous avoid the 4 types of file upload attacks that were mentioned above:
- Use a whitelist of allowed file types
- Note: Conversely, blacklisting file extensions is not recommended as there are many means that this weak protection method can be bypassed.
- Verify file type against the whitelist earlier upload
- Utilize input validation to prevent the whitelist from beingness bypassed using the filename
- Use input validation to preclude the metadata from existence exploited. For example, remove any unnecessary metadata such as exif data from images and remove command characters from filenames and extensions.
- Remove any unnecessary file evaluation
- Limit the size of the filename
- Limit the size of the file (unexpectedly small files and large files can both be used in denial of service attacks)
- Limit the directory to which files are uploaded
- Browse all files with antivirus software (nigh commonly ClamAV, an open-source AV engine, or using an API such equally AttachmentScanner )
- Proper name the files randomly or using a hash instead of by the user'southward input. This will prevent an attacker from scripting access to uploaded files using the file's name as an assault vector.
- Simplify error messages. Remove any directory paths and server configurations from mistake messages that attackers could employ.
- Cheque the uploaded directory to brand sure the read/write/execute user permissions are correct.
Additional attack prevention tips
The tips above cover the basics when it comes to keeping file uploads condom. However, when developing an application that requires high-security, it can be worth building in additional protection. The following recommendations go over more advanced techniques for applications that crave enterprise-form security.
- Use a Captcha to foreclose uploads from bots and scripts
- Remove threats that are embedded in documents such as PDFs and DOCX files using content disarm and reconstruction techniques
- Protect yourself from Cross Site Asking Forgery attacks using these CSRF security methods
- Use Mail methods instead of PUT. Read more about HTTP method exploits here .
- Log user activities, and protect the logging machinery from code injection and log forgery
- When decompressing files, cheque all uncompressed files individually in the aforementioned fashion that all files are checked
- Audit write admission to key configuration files such as ".htaccess" or "web.config" to brand sure that the file uploading system cannot access them
- Defend against Flash or PDF-based cross-site content-hijacking by adding the "Content-Disposition: Zipper" and "X-Content-Type-Options: nosniffrest" headers
- Disable browser caching for clientaccesspolicy.xml and corssdomain.xml files in order to be able to chop-chop restrict access to sure web services without having to look for clients' caches to invalidate.
- Validate CORS headers to ensure that they are only enabled for publicly accessible data. All other data should return CORS headers that merely take authorized URLs. Only use "Access-Control-Allow-Credentials" when necessary, and the "Admission-Control-Let-Headers" and "Access-Control-Allow-Methods" headers should be reviewed as well.
Creating a secure file upload arrangement tin exist challenging fifty-fifty without having to think of security. All the same, investments made in creating a secure organisation prevent plush security breaches that tin can accept a meaning impact on an organisation's reputation and bottom line. As a developer, it'due south important to identify cost-effective means to handle file upload security and evaluate the tradeoffs between an in-house and 3rd-party solution. If you are interested in exploring the benefits of using a 3rd-party, call us today at 1-888-415-1885 or:
Contact Sales
Read More than →
Source: https://blog.filestack.com/thoughts-and-knowledge/secure-file-upload/
Postar um comentário for "Is There a Virus That Prevents Uploads"