Course contentsShow
← Security
Lesson 1963 of 3,05239. Cloud Security - Compute and ServerlessFree lesson

XML External Entities and Insecure Deserialization

Understanding XXE and deserialization attacks targeting serverless function input processing and data transformation.

XML External Entities and Insecure Deserialization

What You'll Learn

You'll learn how attackers exploit serverless function input parsing to execute code, leak secrets, or crash functions using malicious XML or serialized objects.

The Core Problem

Serverless functions often process data from external sources—APIs, queues, file uploads—and transform it into usable structures. When your function parses XML or deserializes objects without validation, attackers can inject malicious payloads that execute unintended operations.

XML External Entities (XXE)

Think of XML parsing like following a recipe that says "include ingredients from the file at this location." An XXE attack exploits this by pointing to dangerous locations:

  • Local file reads: <!ENTITY xxe SYSTEM "file:///proc/self/environ"> can leak environment variables containing secrets
  • SSRF attacks: Reference internal URLs to probe the VPC or access the IMDS
  • Denial of service: Billion laughs attack creates exponentially expanding XML

In serverless, this is especially dangerous because functions often have IAM roles with cloud permissions and can access internal networks.

Insecure Deserialization

Deserialization converts stored data back into objects. Attackers craft malicious serialized data that, when deserialized, executes arbitrary code:

  • Python's pickle.loads() on untrusted data
  • Java's ObjectInputStream reading attacker-controlled bytes
  • Node.js JSON.parse() with prototype pollution chains

The analogy: It's like receiving a gift box that, when opened, rearranges your entire house—the unpacking process itself causes damage.

Serverless Amplification

These attacks are particularly potent in serverless because:

  • Functions process diverse input formats (JSON, XML, binary)
  • Execution context has cloud credentials
  • Limited visibility into parser behavior
  • Third-party libraries may deserialize by default

Key Takeaway: Never parse XML with external entity resolution enabled or deserialize untrusted data without strict validation—in serverless, these input processing flaws can instantly expose secrets, trigger SSRF against cloud APIs, or achieve remote code execution with your function's IAM role.