Secure code review

Reviewing application deserialisation trust boundaries

Serial interface: chip, wave, terminal arranged to illustrate reviewing application deserialisation trust boundaries.

Untrusted values need safe handling for the interpreter and context that will actually receive them. Understanding application deserialisation trust boundaries 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.

The conversion of data from a stored or transmitted representation into actual application objects (deserialisation) has historically been the cause of various code injection vulnerabilities. It is important to perform this process carefully and safely to avoid these types of issues.

In particular, certain methods of deserialisation have been identified by programming language or framework documentation as insecure and cannot be made safe with untrusted data. For each mechanism in use, careful due diligence should be performed.

Why it matters

Consider a realistic failure: a reporting feature safely stores a value but later interprets it as executable query or presentation syntax.

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.

A code audit connects a stated requirement to the implementation responsible for enforcing it. Source review and targeted behavioural checks should explain the same boundary and any relevant exceptions.

How penetration testers check for it

Review the specific control expectations below against the code, deployment and observable application behaviour.

  • Confirm that the application configures XML parsers to use a restrictive configuration and that unsafe features such as resolving external entities are disabled to prevent XML eXternal Entity (XXE) attacks.
  • Confirm that deserialisation of untrusted data enforces safe input handling, such as using an allowlist of object types or restricting client-defined object types, to prevent deserialisation attacks. Deserialisation mechanisms that are explicitly defined as insecure must not be used with untrusted input.
  • Confirm that different parsers used in the application for the same data type, perform parsing in a consistent way and use the same character encoding mechanism to avoid issues such as JSON Interoperability vulnerabilities or different URI or file parsing behaviour being exploited in Remote File Inclusion (RFI) or Server-side Request Forgery (SSRF) attacks.
  • Compare parsing across components and alternate request formats.
  • Use controlled invalid inputs to establish effects rather than assumptions.

How to fix it

Implement the required boundary in the component that actually performs the sensitive operation and retain focused regression coverage.

  • 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 the security of your application code.

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