[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EJ72Y2F4FAY0KY4Y1F1MDM":3,"skill-same:01M7EJ72Y2F4FAY0KY4Y1F1MDM":72},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":44,"commitSha":45,"skillDirectory":46,"forksCount":47,"repositoryHtmlUrl":48,"repositoryHomepageUrl":6,"ownerHtmlUrl":49,"ownerBlogUrl":6,"ownerDescription":50,"updatedAt":51,"install":52,"resources":65},"01M7EJ72Y2F4FAY0KY4Y1F1MDM","exploiting-excessive-data-exposure-in-api",null,"Tests APIs for excessive data exposure (OWASP API3:2023) by intercepting raw API responses and comparing them against what the UI actually renders, looking for leaked PII, internal identifiers, debug data, or business-sensitive fields the frontend filters but the API still transmits. Use when auditing REST or mobile-app APIs for over-fetching, response filtering bypass, or unintended data leakage in endpoint responses.","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fexploiting-excessive-data-exposure-in-api\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: exploiting-excessive-data-exposure-in-api\ndescription: >-\n  Tests APIs for excessive data exposure (OWASP API3:2023) by intercepting raw API\n  responses and comparing them against what the UI actually renders, looking for\n  leaked PII, internal identifiers, debug data, or business-sensitive fields the\n  frontend filters but the API still transmits. Use when auditing REST or mobile-app\n  APIs for over-fetching, response filtering bypass, or unintended data leakage in\n  endpoint responses.\ndomain: cybersecurity\nsubdomain: api-security\ntags:\n- api-security\n- owasp\n- data-exposure\n- rest-security\n- pii-leakage\nversion: 1.0.0\nauthor: mahipal\nlicense: Apache-2.0\nnist_csf:\n- PR.PS-01\n- ID.RA-01\n- PR.DS-10\n- DE.CM-01\nmitre_attack:\n- T1190\n- T1059.007\n- T1552.001\n- T1027\n- T1070\n---\n# Exploiting Excessive Data Exposure in API\n\n## When to Use\n\n- Testing APIs where the frontend displays a subset of data but the API response includes additional fields\n- Assessing mobile application APIs where responses are designed for multiple client types and may contain excess data\n- Identifying PII leakage in API responses that include email addresses, phone numbers, SSNs, or payment data not shown in the UI\n- Testing GraphQL APIs where clients can request arbitrary fields including sensitive attributes\n- Evaluating APIs after microservice refactoring where internal service-to-service data leaks into public endpoints\n\n**Do not use** without written authorization. Data exposure testing involves capturing and analyzing potentially sensitive personal data.\n\n## Prerequisites\n\n- Written authorization specifying target API endpoints and scope\n- Burp Suite Professional or mitmproxy configured as intercepting proxy\n- Two test accounts at different privilege levels (regular user and admin)\n- Browser developer tools or mobile proxy setup for traffic capture\n- Python 3.10+ with `requests` and `json` libraries\n- API documentation (OpenAPI spec) for comparison against actual responses\n\n\n> **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.\n\n## Workflow\n\n### Step 1: Response Schema Discovery\n\nCompare documented API responses with actual responses:\n\n```python\nimport requests\nimport json\n\nBASE_URL = \"https:\u002F\u002Ftarget-api.example.com\u002Fapi\u002Fv1\"\nheaders = {\"Authorization\": \"Bearer \u003Cuser_token>\", \"Content-Type\": \"application\u002Fjson\"}\n\n# Fetch a resource and analyze all returned fields\nendpoints_to_test = [\n    (\"GET\", \"\u002Fusers\u002Fme\", None),\n    (\"GET\", \"\u002Fusers\u002Fme\u002Forders\", None),\n    (\"GET\", \"\u002Fproducts\", None),\n    (\"GET\", \"\u002Fusers\u002Fme\u002Fsettings\", None),\n    (\"GET\", \"\u002Ftransactions\", None),\n]\n\nfor method, path, body in endpoints_to_test:\n    resp = requests.request(method, f\"{BASE_URL}{path}\", headers=headers, json=body)\n    if resp.status_code == 200:\n        data = resp.json()\n        # Recursively extract all field names\n        def extract_fields(obj, prefix=\"\"):\n            fields = []\n            if isinstance(obj, dict):\n                for k, v in obj.items():\n                    full_key = f\"{prefix}.{k}\" if prefix else k\n                    fields.append(full_key)\n                    fields.extend(extract_fields(v, full_key))\n            elif isinstance(obj, list) and obj:\n                fields.extend(extract_fields(obj[0], f\"{prefix}[]\"))\n            return fields\n\n        all_fields = extract_fields(data)\n        print(f\"\\n{method} {path} - {len(all_fields)} fields returned:\")\n        for f in sorted(all_fields):\n            print(f\"  {f}\")\n```\n\n### Step 2: Sensitive Data Pattern Detection\n\nScan API responses for sensitive data patterns:\n\n```python\nimport re\n\nSENSITIVE_PATTERNS = {\n    \"email\": r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}',\n    \"phone\": r'(\\+?1?\\s?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4})',\n    \"ssn\": r'\\b\\d{3}-\\d{2}-\\d{4}\\b',\n    \"credit_card\": r'\\b(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13})\\b',\n    \"password_hash\": r'\\$2[aby]?\\$\\d{2}\\$[.\u002FA-Za-z0-9]{53}',\n    \"api_key\": r'(?:api[_-]?key|apikey)[\"\\s:=]+[\"\\']?([a-zA-Z0-9_\\-]{20,})',\n    \"internal_ip\": r'\\b(?:10\\.\\d{1,3}|172\\.(?:1[6-9]|2\\d|3[01])|192\\.168)\\.\\d{1,3}\\.\\d{1,3}\\b',\n    \"aws_key\": r'AKIA[0-9A-Z]{16}',\n    \"jwt_token\": r'eyJ[A-Za-z0-9_-]+\\.eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+',\n    \"uuid\": r'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',\n}\n\nSENSITIVE_FIELD_NAMES = [\n    \"password\", \"password_hash\", \"secret\", \"token\", \"ssn\", \"social_security\",\n    \"credit_card\", \"card_number\", \"cvv\", \"pin\", \"private_key\", \"api_key\",\n    \"internal_id\", \"debug\", \"trace\", \"stack_trace\", \"created_by_ip\",\n    \"last_login_ip\", \"salt\", \"session_id\", \"refresh_token\", \"mfa_secret\",\n    \"date_of_birth\", \"bank_account\", \"routing_number\", \"tax_id\"\n]\n\ndef scan_response(endpoint, response_text):\n    findings = []\n    # Check for sensitive data patterns in values\n    for pattern_name, pattern in SENSITIVE_PATTERNS.items():\n        matches = re.findall(pattern, response_text)\n        if matches:\n            findings.append({\n                \"endpoint\": endpoint,\n                \"type\": \"sensitive_value\",\n                \"pattern\": pattern_name,\n                \"count\": len(matches),\n                \"sample\": matches[0][:20] + \"...\" if len(matches[0]) > 20 else matches[0]\n            })\n\n    # Check for sensitive field names\n    response_lower = response_text.lower()\n    for field in SENSITIVE_FIELD_NAMES:\n        if f'\"{field}\"' in response_lower or f\"'{field}'\" in response_lower:\n            findings.append({\n                \"endpoint\": endpoint,\n                \"type\": \"sensitive_field\",\n                \"field_name\": field\n            })\n\n    return findings\n\n# Scan all endpoint responses\nfor method, path, body in endpoints_to_test:\n    resp = requests.request(method, f\"{BASE_URL}{path}\", headers=headers, json=body)\n    if resp.status_code == 200:\n        findings = scan_response(f\"{method} {path}\", resp.text)\n        for f in findings:\n            print(f\"[FINDING] {f['endpoint']}: {f['type']} - {f.get('pattern', f.get('field_name'))}\")\n```\n\n### Step 3: Compare UI Display vs API Response\n\n```python\n# Fields the UI shows (observed from the frontend application)\nui_displayed_fields = {\n    \"\u002Fusers\u002Fme\": {\"name\", \"email\", \"avatar_url\", \"role\"},\n    \"\u002Fusers\u002Fme\u002Forders\": {\"order_id\", \"date\", \"status\", \"total\"},\n    \"\u002Fproducts\": {\"id\", \"name\", \"price\", \"image_url\", \"description\"},\n}\n\n# Fields the API actually returns\nfor method, path, body in endpoints_to_test:\n    resp = requests.request(method, f\"{BASE_URL}{path}\", headers=headers, json=body)\n    if resp.status_code == 200:\n        data = resp.json()\n        if isinstance(data, list):\n            actual_fields = set(data[0].keys()) if data else set()\n        elif isinstance(data, dict):\n            # Handle paginated responses\n            items_key = next((k for k in data if isinstance(data[k], list)), None)\n            if items_key and data[items_key]:\n                actual_fields = set(data[items_key][0].keys())\n            else:\n                actual_fields = set(data.keys())\n        else:\n            continue\n\n        expected = ui_displayed_fields.get(path, set())\n        excess = actual_fields - expected\n        if excess:\n            print(f\"\\n{method} {path} - EXCESS FIELDS (not shown in UI):\")\n            for field in sorted(excess):\n                print(f\"  - {field}\")\n```\n\n### Step 4: Test User Object Exposure in Related Endpoints\n\n```python\n# Many APIs embed full user objects in responses for orders, comments, etc.\nendpoints_with_user_objects = [\n    \"\u002Forders\",          # Each order may include full seller\u002Fbuyer profile\n    \"\u002Fcomments\",        # Comments may include full author profile\n    \"\u002Freviews\",         # Reviews may expose reviewer details\n    \"\u002Ftransactions\",    # Transactions may include counterparty info\n    \"\u002Fteam\u002Fmembers\",    # Team listing may expose excessive member data\n]\n\nfor path in endpoints_with_user_objects:\n    resp = requests.get(f\"{BASE_URL}{path}\", headers=headers)\n    if resp.status_code == 200:\n        text = resp.text\n        # Check for user data leakage in nested objects\n        user_fields_found = []\n        for field in [\"password_hash\", \"last_login_ip\", \"mfa_enabled\", \"phone_number\",\n                      \"date_of_birth\", \"ssn\", \"internal_notes\", \"salary\", \"address\"]:\n            if f'\"{field}\"' in text:\n                user_fields_found.append(field)\n        if user_fields_found:\n            print(f\"[EXCESSIVE] {path} exposes user fields: {user_fields_found}\")\n```\n\n### Step 5: GraphQL Over-Fetching Analysis\n\n```python\n# GraphQL allows clients to request any available field\nGRAPHQL_URL = f\"{BASE_URL}\u002Fgraphql\"\n\n# Introspection query to discover all fields on User type\nintrospection = {\n    \"query\": \"\"\"\n    {\n      __type(name: \"User\") {\n        fields {\n          name\n          type {\n            name\n            kind\n          }\n        }\n      }\n    }\n    \"\"\"\n}\n\nresp = requests.post(GRAPHQL_URL, headers=headers, json=introspection)\nif resp.status_code == 200:\n    fields = resp.json().get(\"data\", {}).get(\"__type\", {}).get(\"fields\", [])\n    print(\"Available User fields via GraphQL:\")\n    for f in fields:\n        sensitivity = \"SENSITIVE\" if f[\"name\"] in SENSITIVE_FIELD_NAMES else \"normal\"\n        print(f\"  {f['name']} ({f['type']['name']}) [{sensitivity}]\")\n\n# Try to query sensitive fields\nsensitive_query = {\n    \"query\": \"\"\"\n    query {\n      users {\n        id\n        email\n        passwordHash\n        socialSecurityNumber\n        internalNotes\n        lastLoginIp\n        mfaSecret\n        apiKey\n      }\n    }\n    \"\"\"\n}\nresp = requests.post(GRAPHQL_URL, headers=headers, json=sensitive_query)\nif resp.status_code == 200 and \"errors\" not in resp.json():\n    print(\"[CRITICAL] GraphQL exposes sensitive user fields without restriction\")\n```\n\n### Step 6: Debug and Internal Data Leakage\n\n```python\n# Test for debug information in responses\ndebug_headers_to_check = [\n    \"X-Debug-Token\", \"X-Debug-Info\", \"Server\", \"X-Powered-By\",\n    \"X-Request-Id\", \"X-Correlation-Id\", \"X-Backend-Server\",\n    \"X-Runtime\", \"X-Version\", \"X-Build-Version\"\n]\n\nresp = requests.get(f\"{BASE_URL}\u002Fusers\u002Fme\", headers=headers)\nfor h in debug_headers_to_check:\n    if h.lower() in {k.lower(): v for k, v in resp.headers.items()}:\n        print(f\"[INFO LEAK] Header {h}: {resp.headers.get(h)}\")\n\n# Test error responses for stack traces\nerror_payloads = [\n    (\"GET\", \"\u002Fusers\u002Finvalid-id-format\", None),\n    (\"POST\", \"\u002Forders\", {\"invalid\": \"payload\"}),\n    (\"GET\", \"\u002Fusers\u002F-1\", None),\n    (\"GET\", \"\u002Fusers\u002F0\", None),\n]\n\nfor method, path, body in error_payloads:\n    resp = requests.request(method, f\"{BASE_URL}{path}\", headers=headers, json=body)\n    if resp.status_code >= 400:\n        text = resp.text.lower()\n        if any(kw in text for kw in [\"stack trace\", \"traceback\", \"at com.\", \"at org.\",\n                                      \"file \\\"\", \"line \", \"exception\", \"sql\", \"query\"]):\n            print(f\"[DEBUG LEAK] {method} {path} -> {resp.status_code}: Contains stack trace or query info\")\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Excessive Data Exposure** | API returns more data fields than the client needs, relying on frontend filtering to hide sensitive information from users |\n| **Over-Fetching** | Requesting or receiving more data than needed for a specific operation, common in REST APIs that return fixed response schemas |\n| **Response Filtering** | Client-side filtering of API response data to display only relevant fields, which provides zero security since the full response is interceptable |\n| **Object Property Level Authorization** | OWASP API3:2023 - ensuring that users can only read\u002Fwrite object properties they are authorized to access |\n| **PII Leakage** | Unintended exposure of Personally Identifiable Information in API responses including names, emails, addresses, SSNs, or financial data |\n| **Schema Validation** | Enforcing that API responses conform to a defined schema, stripping unauthorized fields before transmission |\n\n## Tools & Systems\n\n- **Burp Suite Professional**: Intercept API responses and use the Comparer tool to diff expected vs actual response schemas\n- **mitmproxy**: Scriptable proxy for automated response analysis with Python-based content inspection scripts\n- **OWASP ZAP**: Passive scanner detects information disclosure in headers, error messages, and response bodies\n- **Postman**: Compare documented response schemas against actual API responses using test scripts\n- **jq**: Command-line JSON processor for extracting and analyzing specific fields from API responses\n\n## Common Scenarios\n\n### Scenario: Mobile Banking API Data Exposure Assessment\n\n**Context**: A mobile banking application's API returns full account objects to the mobile client, which only displays account nickname and balance. The API is accessed by both iOS and Android apps and a web portal.\n\n**Approach**:\n1. Configure mitmproxy on a test device and authenticate as the test user\n2. Capture all API responses during a complete user session (login, view accounts, transfer, logout)\n3. Analyze `GET \u002Fapi\u002Fv1\u002Faccounts` response: UI shows 4 fields but API returns 23 fields\n4. Discover that the API returns `routing_number`, `account_holder_ssn_last4`, `internal_risk_score`, `kyc_verification_status`, and `linked_external_accounts` - none shown in UI\n5. Analyze `GET \u002Fapi\u002Fv1\u002Ftransactions` response: API returns `merchant_id`, `terminal_id`, `authorization_code`, `processor_response` fields not needed by the client\n6. Check `GET \u002Fapi\u002Fv1\u002Fusers\u002Fme`: API returns `last_login_ip`, `mfa_backup_codes_remaining`, `account_officer_name`, and `credit_score_band`\n7. Test error responses: `POST \u002Fapi\u002Fv1\u002Ftransfers` with invalid payload returns SQL table name in error message\n\n**Pitfalls**:\n- Only checking top-level fields and missing sensitive data in deeply nested objects\n- Not testing paginated responses where subsequent pages may include different fields\n- Ignoring response headers that may leak server version, backend technology, or internal routing information\n- Missing data exposure in error responses which often contain stack traces, SQL queries, or internal paths\n- Assuming that HTTPS encryption prevents data exposure (it protects in transit, not from the authenticated client)\n\n## Output Format\n\n```\n## Finding: Excessive Data Exposure in Account and Transaction APIs\n\n**ID**: API-DATA-001\n**Severity**: High (CVSS 7.1)\n**OWASP API**: API3:2023 - Broken Object Property Level Authorization\n**Affected Endpoints**:\n  - GET \u002Fapi\u002Fv1\u002Faccounts\n  - GET \u002Fapi\u002Fv1\u002Ftransactions\n  - GET \u002Fapi\u002Fv1\u002Fusers\u002Fme\n\n**Description**:\nThe API returns full database objects to the client, including sensitive fields\nthat are not displayed in the mobile application UI. The mobile app filters\nthese fields client-side, but they are fully accessible by intercepting the\nAPI response. This exposes SSN fragments, internal risk scores, and KYC\nverification data for any authenticated user.\n\n**Excess Fields Discovered**:\n- \u002Faccounts: routing_number, account_holder_ssn_last4, internal_risk_score,\n  kyc_verification_status, linked_external_accounts (18 excess fields total)\n- \u002Ftransactions: merchant_id, terminal_id, authorization_code,\n  processor_response (12 excess fields total)\n- \u002Fusers\u002Fme: last_login_ip, mfa_backup_codes_remaining, credit_score_band\n\n**Impact**:\nAn authenticated user can extract sensitive financial data, internal risk\nassessments, and PII for their own account that the application is not\nintended to reveal. Combined with BOLA vulnerabilities, this data could\nbe extracted for all users.\n\n**Remediation**:\n1. Implement server-side response filtering using DTOs\u002Fview models that only include fields needed by the client\n2. Use GraphQL field-level authorization or REST response schemas per endpoint per role\n3. Remove sensitive fields from API responses at the serialization layer\n4. Implement response schema validation in the API gateway to strip undocumented fields\n5. Add automated tests that verify response schemas match documentation\n```\n","# Exploiting Excessive Data Exposure in API\n\n## When to Use\n\n- Testing APIs where the frontend displays a subset of data but the API response includes additional fields\n- Assessing mobile application APIs where responses are designed for multiple client types and may contain excess data\n- Identifying PII leakage in API responses that include email addresses, phone numbers, SSNs, or payment data not shown in the UI\n- Testing GraphQL APIs where clients can request arbitrary fields including sensitive attributes\n- Evaluating APIs after microservice refactoring where internal service-to-service data leaks into public endpoints\n\n**Do not use** without written authorization. Data exposure testing involves capturing and analyzing potentially sensitive personal data.\n\n## Prerequisites\n\n- Written authorization specifying target API endpoints and scope\n- Burp Suite Professional or mitmproxy configured as intercepting proxy\n- Two test accounts at different privilege levels (regular user and admin)\n- Browser developer tools or mobile proxy setup for traffic capture\n- Python 3.10+ with `requests` and `json` libraries\n- API documentation (OpenAPI spec) for comparison against actual responses\n\n\n> **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.\n\n## Workflow\n\n### Step 1: Response Schema Discovery\n\nCompare documented API responses with actual responses:\n\n```python\nimport requests\nimport json\n\nBASE_URL = \"https:\u002F\u002Ftarget-api.example.com\u002Fapi\u002Fv1\"\nheaders = {\"Authorization\": \"Bearer \u003Cuser_token>\", \"Content-Type\": \"application\u002Fjson\"}\n\n# Fetch a resource and analyze all returned fields\nendpoints_to_test = [\n    (\"GET\", \"\u002Fusers\u002Fme\", None),\n    (\"GET\", \"\u002Fusers\u002Fme\u002Forders\", None),\n    (\"GET\", \"\u002Fproducts\", None),\n    (\"GET\", \"\u002Fusers\u002Fme\u002Fsettings\", None),\n    (\"GET\", \"\u002Ftransactions\", None),\n]\n\nfor method, path, body in endpoints_to_test:\n    resp = requests.request(method, f\"{BASE_URL}{path}\", headers=headers, json=body)\n    if resp.status_code == 200:\n        data = resp.json()\n        # Recursively extract all field names\n        def extract_fields(obj, prefix=\"\"):\n            fields = []\n            if isinstance(obj, dict):\n                for k, v in obj.items():\n                    full_key = f\"{prefix}.{k}\" if prefix else k\n                    fields.append(full_key)\n                    fields.extend(extract_fields(v, full_key))\n            elif isinstance(obj, list) and obj:\n                fields.extend(extract_fields(obj[0], f\"{prefix}[]\"))\n            return fields\n\n        all_fields = extract_fields(data)\n        print(f\"\\n{method} {path} - {len(all_fields)} fields returned:\")\n        for f in sorted(all_fields):\n            print(f\"  {f}\")\n```\n\n### Step 2: Sensitive Data Pattern Detection\n\nScan API responses for sensitive data patterns:\n\n```python\nimport re\n\nSENSITIVE_PATTERNS = {\n    \"email\": r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}',\n    \"phone\": r'(\\+?1?\\s?\\(?\\d{3}\\)?[\\s.-]?\\d{3}[\\s.-]?\\d{4})',\n    \"ssn\": r'\\b\\d{3}-\\d{2}-\\d{4}\\b',\n    \"credit_card\": r'\\b(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13})\\b',\n    \"password_hash\": r'\\$2[aby]?\\$\\d{2}\\$[.\u002FA-Za-z0-9]{53}',\n    \"api_key\": r'(?:api[_-]?key|apikey)[\"\\s:=]+[\"\\']?([a-zA-Z0-9_\\-]{20,})',\n    \"internal_ip\": r'\\b(?:10\\.\\d{1,3}|172\\.(?:1[6-9]|2\\d|3[01])|192\\.168)\\.\\d{1,3}\\.\\d{1,3}\\b',\n    \"aws_key\": r'AKIA[0-9A-Z]{16}',\n    \"jwt_token\": r'eyJ[A-Za-z0-9_-]+\\.eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+',\n    \"uuid\": r'[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',\n}\n\nSENSITIVE_FIELD_NAMES = [\n    \"password\", \"password_hash\", \"secret\", \"token\", \"ssn\", \"social_security\",\n    \"credit_card\", \"card_number\", \"cvv\", \"pin\", \"private_key\", \"api_key\",\n    \"internal_id\", \"debug\", \"trace\", \"stack_trace\", \"created_by_ip\",\n    \"last_login_ip\", \"salt\", \"session_id\", \"refresh_token\", \"mfa_secret\",\n    \"date_of_birth\", \"bank_account\", \"routing_number\", \"tax_id\"\n]\n\ndef scan_response(endpoint, response_text):\n    findings = []\n    # Check for sensitive data patterns in values\n    for pattern_name, pattern in SENSITIVE_PATTERNS.items():\n        matches = re.findall(pattern, response_text)\n        if matches:\n            findings.append({\n                \"endpoint\": endpoint,\n                \"type\": \"sensitive_value\",\n                \"pattern\": pattern_name,\n                \"count\": len(matches),\n                \"sample\": matches[0][:20] + \"...\" if len(matches[0]) > 20 else matches[0]\n            })\n\n    # Check for sensitive field names\n    response_lower = response_text.lower()\n    for field in SENSITIVE_FIELD_NAMES:\n        if f'\"{field}\"' in response_lower or f\"'{field}'\" in response_lower:\n            findings.append({\n                \"endpoint\": endpoint,\n                \"type\": \"sensitive_field\",\n                \"field_name\": field\n            })\n\n    return findings\n\n# Scan all endpoint responses\nfor method, path, body in endpoints_to_test:\n    resp = requests.request(method, f\"{BASE_URL}{path}\", headers=headers, json=body)\n    if resp.status_code == 200:\n        findings = scan_response(f\"{method} {path}\", resp.text)\n        for f in findings:\n            print(f\"[FINDING] {f['endpoint']}: {f['type']} - {f.get('pattern', f.get('field_name'))}\")\n```\n\n### Step 3: Compare UI Display vs API Response\n\n```python\n# Fields the UI shows (observed from the frontend application)\nui_displayed_fields = {\n    \"\u002Fusers\u002Fme\": {\"name\", \"email\", \"avatar_url\", \"role\"},\n    \"\u002Fusers\u002Fme\u002Forders\": {\"order_id\", \"date\", \"status\", \"total\"},\n    \"\u002Fproducts\": {\"id\", \"name\", \"price\", \"image_url\", \"description\"},\n}\n\n# Fields the API actually returns\nfor method, path, body in endpoints_to_test:\n    resp = requests.request(method, f\"{BASE_URL}{path}\", headers=headers, json=body)\n    if resp.status_code == 200:\n        data = resp.json()\n        if isinstance(data, list):\n            actual_fields = set(data[0].keys()) if data else set()\n        elif isinstance(data, dict):\n            # Handle paginated responses\n            items_key = next((k for k in data if isinstance(data[k], list)), None)\n            if items_key and data[items_key]:\n                actual_fields = set(data[items_key][0].keys())\n            else:\n                actual_fields = set(data.keys())\n        else:\n            continue\n\n        expected = ui_displayed_fields.get(path, set())\n        excess = actual_fields - expected\n        if excess:\n            print(f\"\\n{method} {path} - EXCESS FIELDS (not shown in UI):\")\n            for field in sorted(excess):\n                print(f\"  - {field}\")\n```\n\n### Step 4: Test User Object Exposure in Related Endpoints\n\n```python\n# Many APIs embed full user objects in responses for orders, comments, etc.\nendpoints_with_user_objects = [\n    \"\u002Forders\",          # Each order may include full seller\u002Fbuyer profile\n    \"\u002Fcomments\",        # Comments may include full author profile\n    \"\u002Freviews\",         # Reviews may expose reviewer details\n    \"\u002Ftransactions\",    # Transactions may include counterparty info\n    \"\u002Fteam\u002Fmembers\",    # Team listing may expose excessive member data\n]\n\nfor path in endpoints_with_user_objects:\n    resp = requests.get(f\"{BASE_URL}{path}\", headers=headers)\n    if resp.status_code == 200:\n        text = resp.text\n        # Check for user data leakage in nested objects\n        user_fields_found = []\n        for field in [\"password_hash\", \"last_login_ip\", \"mfa_enabled\", \"phone_number\",\n                      \"date_of_birth\", \"ssn\", \"internal_notes\", \"salary\", \"address\"]:\n            if f'\"{field}\"' in text:\n                user_fields_found.append(field)\n        if user_fields_found:\n            print(f\"[EXCESSIVE] {path} exposes user fields: {user_fields_found}\")\n```\n\n### Step 5: GraphQL Over-Fetching Analysis\n\n```python\n# GraphQL allows clients to request any available field\nGRAPHQL_URL = f\"{BASE_URL}\u002Fgraphql\"\n\n# Introspection query to discover all fields on User type\nintrospection = {\n    \"query\": \"\"\"\n    {\n      __type(name: \"User\") {\n        fields {\n          name\n          type {\n            name\n            kind\n          }\n        }\n      }\n    }\n    \"\"\"\n}\n\nresp = requests.post(GRAPHQL_URL, headers=headers, json=introspection)\nif resp.status_code == 200:\n    fields = resp.json().get(\"data\", {}).get(\"__type\", {}).get(\"fields\", [])\n    print(\"Available User fields via GraphQL:\")\n    for f in fields:\n        sensitivity = \"SENSITIVE\" if f[\"name\"] in SENSITIVE_FIELD_NAMES else \"normal\"\n        print(f\"  {f['name']} ({f['type']['name']}) [{sensitivity}]\")\n\n# Try to query sensitive fields\nsensitive_query = {\n    \"query\": \"\"\"\n    query {\n      users {\n        id\n        email\n        passwordHash\n        socialSecurityNumber\n        internalNotes\n        lastLoginIp\n        mfaSecret\n        apiKey\n      }\n    }\n    \"\"\"\n}\nresp = requests.post(GRAPHQL_URL, headers=headers, json=sensitive_query)\nif resp.status_code == 200 and \"errors\" not in resp.json():\n    print(\"[CRITICAL] GraphQL exposes sensitive user fields without restriction\")\n```\n\n### Step 6: Debug and Internal Data Leakage\n\n```python\n# Test for debug information in responses\ndebug_headers_to_check = [\n    \"X-Debug-Token\", \"X-Debug-Info\", \"Server\", \"X-Powered-By\",\n    \"X-Request-Id\", \"X-Correlation-Id\", \"X-Backend-Server\",\n    \"X-Runtime\", \"X-Version\", \"X-Build-Version\"\n]\n\nresp = requests.get(f\"{BASE_URL}\u002Fusers\u002Fme\", headers=headers)\nfor h in debug_headers_to_check:\n    if h.lower() in {k.lower(): v for k, v in resp.headers.items()}:\n        print(f\"[INFO LEAK] Header {h}: {resp.headers.get(h)}\")\n\n# Test error responses for stack traces\nerror_payloads = [\n    (\"GET\", \"\u002Fusers\u002Finvalid-id-format\", None),\n    (\"POST\", \"\u002Forders\", {\"invalid\": \"payload\"}),\n    (\"GET\", \"\u002Fusers\u002F-1\", None),\n    (\"GET\", \"\u002Fusers\u002F0\", None),\n]\n\nfor method, path, body in error_payloads:\n    resp = requests.request(method, f\"{BASE_URL}{path}\", headers=headers, json=body)\n    if resp.status_code >= 400:\n        text = resp.text.lower()\n        if any(kw in text for kw in [\"stack trace\", \"traceback\", \"at com.\", \"at org.\",\n                                      \"file \\\"\", \"line \", \"exception\", \"sql\", \"query\"]):\n            print(f\"[DEBUG LEAK] {method} {path} -> {resp.status_code}: Contains stack trace or query info\")\n```\n\n## Key Concepts\n\n| Term | Definition |\n|------|------------|\n| **Excessive Data Exposure** | API returns more data fields than the client needs, relying on frontend filtering to hide sensitive information from users |\n| **Over-Fetching** | Requesting or receiving more data than needed for a specific operation, common in REST APIs that return fixed response schemas |\n| **Response Filtering** | Client-side filtering of API response data to display only relevant fields, which provides zero security since the full response is interceptable |\n| **Object Property Level Authorization** | OWASP API3:2023 - ensuring that users can only read\u002Fwrite object properties they are authorized to access |\n| **PII Leakage** | Unintended exposure of Personally Identifiable Information in API responses including names, emails, addresses, SSNs, or financial data |\n| **Schema Validation** | Enforcing that API responses conform to a defined schema, stripping unauthorized fields before transmission |\n\n## Tools & Systems\n\n- **Burp Suite Professional**: Intercept API responses and use the Comparer tool to diff expected vs actual response schemas\n- **mitmproxy**: Scriptable proxy for automated response analysis with Python-based content inspection scripts\n- **OWASP ZAP**: Passive scanner detects information disclosure in headers, error messages, and response bodies\n- **Postman**: Compare documented response schemas against actual API responses using test scripts\n- **jq**: Command-line JSON processor for extracting and analyzing specific fields from API responses\n\n## Common Scenarios\n\n### Scenario: Mobile Banking API Data Exposure Assessment\n\n**Context**: A mobile banking application's API returns full account objects to the mobile client, which only displays account nickname and balance. The API is accessed by both iOS and Android apps and a web portal.\n\n**Approach**:\n1. Configure mitmproxy on a test device and authenticate as the test user\n2. Capture all API responses during a complete user session (login, view accounts, transfer, logout)\n3. Analyze `GET \u002Fapi\u002Fv1\u002Faccounts` response: UI shows 4 fields but API returns 23 fields\n4. Discover that the API returns `routing_number`, `account_holder_ssn_last4`, `internal_risk_score`, `kyc_verification_status`, and `linked_external_accounts` - none shown in UI\n5. Analyze `GET \u002Fapi\u002Fv1\u002Ftransactions` response: API returns `merchant_id`, `terminal_id`, `authorization_code`, `processor_response` fields not needed by the client\n6. Check `GET \u002Fapi\u002Fv1\u002Fusers\u002Fme`: API returns `last_login_ip`, `mfa_backup_codes_remaining`, `account_officer_name`, and `credit_score_band`\n7. Test error responses: `POST \u002Fapi\u002Fv1\u002Ftransfers` with invalid payload returns SQL table name in error message\n\n**Pitfalls**:\n- Only checking top-level fields and missing sensitive data in deeply nested objects\n- Not testing paginated responses where subsequent pages may include different fields\n- Ignoring response headers that may leak server version, backend technology, or internal routing information\n- Missing data exposure in error responses which often contain stack traces, SQL queries, or internal paths\n- Assuming that HTTPS encryption prevents data exposure (it protects in transit, not from the authenticated client)\n\n## Output Format\n\n```\n## Finding: Excessive Data Exposure in Account and Transaction APIs\n\n**ID**: API-DATA-001\n**Severity**: High (CVSS 7.1)\n**OWASP API**: API3:2023 - Broken Object Property Level Authorization\n**Affected Endpoints**:\n  - GET \u002Fapi\u002Fv1\u002Faccounts\n  - GET \u002Fapi\u002Fv1\u002Ftransactions\n  - GET \u002Fapi\u002Fv1\u002Fusers\u002Fme\n\n**Description**:\nThe API returns full database objects to the client, including sensitive fields\nthat are not displayed in the mobile application UI. The mobile app filters\nthese fields client-side, but they are fully accessible by intercepting the\nAPI response. This exposes SSN fragments, internal risk scores, and KYC\nverification data for any authenticated user.\n\n**Excess Fields Discovered**:\n- \u002Faccounts: routing_number, account_holder_ssn_last4, internal_risk_score,\n  kyc_verification_status, linked_external_accounts (18 excess fields total)\n- \u002Ftransactions: merchant_id, terminal_id, authorization_code,\n  processor_response (12 excess fields total)\n- \u002Fusers\u002Fme: last_login_ip, mfa_backup_codes_remaining, credit_score_band\n\n**Impact**:\nAn authenticated user can extract sensitive financial data, internal risk\nassessments, and PII for their own account that the application is not\nintended to reveal. Combined with BOLA vulnerabilities, this data could\nbe extracted for all users.\n\n**Remediation**:\n1. Implement server-side response filtering using DTOs\u002Fview models that only include fields needed by the client\n2. Use GraphQL field-level authorization or REST response schemas per endpoint per role\n3. Remove sensitive fields from API responses at the serialization layer\n4. Implement response schema validation in the API gateway to strip undocumented fields\n5. Add automated tests that verify response schemas match documentation\n```\n",{"name":5,"tags":24,"author":30,"domain":31,"license":15,"version":32,"nist_csf":33,"subdomain":25,"description":7,"mitre_attack":38},[25,26,27,28,29],"api-security","owasp","data-exposure","rest-security","pii-leakage","mahipal","cybersecurity","1.0.0",[34,35,36,37],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[39,40,41,42,43],"T1190","T1059.007","T1552.001","T1027","T1070","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","04-安全渗透\u002Fexploiting-excessive-data-exposure-in-api",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":53,"prompt":63,"zipAvailable":64},[54,57,60],{"tool":55,"command":56},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill exploiting-excessive-data-exposure-in-api",{"tool":58,"command":59},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill exploiting-excessive-data-exposure-in-api",{"tool":61,"command":62},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill exploiting-excessive-data-exposure-in-api","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fexploiting-excessive-data-exposure-in-api\u002FSKILL.md",true,[66],{"path":67,"resourceType":68,"resourceTypeDesc":69,"sizeBytes":70,"sourceHtmlUrl":71},"references\u002Fapi-reference.md","REFERENCE","参考文档",2231,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fexploiting-excessive-data-exposure-in-api\u002Freferences\u002Fapi-reference.md",[73,82,87,94,101,108],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":81},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":83,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":81},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":81},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":81},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":81},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":77,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":81},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]