This skill focuses on determining at the source code level whether "deserialization/XXE/SSTI holds true". The core work is: white-box confirmation of deserialization entry points, tracing data sources, evaluating available Gadget chains in the classpath, verifying XML parser security configurations, and checking template engine rendering contexts. Runtime black-box techniques such as constructing exploit payloads and sending remote exploit chains fall under the scope of the corresponding exploit skill.
In-depth reference
- Dangerous patterns / secure pattern code comparisons for 3 categories of vulnerabilities / Gadget dependency table / EVID evidence examples → references/serialization-patterns.md
Quick reference table for 3 categories of vulnerabilities
| Type | Typical Sink | Exploitation conditions | Severity |
|---|---|---|---|
| Java deserialization | ObjectInputStream.readObject(), XMLDecoder.readObject() |
User-controllable serialized stream + available Gadget Chain in the classpath | Critical |
| XXE | DocumentBuilderFactory, SAXParser, XMLInputFactory, TransformerFactory, SchemaFactory |
External entities/DTD not disabled + user-controllable XML input | High-Critical |
| SSTI | Velocity.evaluate, FreeMarker Template, Thymeleaf preprocessing expression |
User input directly enters the template compilation/rendering context | Critical |
Java deserialization audit key points
- Entry point identification:
ObjectInputStream.readObject()、ObjectInputStream.readUnshared()、XMLDecoder.readObject(), customreadObject/readResolve/readExternaladditional attack surface in implementations - Data source tracing: HTTP request body (magic bytes
AC ED 00 05or Base64-encodedrO0AB), RMI/JMX remote invocation, JMS message queues, Redis/Memcached cache deserialization, file reads, ViewState, Cookie/Session serialized storage - Gadget availability assessment: Check
pom.xml/build.gradleand whether dependencies of known Gadget chains exist in the classpath (commons-collections 3.x/4.x, commons-beanutils, spring-core, Groovy, hibernate-core, etc.), and whether the versions are within the affected range - Defense mechanism verification: JEP 290
ObjectInputFilterwhether configured, whitelist vs blacklist strategy,SerialKiller/NotSoSerialwhether third-party protection libraries such as these are enabled,resolveClasswhether rewritten as whitelist validation - readResolve/readObject custom logic: Even if no general-purpose Gadget exists, behaviors such as file operations, network requests, and dynamic class loading in custom deserialization methods also constitute attack surface
XXE audit key points
- Secure configuration of 5 XML parsers:
DocumentBuilderFactory:setFeature("http://apache.org/xml/features/disallow-doctype-decl", true)SAXParserFactory: Same as above +setFeature("http://xml.org/sax/features/external-general-entities", false)+setFeature("http://xml.org/sax/features/external-parameter-entities", false)XMLInputFactory(StAX):setProperty(XMLInputFactory.SUPPORT_DTD, false)+setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false)TransformerFactory:setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "")+setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "")SchemaFactory:setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "")+setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "")
- Data flow analysis: XML input sources (HTTP request body, file upload, SOAP message, SVG/Office file) → enter parser → parsing result echoed back (direct XXE) or not echoed back (blind injection/out-of-band OOB)
- Java-specific protocols:
jar:protocol can trigger remote file download and decompression,netdoc:protocol (older JDK) is equivalent tofile://
Template injection SSTI audit key points
- Velocity:
Velocity.evaluate(context, writer, tag, userTemplate)— ifuserTemplateparameter is user-controllable then direct RCE - FreeMarker:
new Template("t", new StringReader(userInput), cfg).process(dataModel, writer)— user input compiled as template source is dangerous - Thymeleaf: controller return value concatenation leads to SSTI,
return "user/" + inputwhen input can inject__${expr}__preprocessing expression triggers SpEL → RCE - Secure pattern: template name/path whitelist, FreeMarker setting
TemplateClassResolver.ALLOWS_NOTHING_RESOLVERDisabled?new()Built-in functions, Velocity usageSecureUberspector, Thymeleaf restricts view names from concatenating user input
Detection Checklist
- All
ObjectInputStream.readObject()/XMLDecoder.readObject()call sites have been reviewed one by one - Data sources of deserialization entry points (HTTP/RMI/JMS/cache/file) have been traced and confirmed
- Classpath dependencies have been checked for known Gadget Chain libraries and their affected versions
- Defense mechanisms such as JEP 290 ObjectInputFilter / SerialKiller / whitelist resolveClass have been verified
- Additional attack surface in custom readObject/readResolve methods has been investigated
- Secure Feature configurations for the 5 XML parsers have been confirmed one by one
- XML input sources (request body/upload/SOAP/SVG) and echo methods have been analyzed
- User input controllability at Velocity/FreeMarker/Thymeleaf template rendering entry points has been checked
- Template engine security modes (sandbox/whitelist/disabling dangerous functions) have been verified
- Severity scoring uses a unified formula, consistent with the pipeline