下载自定义文件格式

发布于 2024-11-02 09:04:44 字数 475 浏览 1 评论 0原文

我的任务是允许用户将文件上传到网页,然后其他用户可以下载该文件。

文件格式是自定义格式,在本例中我将其命名为 .ccx。这是由我们自己定制的软件打开的。这个想法是,用户可以上传教程文件以相互共享。

但是,我担心有人可能会设计 .ccx 文件以在用户计算机上植入病毒。如果设计了这样的文件,这可能会对我们的网站产生非常负面的影响,用户会害怕下载,而我们的竞争对手可能会利用它来利用我们。

  • 作为网络开发人员,我如何确保上传的文件安全?我知道不可能 100% 确定,但我想改进目前“非常不确定”的情况。

  • 此外,在我们的定制软件中,可以采取哪些步骤来确保 .ccx 文件不会对用户计算机(用 C++ 编写的 Windows 程序)造成损害?我说的是相当于 SQL 注入的 exe

感谢您的所有回答。

I've been tasked with allowing users to upload files to a webpage, and then other users can download that file.

The file format is a custom one, for this example I'll just call it .ccx. This is opened by our own custom software. The idea is, users can upload tutorial files to share with each other.

However, I'm concerned that someone could engineer a .ccx file to implant a virus on the users computer. This could have a very negative impact on our site if ever such a file was engineered, users would become fearful of downloading, and our competitors might use that to take advantage of us.

  • How can I as a web developer make sure that uploaded files are safe? I know it's not possible to be 100% sure, but I want to improve on currently being 'very unsure'.

  • Also, in our custom software, what steps can be taken to ensure that the .ccx file wont cause harm to the users computer (A Windows program written in C++)? I'm talking about the exe equivalent of an SQL injection.

Thanks for all answers.

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

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

发布评论

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

评论(2

情话已封尘 2024-11-09 09:04:44

在服务器上,您可以对它们运行任何命令行病毒扫描程序,并让它们查找已知的病毒签名。然而,这是否会提高安全性是值得怀疑的:因为病毒编写者需要定制你的格式,所以他们的恶意文件似乎不太可能与任何已知的签名相匹配,其次你有误报的风险,导致其他情况有效上传将被拒绝。

您需要使客户端应用程序对文件格式的处理尽可能安全。这意味着:

  • 不要信任输入文件。验证一切。不要容错。如果您控制着写入此类文件的唯一应用程序,那么任何意外的字节都应该触发警钟。
  • 进行广泛的测试(例如某种模糊测试来模拟随机输入变化)
  • 设计尽可能简单的文件格式。如果文件格式很复杂,那么实现也会很复杂。实现越复杂,需要处理的格式特征越多,安全漏洞的风险就越高。
  • 确保使用操作系统安全功能,例如 DEP 或 ASLR。
  • 确保参与该项目的所有开发人员都了解常见的安全漏洞以及如何避免它们。
  • 如果您真的非常担心可能的攻击媒介,请尝试对加载代码进行沙箱处理。例如,这可以通过使用嵌入式脚本语言来实现。

您永远无法 100% 确定您的代码是安全的。因此,最好采取一些预防措施:

  • 实施自动更新,以便能够快速修补安全漏洞。
  • 警告用户不要打开来自不受信任的作者的文件(并告诉他们您对“受感染”文件造成的任何损害不承担责任......)。

On the server, you can run any command line virus scanner over them and have them look for known virus signatures. However, it is questionable whether this will improve security: since the virus writers would need to taylor your format, it doesn't seem very likely that their malicious files would match any known signatures, secondly you have the risks of false positives, causing otherwise valid uploads to be rejected.

You need to make your client app's handling of the file format as secure as possible. This means:

  • Do not trust the input files. Validate everything. Don't be fault tolerant. If you are in control of the only application that writes such files, then any unexpected byte should trigger alarm bells.
  • Do extensive testing (for example some kind of fuzzy testing to simulate random input changes)
  • Design your file format as simple as possible. If the file format is complex, the implementation will be, too. And the more complex the implementation, the more format features to handle, the higher the risk of security vulnerabilities becomes.
  • Make sure you use OS security features, such as DEP or ASLR.
  • Ensure that all developers working on the project know about common security vulnerabilities and how to avoid them.
  • If you are really, really worried about possible attack vectors, try sandboxing the loading code. This can, for example, be achieved by using an embedded scripting language.

You can never be 100% sure that your code is secure. So better take some precautions:

  • Implement automatic updates to be able to patch security holes quickly.
  • Warn users not to open files from untrusted authors (and tell them you're not liable for any damage caused by 'infected' files ...).
中二柚 2024-11-09 09:04:44

以尽可能少的权限运行您的自定义软件。如果有人上传损坏的文件,这可以确保即使他们获得了对您的软件的控制权,也无法损害其他任何东西。

Run your custom software with the smallest amount of privileges possible. If someone uploads a corrupt file, this ensures that even if they gain control over your software, they can't compromise anything else.

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