CVE-2025-59340: jinjava has Sandbox Bypass via JavaType-Based Deserialization
(updated )
jinjava’s current sandbox restrictions prevent direct access to dangerous methods such as getClass(), and block instantiation of Class objects. However, these protections can be bypassed.
By using mapper.getTypeFactory().constructFromCanonical(), it is possible to instruct the underlying ObjectMapper to deserialize attacker-controlled input into arbitrary classes. This enables the creation of semi-arbitrary class instances without directly invoking restricted methods or class literals.
As a result, an attacker can escape the sandbox and instantiate classes such as java.net.URL, opening up the ability to access local files and URLs(e.g., file:///etc/passwd). With further chaining, this primitive can potentially lead to remote code execution (RCE).
References
- github.com/HubSpot/jinjava
- github.com/HubSpot/jinjava/commit/66df351e7e8ad71ca04dcacb4b65782af820b8b1
- github.com/HubSpot/jinjava/releases/tag/jinjava-2.7.5
- github.com/HubSpot/jinjava/releases/tag/jinjava-2.8.1
- github.com/HubSpot/jinjava/security/advisories/GHSA-m49c-g9wr-hv6v
- github.com/advisories/GHSA-m49c-g9wr-hv6v
- nvd.nist.gov/vuln/detail/CVE-2025-59340
Code Behaviors & Features
Detect and mitigate CVE-2025-59340 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →