Django应用中如何防止csv注入

2024-06-14 03:05:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个Django应用程序与文件上传功能。我正在用Clamav扫描文件中的病毒。我想在我的应用程序中防止CSV注入。我发现这个stackoverflow链接与之相关,但没有任何帮助。请建议如何防止CSV注入我的Django应用程序与ClamAV。你知道吗


Tags: 文件csvdjango功能应用程序链接stackoverflow建议
1条回答
网友
1楼 · 发布于 2024-06-14 03:05:10

看看CSV注入的定义(这个链接可以在你的SO链接中找到) https://www.owasp.org/index.php/CSV_Injection

简而言之:

When a spreadsheet program such as Microsoft Excel or LibreOffice Calc is used to open a CSV, any cells starting with '=' will be interpreted by the software as a formula. Maliciously crafted formulas can be used for three key attacks:

您可以通过以下方法防止此攻击:

This attack is difficult to mitigate, and explicitly disallowed from quite a few bug bounty programs. To remediate it, ensure that no cells begin with any of the following characters:

Equals to ("=")
Plus ("+")
Minus ("-")
At ("@")

我不知道如何使用ClamAV,因为我不使用它, 但是您可以编写一个小python函数来读取文件,并确保没有任何单元格以上述任何字符开头。你知道吗

相关问题 更多 >