下载自定义文件格式
我的任务是允许用户将文件上传到网页,然后其他用户可以下载该文件。
文件格式是自定义格式,在本例中我将其命名为 .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 theexe
equivalent of an SQL injection.
Thanks for all answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在服务器上,您可以对它们运行任何命令行病毒扫描程序,并让它们查找已知的病毒签名。然而,这是否会提高安全性是值得怀疑的:因为病毒编写者需要定制你的格式,所以他们的恶意文件似乎不太可能与任何已知的签名相匹配,其次你有误报的风险,导致其他情况有效上传将被拒绝。
您需要使客户端应用程序对文件格式的处理尽可能安全。这意味着:
您永远无法 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:
You can never be 100% sure that your code is secure. So better take some precautions:
以尽可能少的权限运行您的自定义软件。如果有人上传损坏的文件,这可以确保即使他们获得了对您的软件的控制权,也无法损害其他任何东西。
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.