Exploiting Excessive Data Exposure in API
When to Use
- Testing APIs where the frontend displays a subset of data but the API response includes additional fields
- Assessing mobile application APIs where responses are designed for multiple client types and may contain excess data
- Identifying PII leakage in API responses that include email addresses, phone numbers, SSNs, or payment data not shown in the UI
- Testing GraphQL APIs where clients can request arbitrary fields including sensitive attributes
- Evaluating APIs after microservice refactoring where internal service-to-service data leaks into public endpoints
Do not use without written authorization. Data exposure testing involves capturing and analyzing potentially sensitive personal data.
Prerequisites
- Written authorization specifying target API endpoints and scope
- Burp Suite Professional or mitmproxy configured as intercepting proxy
- Two test accounts at different privilege levels (regular user and admin)
- Browser developer tools or mobile proxy setup for traffic capture
- Python 3.10+ with
requests and json libraries
- API documentation (OpenAPI spec) for comparison against actual responses
Legal Notice: This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.
Workflow
Step 1: Response Schema Discovery
Compare documented API responses with actual responses:
import requests
import json
BASE_URL = "https://target-api.example.com/api/v1"
headers = {"Authorization": "Bearer <user_token>", "Content-Type": "application/json"}
# Fetch a resource and analyze all returned fields
endpoints_to_test = [
("GET", "/users/me", None),
("GET", "/users/me/orders", None),
("GET", "/products", None),
("GET", "/users/me/settings", None),
("GET", "/transactions", None),
]
for method, path, body in endpoints_to_test:
resp = requests.request(method, f"{BASE_URL}{path}", headers=headers, json=body)
if resp.status_code == 200:
data = resp.json()
# Recursively extract all field names
def extract_fields(obj, prefix=""):
fields = []
if isinstance(obj, dict):
for k, v in obj.items():
full_key = f"{prefix}.{k}" if prefix else k
fields.append(full_key)
fields.extend(extract_fields(v, full_key))
elif isinstance(obj, list) and obj:
fields.extend(extract_fields(obj[0], f"{prefix}[]"))
return fields
all_fields = extract_fields(data)
print(f"\n{method} {path} - {len(all_fields)} fields returned:")
for f in sorted(all_fields):
print(f" {f}")
📎 Detailed content (full examples / references / data tables) has been split into reference.md in the same directory; use Read to load the relevant section on demand.
1---2name: exploiting-excessive-data-exposure-in-api3description: "Exploit excessive data exposure in APIs. Signals: attack surface, cloud assets, exposure."4zh-signals: "Exploiting Excessive Data Exposure in API 信号:攻击面,云资产,暴露面。"5when-to-use: >-6 Tests APIs for excessive data exposure (OWASP API3:2023) by intercepting raw API7 responses and comparing them against what the UI actually renders, looking for8 leaked PII, internal identifiers, debug data, or business-sensitive fields the9 frontend filters but the API still transmits. Use when auditing REST or mobile-app10 APIs for over-fetching, response filtering bypass, or unintended data leakage in11 endpoint responses.12domain: cybersecurity13subdomain: api-security14tags:15- api-security16- owasp17- data-exposure18- rest-security19- pii-leakage20version: 1.0.021author: mahipal22license: Apache-2.023nist_csf:24- PR.PS-0125- ID.RA-0126- PR.DS-1027- DE.CM-0128mitre_attack:29- T119030- T1059.00731- T1552.00132- T102733- T107034metadata:35 source: https://skillmd.com/skills/dangeroussong/exploiting-excessive-data-exposure-in-api36---3738# Exploiting Excessive Data Exposure in API3940## When to Use4142- Testing APIs where the frontend displays a subset of data but the API response includes additional fields43- Assessing mobile application APIs where responses are designed for multiple client types and may contain excess data44- Identifying PII leakage in API responses that include email addresses, phone numbers, SSNs, or payment data not shown in the UI45- Testing GraphQL APIs where clients can request arbitrary fields including sensitive attributes46- Evaluating APIs after microservice refactoring where internal service-to-service data leaks into public endpoints4748**Do not use** without written authorization. Data exposure testing involves capturing and analyzing potentially sensitive personal data.4950## Prerequisites5152- Written authorization specifying target API endpoints and scope53- Burp Suite Professional or mitmproxy configured as intercepting proxy54- Two test accounts at different privilege levels (regular user and admin)55- Browser developer tools or mobile proxy setup for traffic capture56- Python 3.10+ with `requests` and `json` libraries57- API documentation (OpenAPI spec) for comparison against actual responses585960> **Legal Notice:** This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.6162## Workflow6364### Step 1: Response Schema Discovery6566Compare documented API responses with actual responses:6768```python69import requests70import json7172BASE_URL = "https://target-api.example.com/api/v1"73headers = {"Authorization": "Bearer <user_token>", "Content-Type": "application/json"}7475# Fetch a resource and analyze all returned fields76endpoints_to_test = [77 ("GET", "/users/me", None),78 ("GET", "/users/me/orders", None),79 ("GET", "/products", None),80 ("GET", "/users/me/settings", None),81 ("GET", "/transactions", None),82]8384for method, path, body in endpoints_to_test:85 resp = requests.request(method, f"{BASE_URL}{path}", headers=headers, json=body)86 if resp.status_code == 200:87 data = resp.json()88 # Recursively extract all field names89 def extract_fields(obj, prefix=""):90 fields = []91 if isinstance(obj, dict):92 for k, v in obj.items():93 full_key = f"{prefix}.{k}" if prefix else k94 fields.append(full_key)95 fields.extend(extract_fields(v, full_key))96 elif isinstance(obj, list) and obj:97 fields.extend(extract_fields(obj[0], f"{prefix}[]"))98 return fields99100 all_fields = extract_fields(data)101 print(f"\n{method} {path} - {len(all_fields)} fields returned:")102 for f in sorted(all_fields):103 print(f" {f}")104```105106> 📎 Detailed content (full examples / references / data tables) has been split into `reference.md` in the same directory; use Read to load the relevant section on demand.