Istio/CORS - 伪造 ORIGIN 可以触发网格端的请求块吗?

Istio/CORS - can faking ORIGIN trigger a request block on mesh side?

基于https://github.com/istio/istio/issues/23757,我已经有一段时间没有得到任何答案,所以我意识到我很可能不了解内部结构,我需要将问题转移到另一个方向。

我有一个案例,漏洞扫描显示我们容易受到自定义源域的攻击。提供商的期望是阻止与虚拟服务 allowOrigin 设置中的预定义 ORIGIN 不匹配的请求。 我正在尝试发送 OPTIONS 预检或简单获取,但无论我做什么,网格总是 returns 200:

curl -s -H "Origin: http://fake" --verbose http://192.168.223.10:31380/productpage | grep -i "HTTP/1.1 200 OK"
curl -s -H "Origin: http://testit.com" --verbose http://192.168.223.10:31380/productpage | grep -i "HTTP/1.1 200 OK"
curl -s -X OPTIONS -H "Origin: http://testit.com" --verbose http://192.168.223.10:31380/productpage | grep -i "HTTP/1.1 200 OK"
curl -s -X OPTIONS -H "Origin: http://fake" --verbose http://192.168.223.10:31380/productpage | grep -i "HTTP/1.1 200 OK"

这是只控制客户端阻塞(浏览器)的东西吗?如果是,我该如何用 curl 测试它?

我知道如何拒绝原点之类的,但它只会 return 找不到:

- uri:
    exact: /productpage
  headers:
    origin:
      regex: "*test.com"

github 上有这个问题的答案:


大家好。使用 curl 测试 CORS 可能有点误导。服务器端不强制执行 CORS;例如,它不会 return 4xx 错误。相反,headers 被 return 回退给浏览器使用的 deny/accept。 https://www.envoyproxy.io/docs/envoy/latest/start/sandboxes/cors.html?highlight=cors gives a good demo of this, and https://www.sohamkamani.com/blog/2016/12/21/web-security-cors/#:~:text=CORS%20isn't%20actually%20enforced,header%20in%20all%20its%20responses。很好的解释。

所以 Istio 在这里的工作只是 return 这些 headers。我添加了一个测试来展示这个作品:https://github.com/istio/istio/pull/26231