Safeguard
Security Guides•

Is Jackson default typing safe to use in a Spring application?

Jackson's maintainers advise against default typing for untrusted input because of deserialization gadgets. Safer: per class annotations and validators.

Safeguard Security Team
3 min read

Not for untrusted input. Jackson's own documentation says default typing is not generally encouraged and is recommended against when the content source is not trusted, because attackers can name classes that act as deserialization gadgets. Prefer per class type annotations and, if you must use default typing, a strict PolymorphicTypeValidator.

What default typing does

Normally JSON carries data but not Java class names. Default typing makes Jackson write, and later read, the class name for certain values. That lets one field hold different subclasses. The Jackson polymorphic deserialization documentation describes enabling it globally with a PolymorphicTypeValidator, and choosing which types are affected, such as Object, non concrete types or all non final classes.

The problem is who chooses the class. If untrusted input can name a class, Jackson may create it.

The gadget problem

Jackson's docs explain the risk: a class on the classpath may expose methods or fields that, when set through deserialization, do something harmful. These are known as deserialization gadgets. The docs say Jackson keeps a predefined block list of known cases, but that new ones are found over time, so at any moment there may be unblocked attack vectors.

That is why scanner findings in jackson-databind keep appearing. See our write ups on Jackson polymorphic deserialization issues and ObjectMapper risks.

ApproachExposure to attacker chosen classes
No polymorphism, concrete types onlyLowest
Per class JsonTypeInfo with a fixed set of subtypesLow, you list the allowed types
Default typing with a tight validatorDepends on the allow list
Default typing with a permissive validator on untrusted inputHigh

The docs say default typing can be reasonable when both ends, sender and receiver, are controlled by the same entity.

Steps

  1. Search for activateDefaultTyping and the older enableDefaultTyping in your code and in shared libraries.
  2. For each hit, ask who controls the JSON. Public request bodies, queue messages and cache entries all count.
  3. Replace global default typing with annotations that name allowed subtypes.
  4. If you keep default typing, build the validator with explicit allowed base types and packages, not a permissive setting.
  5. Keep jackson-databind current, and review how a transitive version is chosen. See Spring Boot managed versions.
  6. Use reachability analysis to separate a jackson advisory in your tree from one that your code can trigger.

Try it yourself

Click through it at your own pace, or open it full screen. Safeguard scans dependencies, produces SBOMs and uses reachability analysis to show which findings your code can actually reach. You can run a free scan at gold.safeguard.sh/scan.

Quick check

Does upgrading jackson-databind fix this?

Upgrades add to the block list, but the docs say new gadgets are found over time. Reducing who can name classes is the lasting fix.

Is JSON itself a deserialization risk?

Plain data binding to concrete types is much lower risk than type information chosen by the sender. See our post on whether JSON is safe from deserialization attacks.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.