简体   繁体   English

AWS WAF 在尝试上传图像时出现 403 禁止错误

[英]AWS WAF Getting 403 forbidden error while trying to upload an image

We have enabled AWS WAF solution before my ALB and have SQL injection and XSS detection enabled.我们在我的 ALB 之前启用了 AWS WAF 解决方案,并启用了 SQL 注入和 XSS 检测。 We have tried to setup a custom rule to check if the content-type is multipart/form-data* using regex.我们尝试设置自定义规则,以使用正则表达式检查内容类型是否为 multipart/form-data*。

We have set that custom rule with higher priority.我们已经设置了具有更高优先级的自定义规则。 When using the custom rule the images are uploaded but the script tags are not forbidden.使用自定义规则时,上传图像但不禁止脚本标签。 Without having the custom rule if we try uploading the images one particular image alone is not getting uploaded and throws 403 forbidden.如果我们尝试上传图像,而没有自定义规则,则单独一张特定的图像不会被上传并抛出 403 禁止。

Any hints on adding XSS and custom rule to allow image uploads?关于添加 XSS 和自定义规则以允许图像上传的任何提示?

转到您的Web访问控制列表,点击编辑AWS-AWSManagedRulesCommonRuleSet,使覆盖规则的行动True规则SizeRestrictions_BODY

Check your image metadata.检查您的图像元数据。 I recently encountered this issue, and was getting the "GenericRFI_BODY" error in the ACL logs.我最近遇到了这个问题,并且在 ACL 日志中收到了“GenericRFI_BODY”错误。 It turns out the test image I was uploading had an illegal path in its exif data.事实证明,我上传的测试图像在其 exif 数据中有一个非法路径。 There was a URL that pointed to the site where the image came from in some metadata field, and the "://" pattern in that URL was triggering the rule.有一个 URL 指向某个元数据字段中图像来自的站点,并且该 URL 中的“://”模式触发了规则。 Stripping the metadata from the image allowed it to upload.从图像中剥离元数据允许它上传。

I strongly discourage base64 encoding to circumvent firewall rules.我强烈反对使用 base64 编码来规避防火墙规则。 This will bloat the size of your files, and multipart/form-data exists specifically to stream large binaries back and forth from client to server - not to post massive serialized text blocks.这会增加文件的大小,并且 multipart/form-data 专门用于在客户端和服务器之间来回传输大型二进制文件 - 而不是发布大量序列化的文本块。

Here's the RFC: https://www.ietf.org/rfc/rfc2388.txt这是 RFC: https : //www.ietf.org/rfc/rfc2388.txt

I faced 403 issue in AWS firewall when I try to add image as multipart/form-data.当我尝试将图像添加为 multipart/form-data 时,我在 AWS 防火墙中遇到了 403 问题。

Some of the WAF rules which blocks the image upload are, AWS#AWSManagedRulesSQLiRuleSet#GenericRFI_BODY, AWS#AWSManagedRulesSQLiRuleSet#SQLi_BODY and AWS#AWSManagedRulesCommonRuleSet#CrossSiteScripting_BODY.一些阻止图像上传的 WAF 规则是 AWS#AWSManagedRulesSQLiRuleSet#GenericRFI_BODY、AWS#AWSManagedRulesSQLiRuleSet#SQLi_BODY 和 AWS#AWSManagedRulesCommonRuleSet#CrossSiteScripting_BODY。

I solved this issue by uploading the image as base64 string instead of uploading as multipart/form-data.我通过将图像上传为 base64 字符串而不是上传为 multipart/form-data 解决了这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用AWS开发工具包从AWS Elastic Search获取索引时出现403禁止错误 - 403 forbidden error while getting indexes from AWS Elastic search using AWS SDK 尝试使用 AWS SDK 从 Java 应用程序连接 SQS 时出现 403 禁止错误 - 403 forbidden error while trying to connect SQS from Java application using AWS SDK 尝试使用 Boto3(Django + Javascript)通过预先签名的帖子将文件上传到 AWS S3 时被禁止获取 403 - Getting 403 Forbidden when trying to upload file to AWS S3 with presigned post using Boto3 (Django + Javascript) 通过ansible访问AWS时遇到403禁止错误 - Getting a 403 forbidden error on accessing AWS through ansible 将 Laravel 应用程序部署到 AWS Elastic Beanstalk 时出现“403 Forbidden”错误 - Getting a '403 Forbidden' error on deploying a Laravel application to AWS Elastic Beanstalk 通过浏览器访问网站时出现403(禁止访问)错误 - getting 403(Access Forbidden) error while accessing the site through browser 403 - 禁止:试图让 WordPress 在 AWS 上运行 - 403 - Forbidden: Trying to get WordPress to Run on AWS 是否可以更改 AWS WAF v2 上的 403 错误页面? - Is it possible to change 403 error page on AWS WAF v2? Gremlin 到 AWS Neptune 的 403 禁止错误 - 403 Forbidden error for Gremlin to AWS Neptune AWS Config API 返回 403:禁止错误 - AWS Config API returning 403: Forbidden Error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM