CVE-2021-29485
Remote Code Execution Vulnerability in Session Storage
Description
Impact
A malicious attacker can achieve Remote Code Execution (RCE) via a maliciously crafted Java deserialization gadget chain leveraged against the Ratpack session store.
If your application does not use Ratpack's session mechanism, it is not vulnerable.
Details
Attackers with the ability to write to session data, can potentially craft payloads that deserialize unsafe objects, leading to the ability to remotely execute arbitrary code. This is known as an “insecure deserialization” vulnerability, or “gadget vulnerability”.
Ratpack allows session data to be stored server side in an external system such as a relational database, or client side via user cookies. When using server side storage, the attacker would need to obtain the ability to write to the session data store. When using client side storage, the attacker would need to obtain the secrets used to encrypt and/or sign the session data stored in user cookies.
Ratpack's session mechanism allows storing serialized objects, of arbitrary types. The type must be specified when writing the data and when reading, with data only deserialized when there is an exact type match. However, in the process of deserializing an object of a known/trusted/deserialization-safe type, it may attempt to deserialize unsafe types.
By default Ratpack uses Java's built-in serialization mechanism, though other serialization providers can be used. The exact types of payloads required to enable an exploit depend on the exact serialization mechanism used.
To mitigate this vulnerability, Ratpack now employs a “strict allow-list” when deserializing (and serializing) objects to session data. All concrete types of objects serialized must be explicitly declared as safe. Some standard well known JDK types are registered by default.
Serialization is provided by implementations of SessionSerializer.
Its existing methods have been deprecated, and replaced with a new methods that accept a SessionTypeFilter that can be used to assert whether a type is allowed when serializing and deserializing.
The default serializer implementation has been updated to use this mechanism. Any proprietary implementations should also be updated to consult the type filter before serializing or deserializing data. Warnings will be logged any time an implementation that does not implement the new methods is used.
Upon upgrading to Ratpack 1.9, users of the built-in serialization mechanism will need to change their application to declare all types currently being serialized as being safe. This can be done using the new SessionModule.allowTypes() method. Please see its documentation for details...))
Patches
Ratpack 1.9.0 introduces a strict allow-list mechanism that mitigates this vulnerability when used.
Workarounds
The simplest mitigation for users of earlier versions is to reduce the likelihood of attackers being able to write to the session data store.
Alternatively or additionally, the allow-list mechanism could be manually back ported by providing an alternative implementation of SessionSerializer that uses an allow-list.
References
- https://foxglovesecurity.com/2015/11/06/what-do-weblogic-websphere-jboss-jenkins-opennms-and-your-application-have-in-common-this-vulnerability/
- https://owasp.org/www-community/vulnerabilities/Deserialization_of_untrusted_data
Affected Maven artifacts (1)
| Artifact | Affected versions | Fixed in |
|---|---|---|
| io.ratpack » ratpack-core | < 1.9.0 | 1.9.0 |
Blast radius
52% of the dependent artifacts (90) still pull an affected version in their latest release.
| Depth | Dependent versions |
|---|---|
| Direct | 1,114 |
| 2 hops | 1,697 |
| 3 hops | 558 |
| 4 hops | 295 |
| 5 hops | 36 |
Most used dependents
- io.ratpack » ratpack-guice53 usages
- io.ratpack » ratpack-test17 usages
- com.github.jruby-gradle » jruby-gradle-plugin16 usages
- io.ratpack » ratpack-groovy15 usages
- io.ratpack » ratpack-groovy-test15 usages
- io.ratpack » ratpack-rx11 usages
- org.asciidoctor » asciidoctor-gradle-jvm-slides10 usages
- org.asciidoctor » asciidoctor-gradle-jvm-gems9 usages
- org.asciidoctor » asciidoctor5-jvm-core-plugin9 usages
- com.onresolve.jira.groovy » groovyrunner7 usages
- com.github.mstream-trader » commons-config7 usages
- org.http4k » http4k7 usages
- com.github.mstream-trader » commons-test6 usages
- io.ratpack » ratpack-session5 usages
- me.drmaas » ratpack-kotlin-test5 usages
Computed from the dependency graph of build 20261128.0605 (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
| Advisory | NVD CVE-2021-29485 | nvd.nist.gov |
| Package | ratpack/ratpack | github.com |
| Web | ratpack/ratpack advisory GHSA-hc33-32vw-rpp9 | github.com |
| Web | artifact/io.ratpack/ratpack-core | mvnrepository.com |
