You can use the xml-threat-protection
policy to validate an XML request body by applying limits on XML structures such as elements, entities, attributes and string values.
When an invalid request is detected (meaning the limit is reached), the request will be considered a threat and rejected with a 400 BAD REQUEST.
Property | Required | Description | Type | Default |
---|---|---|---|---|
maxElements |
Maximum number of elements allowed in an XML document. Example: |
integer (-1 to specify no limit) |
1000 |
|
maxDepth |
Maximum depth of XML structure. Example: |
integer (-1 to specify no limit) |
100 |
|
maxLength |
Maximum number of characters allowed for the whole XML document. |
integer (-1 to specify no limit) |
1000 |
|
maxAttributesPerElement |
Maximum number of attributes allowed for single XML element. |
integer (-1 to specify no limit) |
100 |
|
maxAttributeValueLength |
Maximum length of individual attribute values. |
integer (-1 to specify no limit) |
100 |
|
maxChildrenPerElement |
Maximum number of child elements for a given element. Example: |
integer (-1 to specify no limit) |
100 |
|
maxTextValueLength |
Maximum length of individual text value. |
integer (-1 to specify no limit) |
100 |
|
maxEntities |
Maximum number of entity expansions allowed. XML entities are a type of macro and vulnerable to entity expansion attacks (for more information on XML entity expansion attacks, see Billion laughs attack). |
integer (-1 to specify no limit) |
100 |
|
maxEntityDepth |
Maximum depth of nested entity expansions allowed. |
integer (-1 to specify no limit) |
100 |
|
allowExternalEntities |
Whether to allow inclusion of external entities. WARNING: Since XML can be vulnerable to XXE injection, only enable this feature if you can really trust your consumers. |
boolean |
false |
Code | Message |
---|---|
|
Applies to:
|
You can use the response template feature to override the default response provided by the policy. These templates must be defined at the API level (see the API Console Response Templates option in the API Proxy menu).
The error keys sent by this policy are as follows:
Key | Parameters |
---|---|
XML_THREAT_DETECTED |
- |
XML_THREAT_MAX_DEPTH |
- |
XML_THREAT_MAX_LENGTH |
- |
XML_THREAT_MAX_ATTRIBUTES |
- |
XML_THREAT_MAX_ATTRIBUTE_VALUE_LENGTH |
- |
XML_MAX_CHILD_ELEMENTS |
- |
XML_THREAT_MAX_TEXT_VALUE_LENGTH |
- |
XML_THREAT_MAX_ENTITIES |
- |
XML_THREAT_MAX_ENTITY_DEPTH |
- |
XML_THREAT_EXTERNAL_ENTITY_FORBIDDEN |
- |