apache - ModSecurity:使用代码 403(第 2 阶段)拒绝访问。使用“multipart/form-data”时
问题描述
我正在尝试将图像上传到网络服务器。并收到错误:403。所以我检查了 Apache 日志,我在日志中有这个错误:
ModSecurity: Access denied with code 403 (phase 2). Match of "eq 0" against "MULTIPART_STRICT_ERROR" required. [file "/usr/local/cwaf/rules/13_HTTP_Protocol.conf"] [line "30"] [id "210240"] [rev "4"] [msg "COMODO WAF: Multipart request body failed strict validation: PE 0, BQ 1, BW 0, DB 0, DA 0, HF 0, LF 0, SM , IQ 0, IH 0, FLE 0||my_web_server.com|F|2"] [severity "CRITICAL"] [tag "CWAF"] [tag "Protocol"] [hostname "my_web_server.com"] [uri "/projects/BoLe/api/saveimage.php"] [unique_id "XDaxYXuIw@DonQukuLB6swAAAAs"]
根据这个网站,我的请求有MULTIPART_BOUNDARY_QUOTED
错误,我试图用谷歌搜索它,但我仍然不明白发生了什么。因此我曾经wireshark
检查过数据包
|%ÝrÜðÕ¿wëE%6@QÔ¬[ggféP3)¯W^P@)îù
POST /projects/BoLe/api/saveimage.php HTTP/1.1
Host: massmodules.com
Accept-Encoding: gzip, identity
Connection: Keep-Alive, TE
User-Agent: BestHTTP
Content-Type: multipart/form-data; boundary="8A317780"
Content-Length: 306
|%ÝrÜðÕ¿wëEZ%7@Q¬[ggféP3)°@^P@)õ`--8A317780
Content-Disposition: form-data; name="fileName"
Content-Type: text/plain; charset="utf-8"
Content-Length: 17
i_am_fileName.png
--8A317780
Content-Disposition: form-data; name="fileName2"
Content-Type: text/plain; charset="utf-8"
Content-Length: 18
i_am_fileName2.png
--8A317780--
有人可以帮我解决这个问题吗?
解决方案
触发错误的规则是这个:
BQ %{MULTIPART_BOUNDARY_QUOTED}, \
这在错误消息中可见:
PE 0, BQ 1, BW 0, DB 0, DA 0, HF 0, LF 0, SM , IQ 0, IH 0, FLE 0
⬆⬆⬆⬆
问题是您在内容类型标头中有引号
Content-Type: text/plain; charset="utf-8"
⬆ ⬆
推荐阅读
- javascript - Node JS 聊天服务器
- apache-spark - 丢弃不良记录并仅将良好记录从 pyspark 中的 json 文件加载到数据帧
- php - 在 php 中使用 trim 我想使用两个条件或一组条件来修剪?
- angular - 清晰度 - 动态数据网格
- android - 如何在按下 EditText 时阻止 Scrollview 将背景图像移动到顶部?
- c++ - 布尔向量的基于范围的 for 循环
- python - 如何创建可导出的表格图像?
- python - 将日期列表拆分为连续日期的子集
- node-modules - 为 Vue JS 项目安装 node-sass 时出错
- go - go get 不一致的内部包错误