SecSIGSecurity Special Interest Group of US MensaCuriosity. Perspective. Security.

Research Library · Idea

Gadget chains

A gadget chain is a sequence of existing code fragments in an application or its dependencies that, when linked during object reconstruction, produces an unintended and harmful result. Gadget chains matter in insecure deserialization, where untrusted data decides which types a program instantiates. The OWASP Deserialization Cheat Sheet notes that a deserializer can only instantiate types it knows about 1.

The cheat sheet lists known .NET classes that have been abused as gadgets. It also notes that allowed types can still be risky. It warns that native deserialization features can be repurposed for denial of service, access control bypass or remote code execution, and that Python's pickle can execute arbitrary code when it loads untrusted data 1.

The recommended defences are to avoid native serialization formats in favour of data-only formats such as JSON, and to deserialize only data whose signature has been verified. Developers should use allowlists of permitted types, for example Java serialization filters. They should avoid BinaryFormatter, which Microsoft says cannot be secured, and keep gadget-prone code separate from internet-facing code 1.

Source · Deserialization Cheat Sheet (opens in a new tab) · OWASP Cheat Sheet Series

References

  1. Deserialization Cheat Sheet (opens in a new tab) · OWASP Cheat Sheet Series ↩ ↩ ↩

Research articles

In the news

See what connects to it on the map of ideas →

See also