RCE in H2 Console
Published 6 Jan 2022 · Updated 8 Jul 2026
Is your project on an affected com.h2database:h2?
Look after several Java apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- >=1.1.100 <2.0.206
- Fixed in
- 2.0.206
mvn versions:use-dep-version -Dincludes=com.h2database:h2 -DdepVersion=2.0.206 -DforceVersion=trueDetails
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.
Is GHSA-h376-j262-vhq6 in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected com.h2database:h2, and gives you the command that fixes it.
More advisories for com.h2database:h2
- HighCVE-2022-45868Password exposure in H2 Database · 23 Nov 2022
- CriticalCVE-2022-23221Arbitrary code execution in H2 Console · 21 Jan 2022
- HighCVE-2021-23463Improper Restriction of XML External Entity Reference in com.h2database:h2. · 16 Dec 2021
References
- Linkgithub.com/h2database/h2database/security/advisories/GHSA-h376-j262-vhq6
- Advisorynvd.nist.gov/vuln/detail/CVE-2021-42392
- Packagegithub.com/h2database/h2database
- Linkgithub.com/h2database/h2database/releases/tag/version-2.0.206
- Linkjfrog.com/blog/the-jndi-strikes-back-unauthenticated-rce-in-h2-database-console
- Linklists.debian.org/debian-lts-announce/2022/02/msg00017.html
- Linksecurity.netapp.com/advisory/ntap-20220119-0001
- Linkwww.debian.org/security/2022/dsa-5076
- Linkwww.oracle.com/security-alerts/cpuapr2022.html
- Linkwww.secpod.com/blog/log4shell-critical-remote-code-execution-vulnerability-in-h2database-console
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.