Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLWhjMzMtMzJ2dy1ycHA5

Remote Code Execution Vulnerability in Session Storage

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

Permalink: https://github.com/advisories/GHSA-hc33-32vw-rpp9
JSON: https://advisories.ecosyste.ms/api/v1/advisories/MDE2OlNlY3VyaXR5QWR2aXNvcnlHSFNBLWhjMzMtMzJ2dy1ycHA5
Source: GitHub Advisory Database
Origin: Unspecified
Severity: Critical
Classification: General
Published: almost 3 years ago
Updated: over 1 year ago


CVSS Score: 10.0
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

Identifiers: GHSA-hc33-32vw-rpp9, CVE-2021-29485
References: Repository: https://github.com/ratpack/ratpack
Blast Radius: 23.5

Affected Packages

maven:io.ratpack:ratpack-core
Dependent packages: 29
Dependent repositories: 224
Downloads:
Affected Version Ranges: < 1.9.0
Fixed in: 1.9.0
All affected versions: 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.9.5, 0.9.6, 0.9.7, 0.9.8, 0.9.9, 0.9.10, 0.9.11, 0.9.12, 0.9.13, 0.9.14, 0.9.15, 0.9.16, 0.9.17, 0.9.18, 0.9.19, 1.0.0, 1.1.0, 1.1.1, 1.2.0, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.4.4, 1.4.5, 1.4.6, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.6.0, 1.6.1, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.8.0, 1.8.1, 1.8.2
All unaffected versions: 1.9.0