Mitigation Strategy: 1. Keep jackson-databind
Updated
-
Description:
- Identify the current
jackson-databind
version (checkpom.xml
,build.gradle
, etc.). - Find the latest patch release for your minor version on GitHub or Maven Central.
- Update the dependency in your project's build file.
- Run a full build and test suite.
- Configure a dependency management tool (Dependabot, Snyk, etc.) for automatic updates (at least weekly).
- Identify the current
-
Threats Mitigated:
- Remote Code Execution (RCE) (Critical): Updates often patch RCE vulnerabilities.
- Denial of Service (DoS) (High): Some vulnerabilities can cause crashes or unresponsiveness.
- Information Disclosure (Medium): Less common, but some vulnerabilities might leak information.
-
Impact:
- RCE: Significantly reduces risk. Risk reduction: High.
- DoS: Reduces risk. Risk reduction: Medium.
- Information Disclosure: Reduces risk. Risk reduction: Low.
-
Currently Implemented:
- Check the project's build file for the current version.
- Check for a dependency management tool configuration.
- Example:
pom.xml
shows version 2.12.3. Dependabot is configured, but checks monthly.
-
Missing Implementation:
- Ensure all instances of
jackson-databind
are updated (including subprojects). - Increase update frequency (e.g., to weekly).
- Example: A microservice uses an older version. Dependabot checks are missing for that microservice.
- Ensure all instances of
Mitigation Strategy: 2. Minimize Polymorphic Deserialization
-
Description:
- Review code for
@JsonTypeInfo
,@JsonSubTypes
, and related annotations. - Analyze if polymorphic deserialization is truly necessary. Could concrete types or composition be used?
- If possible, refactor to remove the annotations and use concrete types.
- If unavoidable, document why and proceed to other mitigations (especially PTV).
- Review code for
-
Threats Mitigated:
- RCE (Critical): Addresses the root cause of most
jackson-databind
RCE vulnerabilities. - DoS (High): Reduces the attack surface for DoS.
- RCE (Critical): Addresses the root cause of most
-
Impact:
- RCE: The most significant impact. Risk reduction: Very High.
- DoS: Moderate impact. Risk reduction: Medium.
-
Currently Implemented:
- Check for the presence of the relevant annotations.
- Review design documents for justification of polymorphism.
- Example: Several data models use
@JsonTypeInfo
without clear justification.
-
Missing Implementation:
- Identify classes/modules where refactoring to remove polymorphism is feasible.
- Example: The
Event
class hierarchy uses@JsonTypeInfo
but could use a singleEvent
class with aneventType
field.
Mitigation Strategy: 3. Use a Safe Default Typing Strategy
-
Description:
- Locate where the
ObjectMapper
is configured. - Check if
activateDefaultTyping
(orenableDefaultTyping
) is used. - Examine the
DefaultTyping
enum value. If it'sOBJECT_AND_NON_CONCRETE
orNON_FINAL
, it's unsafe. - Change it to
NON_CONCRETE_AND_ARRAYS
or, preferably, use a customTypeResolverBuilder
with aPolymorphicTypeValidator
(see next point). - Thoroughly test the application.
- Locate where the
-
Threats Mitigated:
- RCE (Critical): Limits types that can be automatically deserialized.
- DoS (High): Indirectly helps by reducing complexity.
-
Impact:
- RCE: Moderate impact on its own, but essential with a
PolymorphicTypeValidator
. Risk reduction: Medium (High with PTV). - DoS: Low impact. Risk reduction: Low.
- RCE: Moderate impact on its own, but essential with a
-
Currently Implemented:
- Check
ObjectMapper
configuration foractivateDefaultTyping
orenableDefaultTyping
. - Example:
ObjectMapper
is configured withDefaultTyping.NON_FINAL
.
- Check
-
Missing Implementation:
- Change the
DefaultTyping
setting. - Implement a
PolymorphicTypeValidator
(crucial). - Example: Change
DefaultTyping
and implement a PTV.
- Change the
Mitigation Strategy: 4. Implement a PolymorphicTypeValidator
(PTV)
-
Description:
- Create a
PolymorphicTypeValidator
instance (BasicPolymorphicTypeValidator
is a good start). - Configure it to whitelist allowed base types and subtypes. Be restrictive. Use methods like:
allowIfSubType(String prefix)
allowIfSubType(Class<?> clazz)
allowIfBaseType(Class<?> clazz)
allowIfSubType(Predicate<Class<?>> predicate)
- Pass the validator to
ObjectMapper
'sactivateDefaultTyping
. - Thoroughly test, adjusting the whitelist as needed.
- Create a
-
Threats Mitigated:
- RCE (Critical): The most effective mitigation when polymorphism is required. Prevents deserialization of unauthorized classes.
- DoS (High): Indirectly helps by limiting allowed types.
-
Impact:
- RCE: Very high impact. Risk reduction: Very High.
- DoS: Low impact. Risk reduction: Low.
-
Currently Implemented:
- Check
ObjectMapper
configuration for anyPolymorphicTypeValidator
. - Example: No
PolymorphicTypeValidator
is configured.
- Check
-
Missing Implementation:
- Critical missing piece. A PTV must be implemented if polymorphism is used.
- Create a
BasicPolymorphicTypeValidator
with a strict whitelist. - Example: Create a PTV to allow only specific subtypes within
com.example.app.models
.
Mitigation Strategy: 5. Disable Problematic Features
-
Description:
- Review the
ObjectMapper
configuration. - Disable unnecessary features that could increase the attack surface. Consider:
DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
MapperFeature.USE_GETTERS_AS_SETTERS
MapperFeature.AUTO_DETECT_CREATORS
,AUTO_DETECT_FIELDS
,AUTO_DETECT_GETTERS
,AUTO_DETECT_IS_GETTERS
,AUTO_DETECT_SETTERS
- Thoroughly test after disabling features.
- Review the
-
Threats Mitigated:
- RCE (Critical): Reduces the attack surface.
- DoS (High): Can help prevent some DoS attacks.
- Information Disclosure (Medium): Can reduce information leaked through errors.
-
Impact:
- RCE: Low to moderate impact. Risk reduction: Low-Medium.
- DoS: Low impact. Risk reduction: Low.
- Information Disclosure: Low impact. Risk reduction: Low.
-
Currently Implemented:
- Check
ObjectMapper
configuration for disabled features. - Example: No features are explicitly disabled.
- Check
-
Missing Implementation:
- Disable the listed features (or a subset) if not essential.
- Example: Disable
MapperFeature.AUTO_DETECT_CREATORS
,AUTO_DETECT_FIELDS
, etc.