漏洞修复:HTML5: CORS Functionality Abuse

描述

WebInspect has detected the target application supports “Origin: null” for CORS requests, making it vulnerable to CORS attacks.
Cross-Origin Resource Sharing, commonly referred to as CORS, is a technology that allows a domain to define a policy for its resources to be accessed by a web page hosted on a different domain using cross domain XML HTTP Requests (XHR). Historically, the browser restricts cross domain XHR requests to abide by the same origin policy. At its basic form, the same origin policy sets the script execution scope to the resources available on the current domain and prohibits any communication to domains outside this scope. Therefore, execution and incorporation of remote methods and functions hosted on domains outside of the current domain are effectively prohibited. While CORS is supported on all major browsers, it also requires that the domain correctly defines the CORS policy in order to have its resources shared with another domain. These restrictions are managed by access policies typically included in specialized response headers, such as:
Access-Control-Allow-Origin
Access-Control-Allow-Headers
Access-Control-Allow-Methods
In this instance, the Access-Control-Allow-Origin header is set to "null" as seen in the pre-flight response. This makes the target application vulnerable to CORS attacks. Sandboxed documents and various URI scheme such as data: or file: have their 'Origin' defined as ‘null’. Thus, any malicious user can easily obtain "Origin: null" can be easily obtained by any malicious user by simply enclosing the malicious CORS request from within an iframeand using the sandboxattribute.

解决方案

在server中添加
add_header Access-Control-Allow-Origin 允许访问的ip或者域名,允许访问的ip或者域名;
例如:

server{
	add_header Access-Control-Allow-Origin  192.168.11.62;
}

或者

server{
	add_header 'Access-Control-Allow-Origin' $http_origin;
}

实际情况中,还是扫到了
另一个解决方案
判断$http_origin
如果不在白名单,直接403

if ( $http_origin !~* '192.168.1.1|172.1.1.1') {
        return 403 ;
}

参考

https://vulncat.fortify.com/en/detail?id=desc.dynamic.html.html5_cors_functionality_abuse
https://blog.csdn.net/enthan809882/article/details/107941696
https://blog.csdn.net/u014163312/article/details/120007012

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值