CVE-2021-42392
RCE in H2 Console
Description
Impact
H2 Console in versions since 1.1.100 (2008-10-14) to 2.0.204 (2021-12-21) inclusive allows loading of custom classes from remote servers through JNDI.
H2 Console doesn't accept remote connections by default. If remote access was enabled explicitly and some protection method (such as security constraint) wasn't set, an intruder can load own custom class and execute its code in a process with H2 Console (H2 Server process or a web server with H2 Console servlet).
It is also possible to load them by creation a linked table in these versions, but it requires ADMIN privileges and user with ADMIN privileges has full access to the Java process by design. These privileges should never be granted to untrusted users.
Patches
Since version 2.0.206 H2 Console and linked tables explicitly forbid attempts to specify LDAP URLs for JNDI. Only local data sources can be used.
Workarounds
H2 Console should never be available to untrusted users.
-webAllowOthers is a dangerous setting that should be avoided.
H2 Console Servlet deployed on a web server can be protected with a security constraint:
https://h2database.com/html/tutorial.html#usingH2ConsoleServlet
If webAllowOthers is specified, you need to uncomment and edit <security-role> and <security-constraint> as necessary. See documentation of your web server for more details.
References
This issue was found and privately reported to H2 team by JFrog Security's vulnerability research team with detailed information.
Affected Maven artifacts (1)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| com.h2database » h2 | >= 1.1.100, < 2.0.206 | 2.0.206 |
Blast radius
60% of the dependent artifacts (8,032) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 93,830 |
| 2 hops | 332,174 |
| 3 hops | 178,717 |
| 4 hops | 97,632 |
| 5 hops | 38,785 |
| 6 hops | 14,428 |
Most used dependents
- org.sonatype.plugins » nexus-staging-maven-plugin36,701 usages
- org.wso2.carbon » org.wso2.carbon.core1,598 usages
- org.owasp » dependency-check-maven1,289 usages
- org.mybatis.spring.boot » mybatis-spring-boot-starter1,222 usages
- org.wso2.carbon » org.wso2.carbon.ui803 usages
- org.wso2.carbon » org.wso2.carbon.registry.core760 usages
- com.atlassian.confluence » confluence724 usages
- org.dbunit » dbunit596 usages
- com.atlassian.jira » jira-core554 usages
- org.openmrs.test » openmrs-test514 usages
- org.wso2.carbon » org.wso2.carbon.user.core377 usages
- org.wildfly » wildfly-feature-pack372 usages
- org.geoserver » gs-main299 usages
- org.finos.legend.engine » legend-engine-pure-code-compiled-core286 usages
- org.springframework.batch » spring-batch-core271 usages
Computed from the dependency graph of build 20261124.0621 (compile and runtime scopes, nearest version wins). Exclusions and dependency management in consuming projects are not applied, so dependents are potentially affected. When several artifacts are affected, a dependent version that pulls more than one of them is counted once per artifact.
References
- Webhttps://github.com/h2database/h2database/security/advisories/GHSA-h376-j262-vhq6
- Advisoryhttps://nvd.nist.gov/vuln/detail/CVE-2021-42392
- Packagehttps://github.com/h2database/h2database
- Webhttps://github.com/h2database/h2database/releases/tag/version-2.0.206
- Webhttps://jfrog.com/blog/the-jndi-strikes-back-unauthenticated-rce-in-h2-database-console
- Webhttps://lists.debian.org/debian-lts-announce/2022/02/msg00017.html
- Webhttps://security.netapp.com/advisory/ntap-20220119-0001
- Webhttps://www.debian.org/security/2022/dsa-5076
- Webhttps://www.oracle.com/security-alerts/cpuapr2022.html
- Webhttps://www.secpod.com/blog/log4shell-critical-remote-code-execution-vulnerability-in-h2database-console
