Summary
MoguBlog's WeChat callback handler parses attacker-controlled XML with an unhardened SAX reader, allowing external entities to be resolved during request processing. An unauthenticated remote attacker may read local files or cause the server to make outbound HTTP requests when the callback endpoint accepts malicious XML.
Affected context
The vulnerability occurs in deployments that expose the WeChat callback endpoint at POST /wechat/wechatCheck and pass the raw request body to XML parsing logic without disabling DTD processing and external entity resolution. Risk is higher when the application process can read sensitive local files or reach internal and external network services.
Exploit preconditions
- Attack surface: The publicly reachable WeChat callback HTTP endpoint
- Required access: No authentication may be required when the callback handler accepts requests directly
- Trigger point: XML parsing performed by
SignUtil.xmlToMap()during callback processing - Why exploitation is possible: The XML parser permits DTD declarations and external entity resolution, allowing attacker-controlled document references to be processed by the server
Why this happens
The underlying bug is unsafe XML parser configuration. The callback handler supplies untrusted request content to a dom4j SAXReader without restricting DTD handling or external entities, so document structure can cause the parser to access local resources or initiate network connections.
This behavior maps to CWE-611: Improper Restriction of XML External Entity Reference, where XML input can influence resource resolution beyond the intended application data model.
Potential impact
- An attacker may read files accessible to the application process
- The application may disclose resolved entity content through error responses
- The server could make outbound requests to attacker-controlled or internal services
- Internal network details or service metadata could be exposed
- Availability may be affected through resource-intensive XML processing
General mitigation guidance
Mitigation generally focuses on making XML parsing safe by default and reducing trust in request content.
Common defensive patterns include:
- Disable DTD processing and external general and parameter entities
- Use a hardened, restrictive XML parser configuration for every untrusted XML input
- Prefer schema-bound or non-XML formats when XML is not required
- Validate and constrain request structure before business processing
- Prevent outbound network access from callback workers where feasible
- Run the application with least-privilege filesystem and network permissions
- Avoid returning parser details or resolved content in client-visible errors
How teams detect issues like this
Organizations commonly detect this weakness through:
- Static analysis rules identifying XML parsers created without secure-processing settings
- Code review checks for DTD, entity, and external-schema configuration
- Testing that submits XML containing prohibited document declarations and verifies that resolution is blocked
- Runtime monitoring for unexpected outbound connections from callback handlers
- Error-response review for local path, metadata, or internal service content
- Policy enforcement requiring approved XML parsing wrappers or hardened libraries
Automated security review tools may help identify parser construction paths that do not explicitly disable external resource resolution.

