API security

XML and SOAP API parser security

Input to execution: document, filter, code arranged to illustrate xml and soap api parser security.

XML and SOAP services need parser and resource limits as well as authentication. Understanding XML and soap API parser security helps establish which security property the feature needs and where that property is actually enforced.

What does this involve?

Input validation defines the structures, sizes and meanings an application expects to receive. It must happen before information influences a sensitive operation. Validation does not replace safe interpreter APIs, output encoding or permission checks, because those controls address different boundaries.

Output encoding or escaping, performed close to or adjacent to a potentially dangerous context, is critical to the security of any application. Typically, output encoding and escaping are not persisted, but are instead used to render output safe for immediate use in the appropriate interpreter. Attempting to perform this too early may result in malformed content or render the encoding or escaping ineffective.

In many cases, software libraries include safe or safer functions that perform this automatically, although it is necessary to ensure that they are correct for the current context.

Why it matters

Consider a realistic failure: a document parser resolves an external reference outside its intended input.

Untrusted input can change application behaviour, consume excessive resources or reach data and execution paths outside the intended feature. The practical result depends on where the value is used and which privileges are available there.

An API review follows the server-side behaviour behind the interface. Direct requests, alternate methods and background operations can reveal boundaries that the normal frontend journey does not exercise.

How penetration testers check for it

Review entity handling, schemas, transformations and bounded message processing.

  • Confirm that output encoding for an HTTP response, HTML document, or XML document is relevant for the context required, such as encoding the relevant characters for HTML elements, HTML attributes, HTML comments, CSS, or HTTP header fields, to avoid changing the message or document structure.
  • Confirm that when dynamically building URLs, untrusted data is encoded according to its context. Ensure that only safe URL protocols are permitted.
  • Confirm that output encoding or escaping is used when dynamically building JavaScript content (including JSON), to avoid changing the message or document structure (to avoid JavaScript and JSON injection).
  • Confirm that data selection or database queries use parameterized queries, ORMs, entity frameworks, or are otherwise protected from SQL Injection and other database injection attacks. This is also relevant when writing stored procedures.
  • Confirm that the application protects against OS command injection and that operating system calls use parameterized OS queries or use contextual command line output encoding.
  • Confirm that the application protects against LDAP injection vulnerabilities, or that specific security controls to prevent LDAP injection have been implemented.
  • Confirm that the application is protected against XPath injection attacks by using query parameterization or precompiled queries.
  • Confirm that LaTeX processors are configured securely and an allowlist of commands is used to prevent LaTeX injection attacks.
  • Confirm that the application escapes special characters in regular expressions (typically using a backslash) to prevent them from being misinterpreted as metacharacters.
  • Confirm that the application is protected against CSV and Formula Injection. The application must follow the escaping rules defined in RFC 4180 sections 2.6 and 2.7 when exporting CSV content. Additionally, when exporting to CSV or other spreadsheet formats, special characters (including '=', '+', '-', '@', '\t' (tab), and '\0' (null character)) must be escaped with a single quote if they appear as the first character in a field value.
  • Confirm that all untrusted HTML input from WYSIWYG editors or similar is sanitized using a well-known and secure HTML sanitization library or framework feature.
  • Confirm that the application avoids the use of eval or other dynamic code execution features such as Spring Expression Language (SpEL). Where there is no alternative, any user input being included must be sanitized before being executed.
  • Confirm that data being passed to a potentially dangerous context is sanitized beforehand to enforce safety measures, such as only allowing characters which are safe for this context and trimming input which is too long.
  • Confirm that user-supplied Scalable Vector Graphics (SVG) scriptable content is validated or sanitized to contain only tags and attributes that are safe for the application, e.g., do not contain scripts and foreignObject.
  • Confirm that the application sanitizes or disables user-supplied scriptable or expression template language content, such as Markdown, CSS or XSL stylesheets, BBCode, or similar.
  • Confirm that the application protects against Server-side Request Forgery (SSRF) attacks, by validating untrusted data against an allowlist of protocols, domains, paths and ports and sanitizing potentially dangerous characters before using the data to call another service.
  • Confirm that the application protects against template injection attacks by not allowing templates to be built based on untrusted input. Where there is no alternative, any untrusted input being included dynamically during template creation must be sanitized or strictly validated.
  • Confirm that the application appropriately sanitizes untrusted input before use in Java Naming and Directory Interface (JNDI) queries and that JNDI is configured securely to prevent JNDI injection attacks.
  • Confirm that the application sanitizes content before it is sent to memcache to prevent injection attacks.
  • Confirm that format strings which might resolve in an unexpected or malicious way when used are sanitized before being processed.
  • Confirm that the application sanitizes user input before passing to mail systems to protect against SMTP or IMAP injection.
  • Confirm that regular expressions are free from elements causing exponential backtracking, and ensure untrusted input is sanitized to mitigate ReDoS or Runaway Regex attacks.
  • Compare parsing across components and alternate request formats.
  • Use controlled invalid inputs to establish effects rather than assumptions.

How to fix it

Disable unnecessary external resolution and apply safe parser configuration and input limits.

  • Use explicit schemas and canonical representations.
  • Prefer safe parsers and parameterised interpreter interfaces.
  • Reject unexpected structures before sensitive processing.
  • Apply resource bounds and predictable failure handling.

Blocking a few known attack strings is not a complete validation strategy. The intended data model and downstream interpretation determine which protections are needed.

Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.

Read about our methodology or contact pentested.com to discuss your APIs and integrations.

See your first test report this week.

Book a 30 minute demo. We will verify one of your targets with you and run a test against it, so you can judge the results on your own systems.

Book a demo