当您添加公开的图像上传表单时,如何保护您的 Web 应用程序?

发布于 2024-12-23 18:40:32 字数 317 浏览 5 评论 0原文

我正在使用一个用 aspnet mvc 编写的小型 Web 应用程序(在 .NET 4 上运行)。该网站向公众开放,我们允许任何人上传图像(jpg/gif/png)。

目前,我正在执行看似最低安全性的操作,例如在上传步骤中进行检查

  1. ,确保文件以 .jpg/.gif/ 结尾.png
  2. 验证为传入文件列出的实际内容类型是“图像”,
  3. 使用基于参数的 SQL

以(希望)避免基本的 SQL 注入,但我忍不住觉得我缺少防止漏洞利用的基础知识: )

您可以提出的任何可能有助于减少公开图片上传的风险会很大!

I'm working with a small web app written in aspnet mvc (running on .NET 4). This site is open to the public and we allow anyone to upload an image (jpg/gif/png)

Currently I'm doing what appears to be minimal security like checking during the upload step

  1. ensure the file ends with .jpg/.gif/.png
  2. verify the actual content type listed for the file coming in is 'image'
  3. using param based SQL to (hopefully) avoid basic SQL injection

But I can't help but feel like I'm missing the basics that would prevent an exploit :)

Anything you can suggest that might help reduce risk for a public image upload would be great!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美人骨 2024-12-30 18:40:32

请注意,存在许多基于图像的漏洞,几乎所有这些漏洞都针对较差的图像编解码器实现。 除非您能够在 沙盒环境将提供损坏的图像,几乎或根本没有机会损坏您的系统上的任何内容。

Note that there are many image-based exploits out there, almost all of them targeting poor image codec implementations. You cannot reasonably prevent image exploits from being uploaded unless you're able to re-encode the images in an sandbox environment that will provide a corrupted image little or no opportunity to damage anything on your system.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文