漏洞描述
JBoss JMX 控制台存在弱口令漏洞。该漏洞允许未在配置文件中指定的方法(如 HEAD、PUT 或 DELETE 等)直接以 JBossAdmin 身份调用 GET 处理器,并通过 JBoss 的 HtmlAdaptor 模块部署 WebShell。
修复方案
使用网络访问控制
使用 ECS 安全组策略 限制可以访问 JBoss JMX 控制台的源 IP,不要将控制台开放到互联网上。
云盾检测及防护
使用云盾 态势感知 检测和防护该漏洞。您可以到 云盾控制台 开通并使用该服务。
删除默认控制台文件
如果您不需要使用控制台管理和发布代码,建议您卸载控制台。您可以删除$JBOSS_HOME/[server]/all/deploy
和$JBOSS_HOME/[server]/default/deploy
下的 Jmx-console.war
、Web-console.war
文件,以卸载控制台。
配置账户认证与鉴权
默认情况下,在访问http://localhost:8080/jmx-console
时,访问者不需要输入用户名和密码,即可浏览到 JBoss 的一部分部署管理信息。该设置存在安全隐患。
通过以下 JBoss 配置,可以使 JMX 控制台必须以用户名和密码才能访问。
在 JBoss 安装目录
/server/default/deploy/jmx-console.war/WEB-INF
下,打开jboss-web.xml
文件,去掉其中的<security-domain>java:/jaas/jmx-console</security- domain>
注释。修改后,该部分内容为:
<jboss-web>
<!-- Uncomment the security-domain to enable security. You will
need to edit the htmladaptor login configuration to setup the
login modules used to authentication users.-->
<security-domain>java:/jaas/jmx-console</security-domain>
</jboss-web>
在步骤 1 的同级目录下, 打开
web.xml
文件,找到<security-constraint/>
节点,并去掉该节点的注释。修改后,该部分内容为:
<!-- A security constraint that restricts access to the HTML JMX console
to users with the role JBossAdmin. Edit the roles to what you want and
uncomment the WEB-INF/jboss-web.xml/security-domain element to enable
secured access to the HTML JMX console.-->
<security-constraint>
<web-resource-collection>
<web-resource-name>HtmlAdaptor</web-resource-name>
<description>An example security config that only allows users with the
role JBossAdmin to access the HTML JMX console web application
</description>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<auth-constraint>
<role-name>JBossAdmin</role-name>
</auth-constraint>
</security-constraint>
完成该操作后,只有拥有系统配置的登录角色
JBossAdmin
的用户,才能访问 JMX 控制台。在 JBoss 安装目录
/server/default/conf
下,打开login-config.xml
,进一步配置步骤 1 中的 jmx-console 安全域和步骤 2 中的登录角色JBossAdmin
。查找名字为
jmx-console
的application-policy
:<application-policy name = "jmx-console">
<authentication>
<login-module code="org.jboss.security.auth.spi.UsersRolesLoginModule"
flag = "required">
<module-option name="usersProperties">props/jmx-console-users.properties</module-option>
<module-option name="rolesProperties">props/jmx-console-roles.properties</module-option>
</login-module>
</authentication>
</application-policy>
可以看到,登录用的角色和用户信息分别在
props
目录下的jmx-console-roles.properties
和jmx-console-users.properties
文件中设置。打开
jmx-console-users.properties
,其文件内容如下:# A sample users.properties file for use with the UsersRolesLoginModule
admin=admin
- 该文件的格式定义为:
用户名=密码
。 - 在该文件中,默认定义了一个用户名为
admin
,密码也为admin
的用户。
您可修改默认的用户名和密码。密码需要满足强口令策略;例如,应包括 8 位以上的大小写字母、特殊字符和数字。
打开
jmx-console-roles.properties
,其文件内容如下:# A sample roles.properties file for use with the UsersRolesLoginModule
admin=JBossAdmin, HttpInvoker
- 该文件的格式定义为:
用户名=角色
,多个角色以 “,” 隔开。 - 该文件默认为
admin
用户定义了JBossAdmin
和HttpInvoker
两个角色。
在此处,您应为允许登录的用户添加
JBossAdmin
角色。
配置完成后,当访问
http://localhost:8088/jmx-console/
时,只有使用在jmx-console-users.properties
文件中定义的用户名和密码,才能访问 JMX 的控制台页面。