Wildfly Java 应用程序:对某些 URL 进行主机标头攻击的漏洞

问题描述 投票:0回答:0

我有一个在 Wildfly 上运行的 Java 应用程序。我们发现该应用程序似乎容易受到针对某些 URL 的主机标头攻击。该应用程序有几个过滤器可以处理这个问题,但某些请求没有通过它们,因此很容易受到攻击。似乎当某些网址不以

/
结尾时,就会发生这种情况。

我的web.xml文件是这样设置的:

<context-param>
    <param-name>root_path</param-name>
    <param-value>app/</param-value>
</context-param>

...

<filter>
    <filter-name>AppFilter</filter-name>
    <filter-class>com.foo.bar.AppFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>AppFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

这是一个显示主机标头问题的示例 curl 请求:

curl -v 'localhost:80/app' -H 'Host: example.org:123'
*   Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /app HTTP/1.1
> Host: example.org:123
> User-Agent: curl/7.87.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Connection: keep-alive
< Location: http://example.org:123/app/
< Content-Length: 0
< Date: Fri, 05 May 2023 23:18:08 GMT
<
* Connection #0 to host localhost left intact

如果我像这样在 URL 的末尾添加

/
localhost:80/app/
,则漏洞不再存在并且请求按预期通过应用程序的过滤器。

我试过稍微修改 web.xml 但没有成功。我将

root_path
更改为
app
而不是
app/
并添加了
/
*
url-patterns
filter-mapping
但这些都不起作用。

我想知道 web.xml 中是否缺少某些配置,或者我是否可以在 standlone.xml 中做些什么来解决这个问题。

java http-headers wildfly servlet-filters web.xml
© www.soinside.com 2019 - 2024. All rights reserved.