XML Threat Protection¶
Overview¶
XML Threat Protection in Yappes guards XML payloads at the API Gateway against oversized documents, excessive element counts, and deeply nested structures that can indicate denial-of-service or injection attacks.
This feature helps organizations to:
- Limit XML element count, attribute count, and nesting depth before requests reach backend services
- Block malicious or abnormally large XML structures early in the request lifecycle
- Protect backend systems from XML-based abuse without changing application code
- Enforce consistent structural limits across XML API endpoints
When applied at the API or subscription level, XML Threat Protection enforces structural limits on XML payloads at the Yappes Gateway before they reach backend services.
XML Threat Protection aligns with OWASP API Security best practices for input validation and payload size control.
When to Use XML Threat Protection¶
Use XML Threat Protection when:
- APIs accept XML request or response payloads (
application/xml) - You need to cap element count, attribute count, text length, or nesting depth at the gateway
- Backend services should be protected from oversized or deeply nested XML
- You want separate request and response limits per endpoint
When Not to Use XML Threat Protection¶
Avoid using XML Threat Protection in the following scenarios:
- The endpoint uses JSON content type only (use JSON Threat Protection instead)
- You need pattern-based blocking on URI, headers, or query parameters (use Regex Threat Protection)
- Full XML schema (XSD) validation is required (consider Schema Validation for structural contracts)
Prerequisites¶
Before configuring XML Threat Protection policies, ensure the following requirements are met.
Required Access and Permissions¶
Common Requirements¶
- Active Yappes platform account
API Manageraccess- Permission to create and manage Gateway Policies
- At least one API created under
My APIs
API Level¶
- Endpoint content type is
application/xml - For GET endpoints, only Response context is supported (no request body)
Subscription Level¶
- API must be
published - An
active subscriptionmust be available on the Manage Subscriptions page
System Requirements¶
- Supported web browser:
Chrome,Edge, orFirefox
XML Configuration¶
XML Threat Protection is configured in a code editor labeled XML Configuration. A default template is loaded when you select Context (Request or Response). Edit the XML document to set limits for your endpoint.
Configuration Elements¶
| Element / Attribute | Required | Description | Default |
|---|---|---|---|
enabled |
Yes | Turns threat protection on or off for this policy | true |
continueOnError |
Yes | If true, the request proceeds even when evaluation fails |
false |
name |
Yes | Internal name for the protection configuration | XML-Threat-Protection-1 |
DisplayName |
Yes | Human-readable display name | XML Threat Protection |
ElementCount |
Yes | Maximum number of XML elements allowed in the document | 200 |
AttributeCount |
Yes | Maximum number of attributes allowed | 100 |
TextNodeLength |
Yes | Maximum length of text node content | 1000 |
ContainerDepth |
Yes | Maximum nesting depth of XML elements | 15 |
Default Template Example¶
<XMLThreatProtection
enabled="true"
continueOnError="false"
name="XML-Threat-Protection-1">
<DisplayName>XML Threat Protection</DisplayName>
<ElementCount>200</ElementCount>
<AttributeCount>100</AttributeCount>
<TextNodeLength>1000</TextNodeLength>
<ContainerDepth>15</ContainerDepth>
</XMLThreatProtection>
Note
- Click the Expand icon to open the editor in full-screen mode for easier editing.
- The configuration must be valid XML.
Info
When an endpoint uses an XML-compatible content type, the platform shows: "This endpoint uses XML-compatible content type, so only XML Threat Protection is available." in the JSON Threat Protection context on the Gateway Policies page.
Custom error and message
For error scenarios, you can override the default HTTP status code, error code, and message. See Custom Error and Message.
Step-by-Step Implementation¶
Method 1: Creating XML Threat Protection from the Endpoint Tab¶
Step 1: Navigate to API Manager¶
- Click on
Manage APIsin the main dashboard. - Select
My APIsfrom the submenu.
Step 2: Open Your API and Select an Endpoint¶
- For a new API, follow onboarding steps and open endpoint details.
- For an existing API, select it from
My APIsand click the target endpoint. - The endpoint must use content type
application/xml.
Step 3: Open XML Threat Protection Tab¶
- Click the
XML Threat Protectiontab on the endpoint details panel. - Click
XML Threat Protectionto create a new policy, orEdit/Viewon an existing attached policy.
Step 4: Enter Policy Details¶
- Enter a descriptive
Policy name(e.g.SoapOperationXmlResponseProtection). - Add a
Description(max 500 characters). Select APIand endpoint fields are read-only.
Step 5: Select Context and Configure XML¶
- Select
Context—RequestorResponse. - On
GETendpoints, onlyResponseis available. - Edit the
XML Configurationin the editor. Refer to XML Configuration for element details.
Step 6: Create the Policy¶
- Review the configuration.
- Click
Create policy(orSavewhen editing). Expected Result: The policy is attached to the endpoint.
Info
Each endpoint can have one request and one response XML Threat Protection policy. On GET endpoints, you can attach one response policy only.
Method 2: Creating XML Threat Protection from Gateway Policies Page¶
Step 1: Navigate to Gateway Policies¶
- Locate
Gateway Control → Gateway Policiesin the main navigation menu.
Step 2: Configure Policy Settings¶
- Click
Create Policy. - Select the appropriate
Control Levelbased on where the policy is required: API Level— Applies XML Threat Protection to a specific API endpoint at creation.Subscription Level— Creates a reusable policy for attachment to consumer subscription endpoints.- In
Policy Type, selectXML Threat Protection.
For general policy creation guidance, see Creating a policy (w/edit and delete).
Step 3: Define Policy Details¶
- Enter
Policy NameandDescription.
Step 4: Select API and Endpoint (API Level Only)¶
- If
Control Levelis set toAPI Level: - Select the target
APIandSource endpoint(orOperationfor SOAP APIs). - XML Threat Protection is shown when the endpoint content type is
application/xml. - If
Control Levelis set toSubscription Level: - No API or endpoint selection is required.
Step 5: Select Context and Configure XML¶
- Select
Context—RequestorResponse. - On
API Levelwith aGETendpoint, onlyResponseis available. - Edit
XML Configurationin the editor. Refer to XML Configuration for element details.
Info
At Subscription Level, both Request and Response context are available during policy creation. GET endpoint restrictions apply when you attach the policy to endpoints in Manage Subscriptions — request-context policies are not listed when a GET endpoint is selected.
Step 6: Create the Policy¶
- Review all settings.
- Click
Create Policy.
Success
The XML Threat Protection policy is successfully created.
Attaching XML Threat Protection Policy to Subscriptions¶
Use this flow when you created a policy with Control Level set to Subscription Level in Gateway Policies.
Step 1: Navigate to Manage Subscriptions¶
- From the main menu, click
Manage Subscriptions. - The
Manage Subscriptionspage displays a list of all API subscriptions. - Locate the subscription where you want to apply the XML Threat Protection policy.
Step 2: Open the Policy Attachment Dialog¶
- Click
Attach or Detachfor the relevant subscription. - The policy attachment dialog opens.
Step 3: Select Endpoint Level¶
- In the
Attach Policytab, selectEndpoint Level. - XML Threat Protection policies do not appear when
API Levelis selected. The platform shows: "Custom Plugin, JSON, XML and Regex Threat Protections are not listed and cannot be attached at API level."
Step 4: Select Endpoints¶
- Select one or more endpoints from the endpoint list.
- Only endpoints with
application/xml,text/xml, or*+xmlcontent type are compatible with XML Threat Protection policies. - If a
GETendpoint is among your selection,Requestcontext policies are not available for attachment. - After selecting endpoints, proceed to the policy selection step.
For general attach and detach steps, see Manage Subscriptions — Attach/Detach Gateway Policies.
Step 5: Select and Attach the Policy¶
- In
Select Policy to Attach, choose your subscription-level XML Threat Protection policy. - Click
Save Changesto apply the policy to the selected endpoints.
Note
- Only one policy of the same type can be attached to a subscription at a time. Detach the existing policy before attaching a replacement.
- Each endpoint supports at most one request and one response XML Threat Protection policy.
Understanding the Interface¶
| Component | Description |
|---|---|
| Policy Name | Identifies the XML Threat Protection policy |
| Description | Documents the policy purpose |
| Context | Request or Response — where limits are enforced |
| XML Configuration | Code editor for XML limit settings |
| Control Level | API Level (single endpoint at creation) or Subscription Level (attach via Manage Subscriptions) |
Control Level Summary¶
| Control Level | API/Endpoint at Creation | Attach Path |
|---|---|---|
| API Level | Required | Endpoint tab or Gateway Policies (auto-attached to selected endpoint) |
| Subscription Level | Not required | Manage Subscriptions → Endpoint Level |
Configuration and Settings¶
Required Configuration Fields¶
| Field | Requirement | Description |
|---|---|---|
| Policy Name | Mandatory | Min 3 characters; must start with a letter |
| Description | Optional | Max 500 characters |
| Control Level | Mandatory | API Level or Subscription Level |
| API Selection | Mandatory at API Level | Target API; not required at Subscription Level |
| Endpoint Selection | Mandatory at API Level | Specific endpoint for enforcement; not required at Subscription Level |
| Context | Mandatory | Request or Response |
| XML Configuration | Mandatory | Valid XML with configured limits |
Info
GET endpoints do not support Request context for XML Threat Protection. The platform shows: "Get endpoint can not have request context" and limits you to Response only.
Each endpoint supports at most one request and one response XML Threat Protection policy.
Best Practices for Configuration¶
| Best Practice | Benefit |
|---|---|
| Start with default limits and tune based on real SOAP/XML traffic | Reduces false blocks while maintaining protection |
| Set separate request and response policies when payload sizes differ | More precise control per direction |
Keep continueOnError as false in production |
Ensures limits are strictly enforced |
| Test with oversized XML documents in non-production | Confirms blocking behavior before rollout |
| Use Regex Threat Protection for URI/header pattern blocking | Complements structural XML limits |
What Happens If a Request Is Blocked¶
If XML Threat Protection detects a limit violation:
- The request or response is blocked at the API Gateway (unless
continueOnErroristrue) - The backend service is not invoked for blocked requests
- The client receives a threat protection error response
- The failure is logged for monitoring and audit purposes
Verification and Testing¶
After configuring XML Threat Protection:
- Send an XML payload within configured limits and confirm the API responds successfully.
- Send XML that exceeds element count, attribute count, or depth limits and confirm the gateway blocks it.
- Confirm separate request and response policies apply when both are configured.
- On GET endpoints, verify only response context is enforced.
Troubleshooting¶
| Issue | Possible Cause | Resolution |
|---|---|---|
| XML Threat Protection tab not visible | Endpoint content type is not application/xml |
Use an XML content type endpoint |
| Cannot select Request context | Endpoint method is GET | Use Response context only |
| Cannot create second policy | Request or response slot already filled | Edit existing policy or choose the other context |
| Configuration save fails | Invalid XML in editor | Fix syntax errors shown in the editor |
| Requests blocked unexpectedly | Limits too strict for legitimate payloads | Increase values in XML Configuration |
| JSON Threat Protection shown instead | Wrong content type on endpoint | Confirm endpoint uses application/xml |
Impact of Policy Changes¶
- Tightening limits may cause previously accepted XML payloads to fail.
- Relaxing limits may allow larger or deeper XML documents through the gateway.
- Changing
continueOnErroraffects whether violations block traffic or only log. - Always test updates in non-production before deploying to production.
❓ Frequently Asked Questions¶
How many XML Threat Protection policies can I attach per endpoint?
One request and one response policy per endpoint. GET endpoints support response only.
Is XML Threat Protection available at subscription level?
Yes. Create the policy with Control Level set to Subscription Level in Gateway Policies, then attach it via Manage Subscriptions at Endpoint Level. See Attaching XML Threat Protection Policy to Subscriptions.
Does XML Threat Protection validate against XSD?
No. It enforces structural limits (element count, depth, text length), not full schema validation.
What content types support XML Threat Protection?
Endpoints with application/xml content type.
Can I use XML Threat Protection on SOAP APIs?
Yes. SOAP endpoints typically use XML content type. The UI shows Operation instead of Endpoint for SOAP APIs.
What is the difference between XML and JSON Threat Protection?
JSON Threat Protection applies JSON-specific limits. XML Threat Protection applies element, attribute, and depth limits on XML documents.
Pro Tip
XML Threat Protection in Yappes enforces structural limits on XML payloads at the API Gateway. Use it on SOAP and XML endpoints, start with the default template, and pair with Regex Threat Protection for pattern-based defense on URI and headers.






