Apache HertzBeat JDBC RCE
免责声明:本文仅供安全研究与学习交流使用,请勿将文中技术用于未经授权的测试或攻击。文中观点仅代表作者个人,与任何组织无关。如有侵权、内容异议或其他不便,请联系作者(GitHub:@unam4)删除。
0x01 Overview
This issue was identified by the Secrux team via static analysis. We request a CVE assignment; this is very important to the Secrux team.
Vulnerability description: A remote attacker with access to the monitor detection API can supply a crafted JDBC URL that bypasses the URL format checks and blacklist in JdbcCommonCollect#constructDatabaseUrl. When the backend attempts to connect, the injected H2 JDBC parameters can create and execute a malicious trigger, resulting in arbitrary command execution on the server.
Affected version: hertzbeat-1.8.0
1 | |
0x02 Analysis
org.apache.hertzbeat.collector.collect.database.JdbcCommonCollect#constructDatabaseUrl
1 | |
The core problem is that the regex validation can be bypassed.
1 | |
This check blocks ; and whitespace in the JDBC URL. Whitespace can be bypassed using /**/.
payload
1 | |
Then, leveraging H2's parsing behavior, a backslash can be inserted into keywords to bypass the blacklist checks.
1 | |
Finally, the payload is triggered in org.apache.hertzbeat.collector.collect.database.JdbcCommonCollect#getConnection.
0x03 PoC / Verification
1 | |
Full request below.
org.apache.hertzbeat.collector.collect.database.JdbcCommonCollect#constructDatabaseUrl
This method calls recursiveDecode(cleanedUrl) to decode the URL.
After sending the request, a reverse shell is obtained on 192.0.2.1:9001.
1 | |
0x04 Additional Details (CVE Report)
CWE: CWE-78 (OS Command Injection)
Attack Vector: Remote (network). Requires authenticated access to the backend monitor detect API and the ability to submit a crafted JDBC URL.
Impact: Backend remote command execution under the privileges of the Hertzbeat service process, leading to full system compromise.
Severity (suggested): High (RCE).
Affected Component: org.apache.hertzbeat.collector.collect.database.JdbcCommonCollect#constructDatabaseUrl and #getConnection.
Affected Versions: Tested on hertzbeat-1.8.0; earlier versions are likely affected if they share the same URL validation logic.
Suggested Mitigations:
- Enforce a strict allowlist of JDBC schemes and disallow H2
init/triggerfeatures. - Reject comment-based whitespace bypasses and normalize input before validation.
- Avoid recursive decoding or limit to a single safe decode pass.
- Restrict who can access the detect API and validate URLs server-side with a secure parser.
补充说明
payload在使用base64时,生成的base64字符不能有+符号,如果payload生成的base64包含+号,会被
1 | |
进行匹配到,这里需换下端口号,直到生成的base64字符不包含+号即可绕过检测,触发反弹shell。
payload
1 | |
完整数据包
1 | |
1 | |