我希望防止我的应用程序受到resource consumption类型的resource consumption攻击。这意味着攻击者可以通过将大型文件上载到服务器来占用服务器资源,如内存和磁盘容量。
我想知道是否可能检查传入文件的元数据,如大小和取消上传一旦达到一个限制。否则,攻击者可能会将20 GB文件上载到服务器,如果服务器等待上载完成以完成验证,那么甚至在上传完成之前,我的服务器就可能会被这样大的文件淹没。
我想知道如何用Java实现这一点。我正在使用Apache/coyote 1.1。
更新:
我在PHP中找到了如下解决方案。
post_max_size integer
Sets max size of post data allowed. This setting also affects file upload.
To upload large files, this value must be larger than upload_max_filesize.
If memory limit is enabled by your configure script, memory_limit also
affects file uploading. Generally speaking, memory_limit should be larger
than post_max_size. When an integer is used, the value is measured in bytes.
Shorthand notation, as described in this FAQ, may also be used. If the size
of post data is greater than post_max_size, the $_POST and $_FILES
superglobals are empty [...]
max_file_uploads integer
The maximum number of files allowed to be uploaded simultaneously. Starting
with PHP 5.3.4, upload fields left blank on submission do not count towards
this limit.在Java中有什么替代品可以替代吗?
发布于 2015-03-12 06:18:19
我们可以通过以下方法来测量上传文件的大小,
因为可以调整/破解#1实现。依赖于#2是很好的。MultipartConfig有能力在达到限制时中断文件上传(低于#2)。
注意:
发布于 2015-03-11 08:03:32
https://www.netroby.com/view.php?id=3585,看看您是否可以限制文件上传的大小。
https://stackoverflow.com/questions/28980944
复制相似问题