[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M71GRF7NZQC0PAMRSHDP40H4":3,"skill-same:01M71GRF7NZQC0PAMRSHDP40H4":101},{"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":28,"publishedAt":49,"linkOnly":50,"markdownContent":51,"markdownBody":52,"frontMatter":53,"refName":74,"commitSha":75,"skillDirectory":76,"forksCount":14,"repositoryHtmlUrl":77,"repositoryHomepageUrl":6,"ownerHtmlUrl":78,"ownerBlogUrl":6,"ownerDescription":79,"updatedAt":80,"install":81,"resources":94},"01M71GRF7NZQC0PAMRSHDP40H4","api-shadow-enum",null,"Discover and inventory shadow API endpoints that operate outside documented specifications using traffic analysis, code scanning, and API discovery platforms.","DCx7C5\u002Fai-marketplace","DCx7C5","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F42419559?v=4","01M71C01G2AZV3NTNGWAWSHJPP","DC","01M71C01GQW6G50S2BYMS7PP3E",0,"MIT","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fweb-application\u002Fapi\u002Fshadow\u002Fenum\u002FSKILL.md",[18,23],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48],"api shadow enum","enum","Shadow","api","Bash","traffic","operate","de","discover","cm","scanning","cybersecurity","inventory","analysis","undocumented-apis","api-discovery","shadow-apis","attack-surface","api-security","code","2026-11-10 10:12:30",false,"---\nname: api-shadow-enum\ndescription: Discover and inventory shadow API endpoints that operate outside documented specifications using traffic analysis, code scanning, and API discovery platforms.\ndomain: cybersecurity\nsubdomain: api-security\ntags:\n- api-security\n- shadow-apis\n- api-discovery\n- undocumented-apis\n- zombie-apis\n- api-inventory\n- attack-surface-management\n- api-governance\nnist_csf:\n- PR.PS-01\n- ID.RA-01\n- PR.DS-10\n- DE.CM-01\nmodel: sonnet\nmaxTurns: 20\ntools: [Read, Bash, Glob, Grep]\nmitre_attack:\n- T1082\n- T1595\ncapec: []\n---\n\n# Detecting Shadow API Endpoints\n\n## Overview\n\nShadow APIs are API endpoints operating within an organization's environment that are not tracked, documented, or secured. They emerge from rapid development cycles, forgotten test environments, deprecated API versions left running, third-party integrations, or developer side projects deployed without governance. Shadow APIs bypass authentication and monitoring controls, creating hidden entry points for attackers. Studies show that up to 30% of API endpoints in large organizations are undocumented, making shadow API detection a critical component of API security posture management.\n\n\n## When to Use\n\n- When investigating security incidents that require detecting shadow api endpoints\n- When building detection rules or threat hunting queries for this domain\n- When SOC analysts need structured procedures for this analysis type\n- When validating security monitoring coverage for related attack techniques\n\n## Prerequisites\n\n- API gateway or reverse proxy with traffic logging (Kong, AWS API Gateway, Envoy)\n- Network traffic capture capability (packet broker, port mirroring)\n- Access to source code repositories and CI\u002FCD pipeline configurations\n- Cloud provider access for configuration scanning (AWS, GCP, Azure)\n- API documentation inventory (OpenAPI specs, Swagger docs)\n- Python 3.8+ for custom discovery tooling\n\n## Detection Methods\n\n### 1. Traffic Analysis and Comparison\n\nCompare live API traffic against documented OpenAPI specifications to identify undocumented endpoints:\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"Shadow API Endpoint Detector\n\nCompares observed API traffic patterns against documented\nOpenAPI specifications to identify undocumented (shadow) endpoints.\n\"\"\"\n\nimport json\nimport re\nimport yaml\nimport sys\nfrom collections import defaultdict\nfrom datetime import datetime\nfrom typing import Dict, List, Set, Tuple, Optional\nfrom dataclasses import dataclass, field\n\n@dataclass\nclass DiscoveredEndpoint:\n    method: str\n    path_pattern: str\n    first_seen: str\n    last_seen: str\n    request_count: int\n    source_ips: Set[str] = field(default_factory=set)\n    status_codes: Set[int] = field(default_factory=set)\n    has_auth_header: bool = False\n    documented: bool = False\n\nclass ShadowAPIDetector:\n    # Common patterns for parameterized path segments\n    PARAM_PATTERNS = [\n        (re.compile(r'\u002F\\d+'), '\u002F{id}'),\n        (re.compile(r'\u002F[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'), '\u002F{uuid}'),\n        (re.compile(r'\u002F[a-zA-Z0-9]{20,40}'), '\u002F{token}'),\n    ]\n\n    def __init__(self):\n        self.documented_endpoints: Set[Tuple[str, str]] = set()\n        self.discovered_endpoints: Dict[Tuple[str, str], DiscoveredEndpoint] = {}\n\n    def load_openapi_spec(self, spec_path: str):\n        \"\"\"Load documented endpoints from OpenAPI specification.\"\"\"\n        with open(spec_path, 'r') as f:\n            if spec_path.endswith('.json'):\n                spec = json.load(f)\n            else:\n                spec = yaml.safe_load(f)\n\n        paths = spec.get('paths', {})\n        for path, methods in paths.items():\n            # Normalize OpenAPI path parameters\n            normalized_path = re.sub(r'\\{[^}]+\\}', '{id}', path)\n            for method in methods:\n                if method.upper() in ('GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'):\n                    self.documented_endpoints.add((method.upper(), normalized_path))\n\n        print(f\"Loaded {len(self.documented_endpoints)} documented endpoints from {spec_path}\")\n\n    def normalize_path(self, path: str) -> str:\n        \"\"\"Normalize an observed path by replacing dynamic segments with placeholders.\"\"\"\n        # Remove query string\n        path = path.split('?')[0]\n\n        for pattern, replacement in self.PARAM_PATTERNS:\n            path = pattern.sub(replacement, path)\n\n        return path\n\n    def process_access_log(self, log_file: str, log_format: str = \"common\"):\n        \"\"\"Process API access logs to discover endpoints.\"\"\"\n        patterns = {\n            \"common\": re.compile(\n                r'(?P\u003Cip>[\\d.]+)\\s+\\S+\\s+\\S+\\s+\\[(?P\u003Ctime>[^\\]]+)\\]\\s+'\n                r'\"(?P\u003Cmethod>\\w+)\\s+(?P\u003Cpath>\\S+)\\s+\\S+\"\\s+(?P\u003Cstatus>\\d+)'\n            ),\n            \"json\": None  # Handle JSON logs separately\n        }\n\n        with open(log_file, 'r') as f:\n            for line in f:\n                if log_format == \"json\":\n                    try:\n                        entry = json.loads(line)\n                        method = entry.get('method', entry.get('http_method', ''))\n                        path = entry.get('path', entry.get('uri', ''))\n                        status = int(entry.get('status', entry.get('status_code', 0)))\n                        ip = entry.get('remote_addr', entry.get('client_ip', ''))\n                        timestamp = entry.get('timestamp', entry.get('@timestamp', ''))\n                        has_auth = bool(entry.get('authorization', entry.get('auth_header', '')))\n                    except json.JSONDecodeError:\n                        continue\n                else:\n                    match = patterns[log_format].match(line)\n                    if not match:\n                        continue\n                    method = match.group('method')\n                    path = match.group('path')\n                    status = int(match.group('status'))\n                    ip = match.group('ip')\n                    timestamp = match.group('time')\n                    has_auth = 'Authorization' in line\n\n                # Only process API paths\n                if not path.startswith('\u002Fapi') and not path.startswith('\u002Fv'):\n                    continue\n\n                normalized = self.normalize_path(path)\n                key = (method.upper(), normalized)\n\n                if key not in self.discovered_endpoints:\n                    self.discovered_endpoints[key] = DiscoveredEndpoint(\n                        method=method.upper(),\n                        path_pattern=normalized,\n                        first_seen=timestamp,\n                        last_seen=timestamp,\n                        request_count=0,\n                        documented=(key in self.documented_endpoints)\n                    )\n\n                endpoint = self.discovered_endpoints[key]\n                endpoint.request_count += 1\n                endpoint.last_seen = timestamp\n                endpoint.source_ips.add(ip)\n                endpoint.status_codes.add(status)\n                if has_auth:\n                    endpoint.has_auth_header = True\n\n    def identify_shadow_apis(self) -> List[DiscoveredEndpoint]:\n        \"\"\"Identify endpoints that are not in the documented specification.\"\"\"\n        shadows = []\n        for key, endpoint in self.discovered_endpoints.items():\n            if not endpoint.documented:\n                shadows.append(endpoint)\n\n        # Sort by request count descending (most active shadows first)\n        shadows.sort(key=lambda e: e.request_count, reverse=True)\n        return shadows\n\n    def classify_risk(self, endpoint: DiscoveredEndpoint) -> str:\n        \"\"\"Classify the risk level of a shadow endpoint.\"\"\"\n        risk_score = 0\n\n        # No authentication observed\n        if not endpoint.has_auth_header:\n            risk_score += 3\n\n        # High traffic volume\n        if endpoint.request_count > 1000:\n            risk_score += 2\n        elif endpoint.request_count > 100:\n            risk_score += 1\n\n        # Multiple source IPs (wider exposure)\n        if len(endpoint.source_ips) > 10:\n            risk_score += 2\n\n        # Successful responses (endpoint is functional)\n        if 200 in endpoint.status_codes or 201 in endpoint.status_codes:\n            risk_score += 1\n\n        # Write operations are higher risk\n        if endpoint.method in ('POST', 'PUT', 'DELETE', 'PATCH'):\n            risk_score += 2\n\n        # Sensitive path patterns\n        sensitive_patterns = ['admin', 'internal', 'debug', 'test', 'backup',\n                            'config', 'health', 'metrics', 'graphql', 'console']\n        for pattern in sensitive_patterns:\n            if pattern in endpoint.path_pattern.lower():\n                risk_score += 3\n                break\n\n        if risk_score >= 8:\n            return \"CRITICAL\"\n        elif risk_score >= 5:\n            return \"HIGH\"\n        elif risk_score >= 3:\n            return \"MEDIUM\"\n        return \"LOW\"\n\n    def generate_report(self) -> dict:\n        \"\"\"Generate a comprehensive shadow API discovery report.\"\"\"\n        shadows = self.identify_shadow_apis()\n        total_documented = len(self.documented_endpoints)\n        total_discovered = len(self.discovered_endpoints)\n\n        report = {\n            \"scan_date\": datetime.now().isoformat(),\n            \"summary\": {\n                \"documented_endpoints\": total_documented,\n                \"total_discovered_endpoints\": total_discovered,\n                \"shadow_endpoints\": len(shadows),\n                \"shadow_ratio\": f\"{len(shadows)\u002Fmax(total_discovered,1)*100:.1f}%\",\n            },\n            \"shadow_endpoints\": []\n        }\n\n        for endpoint in shadows:\n            risk = self.classify_risk(endpoint)\n            report[\"shadow_endpoints\"].append({\n                \"method\": endpoint.method,\n                \"path\": endpoint.path_pattern,\n                \"risk_level\": risk,\n                \"request_count\": endpoint.request_count,\n                \"unique_sources\": len(endpoint.source_ips),\n                \"authenticated\": endpoint.has_auth_header,\n                \"status_codes\": sorted(endpoint.status_codes),\n                \"first_seen\": endpoint.first_seen,\n                \"last_seen\": endpoint.last_seen,\n            })\n\n        return report\n\n\ndef main():\n    detector = ShadowAPIDetector()\n\n    # Load documented API specifications\n    spec_files = sys.argv[1:] if len(sys.argv) > 1 else [\"openapi.yaml\"]\n    for spec in spec_files:\n        if spec.endswith(('.yaml', '.yml', '.json')):\n            detector.load_openapi_spec(spec)\n\n    # Process access logs\n    detector.process_access_log(\"\u002Fvar\u002Flog\u002Fapi\u002Faccess.log\")\n\n    report = detector.generate_report()\n\n    print(f\"\\n{'='*60}\")\n    print(f\"SHADOW API DISCOVERY REPORT\")\n    print(f\"{'='*60}\")\n    print(f\"Documented: {report['summary']['documented_endpoints']}\")\n    print(f\"Discovered: {report['summary']['total_discovered_endpoints']}\")\n    print(f\"Shadow: {report['summary']['shadow_endpoints']} ({report['summary']['shadow_ratio']})\")\n    print()\n\n    for ep in report[\"shadow_endpoints\"]:\n        risk_marker = {\"CRITICAL\": \"[!!!]\", \"HIGH\": \"[!!]\", \"MEDIUM\": \"[!]\", \"LOW\": \"[.]\"}\n        print(f\"  {risk_marker.get(ep['risk_level'], '[?]')} {ep['method']} {ep['path']}\")\n        print(f\"      Risk: {ep['risk_level']} | Requests: {ep['request_count']} | Auth: {ep['authenticated']}\")\n\n    # Save full report\n    with open(\"shadow_api_report.json\", \"w\") as f:\n        json.dump(report, f, indent=2, default=str)\n    print(f\"\\nFull report saved to shadow_api_report.json\")\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### 2. Cloud Configuration Scanning\n\n```bash\n# AWS: Discover API Gateway endpoints not in documentation\naws apigateway get-rest-apis --query 'items[*].[name,id]' --output table\n\n# List all routes for each API\naws apigatewayv2 get-apis --query 'Items[*].[Name,ApiId,ProtocolType]' --output table\n\n# AWS Lambda function URLs (potential shadow APIs)\naws lambda list-function-url-configs --function-name \"*\" 2>\u002Fdev\u002Fnull\n\n# Find ALB listener rules routing to undocumented backends\naws elbv2 describe-rules --listener-arn $LISTENER_ARN \\\n  --query 'Rules[*].[Priority,Conditions[0].Values[0],Actions[0].TargetGroupArn]'\n```\n\n### 3. Source Code Repository Mining\n\n```bash\n# Search for undocumented route definitions in source code\n# Express.js routes\ngrep -rn \"app\\.\\(get\\|post\\|put\\|delete\\|patch\\)\" --include=\"*.js\" --include=\"*.ts\" src\u002F\n\n# Flask\u002FDjango routes\ngrep -rn \"@app\\.route\\|@api\\.route\\|path(\" --include=\"*.py\" src\u002F\n\n# Spring Boot endpoints\ngrep -rn \"@\\(Get\\|Post\\|Put\\|Delete\\|Patch\\)Mapping\\|@RequestMapping\" --include=\"*.java\" src\u002F\n\n# Compare found routes against OpenAPI specification\ndiff \u003C(grep -roh \"'\u002Fapi\u002F[^']*'\" src\u002F | sort -u) \\\n     \u003C(yq '.paths | keys[]' openapi.yaml | sort -u)\n```\n\n## Prevention and Governance\n\n### API Registration Gateway Policy\n\n```yaml\n# Kong plugin configuration - reject unregistered routes\nplugins:\n  - name: request-validator\n    config:\n      allowed_content_types:\n        - application\u002Fjson\n      body_schema: null\n  - name: pre-function\n    config:\n      access:\n        - |\n          -- Block requests to unregistered endpoints\n          local registered = kong.cache:get(\"registered_endpoints\")\n          local path = kong.request.get_path()\n          local method = kong.request.get_method()\n          local key = method .. \":\" .. path\n          if not registered[key] then\n            kong.log.warn(\"Shadow API access attempt: \", key)\n            return kong.response.exit(404, {error = \"Endpoint not registered\"})\n          end\n```\n\n## References\n\n- APIsec Shadow API Best Practices: https:\u002F\u002Fwww.apisec.ai\u002Fblog\u002Fsecure-your-shadow-apis-best-practices-for-api-discovery\n- Wiz Shadow API Guide: https:\u002F\u002Fwww.wiz.io\u002Facademy\u002Fapi-security\u002Fshadow-api\n- Checkmarx Shadow and Zombie APIs: https:\u002F\u002Fcheckmarx.com\u002Flearn\u002Fapi-security\u002Fshadow-zombie-apis-undocumented-api-vulnerabilities-threaten-security-posture\u002F\n- Treblle Shadow API Tools: https:\u002F\u002Ftreblle.com\u002Fblog\u002Ftop-tools-for-detecting-shadow-apis-and-how-treblle-differs\n- SecureLayer7 Shadow APIs: https:\u002F\u002Fblog.securelayer7.net\u002Fshadow-apis-explained-risks-detection-and-prevention\u002F\n","# Detecting Shadow API Endpoints\n\n## Overview\n\nShadow APIs are API endpoints operating within an organization's environment that are not tracked, documented, or secured. They emerge from rapid development cycles, forgotten test environments, deprecated API versions left running, third-party integrations, or developer side projects deployed without governance. Shadow APIs bypass authentication and monitoring controls, creating hidden entry points for attackers. Studies show that up to 30% of API endpoints in large organizations are undocumented, making shadow API detection a critical component of API security posture management.\n\n\n## When to Use\n\n- When investigating security incidents that require detecting shadow api endpoints\n- When building detection rules or threat hunting queries for this domain\n- When SOC analysts need structured procedures for this analysis type\n- When validating security monitoring coverage for related attack techniques\n\n## Prerequisites\n\n- API gateway or reverse proxy with traffic logging (Kong, AWS API Gateway, Envoy)\n- Network traffic capture capability (packet broker, port mirroring)\n- Access to source code repositories and CI\u002FCD pipeline configurations\n- Cloud provider access for configuration scanning (AWS, GCP, Azure)\n- API documentation inventory (OpenAPI specs, Swagger docs)\n- Python 3.8+ for custom discovery tooling\n\n## Detection Methods\n\n### 1. Traffic Analysis and Comparison\n\nCompare live API traffic against documented OpenAPI specifications to identify undocumented endpoints:\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"Shadow API Endpoint Detector\n\nCompares observed API traffic patterns against documented\nOpenAPI specifications to identify undocumented (shadow) endpoints.\n\"\"\"\n\nimport json\nimport re\nimport yaml\nimport sys\nfrom collections import defaultdict\nfrom datetime import datetime\nfrom typing import Dict, List, Set, Tuple, Optional\nfrom dataclasses import dataclass, field\n\n@dataclass\nclass DiscoveredEndpoint:\n    method: str\n    path_pattern: str\n    first_seen: str\n    last_seen: str\n    request_count: int\n    source_ips: Set[str] = field(default_factory=set)\n    status_codes: Set[int] = field(default_factory=set)\n    has_auth_header: bool = False\n    documented: bool = False\n\nclass ShadowAPIDetector:\n    # Common patterns for parameterized path segments\n    PARAM_PATTERNS = [\n        (re.compile(r'\u002F\\d+'), '\u002F{id}'),\n        (re.compile(r'\u002F[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'), '\u002F{uuid}'),\n        (re.compile(r'\u002F[a-zA-Z0-9]{20,40}'), '\u002F{token}'),\n    ]\n\n    def __init__(self):\n        self.documented_endpoints: Set[Tuple[str, str]] = set()\n        self.discovered_endpoints: Dict[Tuple[str, str], DiscoveredEndpoint] = {}\n\n    def load_openapi_spec(self, spec_path: str):\n        \"\"\"Load documented endpoints from OpenAPI specification.\"\"\"\n        with open(spec_path, 'r') as f:\n            if spec_path.endswith('.json'):\n                spec = json.load(f)\n            else:\n                spec = yaml.safe_load(f)\n\n        paths = spec.get('paths', {})\n        for path, methods in paths.items():\n            # Normalize OpenAPI path parameters\n            normalized_path = re.sub(r'\\{[^}]+\\}', '{id}', path)\n            for method in methods:\n                if method.upper() in ('GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'):\n                    self.documented_endpoints.add((method.upper(), normalized_path))\n\n        print(f\"Loaded {len(self.documented_endpoints)} documented endpoints from {spec_path}\")\n\n    def normalize_path(self, path: str) -> str:\n        \"\"\"Normalize an observed path by replacing dynamic segments with placeholders.\"\"\"\n        # Remove query string\n        path = path.split('?')[0]\n\n        for pattern, replacement in self.PARAM_PATTERNS:\n            path = pattern.sub(replacement, path)\n\n        return path\n\n    def process_access_log(self, log_file: str, log_format: str = \"common\"):\n        \"\"\"Process API access logs to discover endpoints.\"\"\"\n        patterns = {\n            \"common\": re.compile(\n                r'(?P\u003Cip>[\\d.]+)\\s+\\S+\\s+\\S+\\s+\\[(?P\u003Ctime>[^\\]]+)\\]\\s+'\n                r'\"(?P\u003Cmethod>\\w+)\\s+(?P\u003Cpath>\\S+)\\s+\\S+\"\\s+(?P\u003Cstatus>\\d+)'\n            ),\n            \"json\": None  # Handle JSON logs separately\n        }\n\n        with open(log_file, 'r') as f:\n            for line in f:\n                if log_format == \"json\":\n                    try:\n                        entry = json.loads(line)\n                        method = entry.get('method', entry.get('http_method', ''))\n                        path = entry.get('path', entry.get('uri', ''))\n                        status = int(entry.get('status', entry.get('status_code', 0)))\n                        ip = entry.get('remote_addr', entry.get('client_ip', ''))\n                        timestamp = entry.get('timestamp', entry.get('@timestamp', ''))\n                        has_auth = bool(entry.get('authorization', entry.get('auth_header', '')))\n                    except json.JSONDecodeError:\n                        continue\n                else:\n                    match = patterns[log_format].match(line)\n                    if not match:\n                        continue\n                    method = match.group('method')\n                    path = match.group('path')\n                    status = int(match.group('status'))\n                    ip = match.group('ip')\n                    timestamp = match.group('time')\n                    has_auth = 'Authorization' in line\n\n                # Only process API paths\n                if not path.startswith('\u002Fapi') and not path.startswith('\u002Fv'):\n                    continue\n\n                normalized = self.normalize_path(path)\n                key = (method.upper(), normalized)\n\n                if key not in self.discovered_endpoints:\n                    self.discovered_endpoints[key] = DiscoveredEndpoint(\n                        method=method.upper(),\n                        path_pattern=normalized,\n                        first_seen=timestamp,\n                        last_seen=timestamp,\n                        request_count=0,\n                        documented=(key in self.documented_endpoints)\n                    )\n\n                endpoint = self.discovered_endpoints[key]\n                endpoint.request_count += 1\n                endpoint.last_seen = timestamp\n                endpoint.source_ips.add(ip)\n                endpoint.status_codes.add(status)\n                if has_auth:\n                    endpoint.has_auth_header = True\n\n    def identify_shadow_apis(self) -> List[DiscoveredEndpoint]:\n        \"\"\"Identify endpoints that are not in the documented specification.\"\"\"\n        shadows = []\n        for key, endpoint in self.discovered_endpoints.items():\n            if not endpoint.documented:\n                shadows.append(endpoint)\n\n        # Sort by request count descending (most active shadows first)\n        shadows.sort(key=lambda e: e.request_count, reverse=True)\n        return shadows\n\n    def classify_risk(self, endpoint: DiscoveredEndpoint) -> str:\n        \"\"\"Classify the risk level of a shadow endpoint.\"\"\"\n        risk_score = 0\n\n        # No authentication observed\n        if not endpoint.has_auth_header:\n            risk_score += 3\n\n        # High traffic volume\n        if endpoint.request_count > 1000:\n            risk_score += 2\n        elif endpoint.request_count > 100:\n            risk_score += 1\n\n        # Multiple source IPs (wider exposure)\n        if len(endpoint.source_ips) > 10:\n            risk_score += 2\n\n        # Successful responses (endpoint is functional)\n        if 200 in endpoint.status_codes or 201 in endpoint.status_codes:\n            risk_score += 1\n\n        # Write operations are higher risk\n        if endpoint.method in ('POST', 'PUT', 'DELETE', 'PATCH'):\n            risk_score += 2\n\n        # Sensitive path patterns\n        sensitive_patterns = ['admin', 'internal', 'debug', 'test', 'backup',\n                            'config', 'health', 'metrics', 'graphql', 'console']\n        for pattern in sensitive_patterns:\n            if pattern in endpoint.path_pattern.lower():\n                risk_score += 3\n                break\n\n        if risk_score >= 8:\n            return \"CRITICAL\"\n        elif risk_score >= 5:\n            return \"HIGH\"\n        elif risk_score >= 3:\n            return \"MEDIUM\"\n        return \"LOW\"\n\n    def generate_report(self) -> dict:\n        \"\"\"Generate a comprehensive shadow API discovery report.\"\"\"\n        shadows = self.identify_shadow_apis()\n        total_documented = len(self.documented_endpoints)\n        total_discovered = len(self.discovered_endpoints)\n\n        report = {\n            \"scan_date\": datetime.now().isoformat(),\n            \"summary\": {\n                \"documented_endpoints\": total_documented,\n                \"total_discovered_endpoints\": total_discovered,\n                \"shadow_endpoints\": len(shadows),\n                \"shadow_ratio\": f\"{len(shadows)\u002Fmax(total_discovered,1)*100:.1f}%\",\n            },\n            \"shadow_endpoints\": []\n        }\n\n        for endpoint in shadows:\n            risk = self.classify_risk(endpoint)\n            report[\"shadow_endpoints\"].append({\n                \"method\": endpoint.method,\n                \"path\": endpoint.path_pattern,\n                \"risk_level\": risk,\n                \"request_count\": endpoint.request_count,\n                \"unique_sources\": len(endpoint.source_ips),\n                \"authenticated\": endpoint.has_auth_header,\n                \"status_codes\": sorted(endpoint.status_codes),\n                \"first_seen\": endpoint.first_seen,\n                \"last_seen\": endpoint.last_seen,\n            })\n\n        return report\n\n\ndef main():\n    detector = ShadowAPIDetector()\n\n    # Load documented API specifications\n    spec_files = sys.argv[1:] if len(sys.argv) > 1 else [\"openapi.yaml\"]\n    for spec in spec_files:\n        if spec.endswith(('.yaml', '.yml', '.json')):\n            detector.load_openapi_spec(spec)\n\n    # Process access logs\n    detector.process_access_log(\"\u002Fvar\u002Flog\u002Fapi\u002Faccess.log\")\n\n    report = detector.generate_report()\n\n    print(f\"\\n{'='*60}\")\n    print(f\"SHADOW API DISCOVERY REPORT\")\n    print(f\"{'='*60}\")\n    print(f\"Documented: {report['summary']['documented_endpoints']}\")\n    print(f\"Discovered: {report['summary']['total_discovered_endpoints']}\")\n    print(f\"Shadow: {report['summary']['shadow_endpoints']} ({report['summary']['shadow_ratio']})\")\n    print()\n\n    for ep in report[\"shadow_endpoints\"]:\n        risk_marker = {\"CRITICAL\": \"[!!!]\", \"HIGH\": \"[!!]\", \"MEDIUM\": \"[!]\", \"LOW\": \"[.]\"}\n        print(f\"  {risk_marker.get(ep['risk_level'], '[?]')} {ep['method']} {ep['path']}\")\n        print(f\"      Risk: {ep['risk_level']} | Requests: {ep['request_count']} | Auth: {ep['authenticated']}\")\n\n    # Save full report\n    with open(\"shadow_api_report.json\", \"w\") as f:\n        json.dump(report, f, indent=2, default=str)\n    print(f\"\\nFull report saved to shadow_api_report.json\")\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n### 2. Cloud Configuration Scanning\n\n```bash\n# AWS: Discover API Gateway endpoints not in documentation\naws apigateway get-rest-apis --query 'items[*].[name,id]' --output table\n\n# List all routes for each API\naws apigatewayv2 get-apis --query 'Items[*].[Name,ApiId,ProtocolType]' --output table\n\n# AWS Lambda function URLs (potential shadow APIs)\naws lambda list-function-url-configs --function-name \"*\" 2>\u002Fdev\u002Fnull\n\n# Find ALB listener rules routing to undocumented backends\naws elbv2 describe-rules --listener-arn $LISTENER_ARN \\\n  --query 'Rules[*].[Priority,Conditions[0].Values[0],Actions[0].TargetGroupArn]'\n```\n\n### 3. Source Code Repository Mining\n\n```bash\n# Search for undocumented route definitions in source code\n# Express.js routes\ngrep -rn \"app\\.\\(get\\|post\\|put\\|delete\\|patch\\)\" --include=\"*.js\" --include=\"*.ts\" src\u002F\n\n# Flask\u002FDjango routes\ngrep -rn \"@app\\.route\\|@api\\.route\\|path(\" --include=\"*.py\" src\u002F\n\n# Spring Boot endpoints\ngrep -rn \"@\\(Get\\|Post\\|Put\\|Delete\\|Patch\\)Mapping\\|@RequestMapping\" --include=\"*.java\" src\u002F\n\n# Compare found routes against OpenAPI specification\ndiff \u003C(grep -roh \"'\u002Fapi\u002F[^']*'\" src\u002F | sort -u) \\\n     \u003C(yq '.paths | keys[]' openapi.yaml | sort -u)\n```\n\n## Prevention and Governance\n\n### API Registration Gateway Policy\n\n```yaml\n# Kong plugin configuration - reject unregistered routes\nplugins:\n  - name: request-validator\n    config:\n      allowed_content_types:\n        - application\u002Fjson\n      body_schema: null\n  - name: pre-function\n    config:\n      access:\n        - |\n          -- Block requests to unregistered endpoints\n          local registered = kong.cache:get(\"registered_endpoints\")\n          local path = kong.request.get_path()\n          local method = kong.request.get_method()\n          local key = method .. \":\" .. path\n          if not registered[key] then\n            kong.log.warn(\"Shadow API access attempt: \", key)\n            return kong.response.exit(404, {error = \"Endpoint not registered\"})\n          end\n```\n\n## References\n\n- APIsec Shadow API Best Practices: https:\u002F\u002Fwww.apisec.ai\u002Fblog\u002Fsecure-your-shadow-apis-best-practices-for-api-discovery\n- Wiz Shadow API Guide: https:\u002F\u002Fwww.wiz.io\u002Facademy\u002Fapi-security\u002Fshadow-api\n- Checkmarx Shadow and Zombie APIs: https:\u002F\u002Fcheckmarx.com\u002Flearn\u002Fapi-security\u002Fshadow-zombie-apis-undocumented-api-vulnerabilities-threaten-security-posture\u002F\n- Treblle Shadow API Tools: https:\u002F\u002Ftreblle.com\u002Fblog\u002Ftop-tools-for-detecting-shadow-apis-and-how-treblle-differs\n- SecureLayer7 Shadow APIs: https:\u002F\u002Fblog.securelayer7.net\u002Fshadow-apis-explained-risks-detection-and-prevention\u002F\n",{"name":5,"tags":54,"capec":59,"model":60,"tools":61,"domain":40,"maxTurns":65,"nist_csf":66,"subdomain":47,"description":7,"mitre_attack":71},[47,45,44,43,55,56,57,58],"zombie-apis","api-inventory","attack-surface-management","api-governance",[],"sonnet",[62,33,63,64],"Read","Glob","Grep",20,[67,68,69,70],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[72,73],"T1082","T1595","main","a91f1293287ffa9f4f1b8f486cd6e835a1568c84","skills\u002Fweb-application\u002Fapi\u002Fshadow\u002Fenum","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace","https:\u002F\u002Fgithub.com\u002FDCx7C5","#Python","2026-09-01 11:21:00",{"source":8,"skillName":5,"commands":82,"prompt":92,"zipAvailable":93},[83,86,89],{"tool":84,"command":85},"npx","npx skills add DCx7C5\u002Fai-marketplace --skill api-shadow-enum",{"tool":87,"command":88},"bunx","bunx skills add DCx7C5\u002Fai-marketplace --skill api-shadow-enum",{"tool":90,"command":91},"pnpm","pnpm dlx skills add DCx7C5\u002Fai-marketplace --skill api-shadow-enum","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fweb-application\u002Fapi\u002Fshadow\u002Fenum\u002FSKILL.md",true,[95],{"path":96,"resourceType":97,"resourceTypeDesc":98,"sizeBytes":99,"sourceHtmlUrl":100},"index.json","REFERENCE","参考文档",634,"https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fweb-application\u002Fapi\u002Fshadow\u002Fenum\u002Findex.json",[102,125,145,166,188,203],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":49},"01M71HAPZ01KQ30RKTB0FFSQ05","services-wmi-persistence-detect","Detect WMI event subscription persistence by enumerating ActiveScriptEventConsumer, CommandLineEventConsumer, and permanent subscriptions in the WMI repository.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fservices\u002Fwmi\u002Fpersistence\u002Fdetect\u002FSKILL.md",[],[109,110,111,112,113,36,38,114,115,116,117,118,119,120,121,122,123,40,124],"services","detect","services wmi persistence detect","wmi","persistence","process","activescript","event","subscriptions","commandline-consumer","repository","subscription","event-subscription","t1546.003","forensics","process-forensics",{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":129,"categories":130,"keywords":131,"publishedAt":49},"01M71HAK6JTTTS229T17WJMMCG","services-wmi-exec-exploit","Perform lateral movement across Windows networks using WMI-based remote execution techniques including Impacket wmiexec.py, CrackMapExec, and native WMI commands for stealthy post-exploitation during red team engagements.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fservices\u002Fwmi\u002Fexec\u002Fexploit\u002FSKILL.md",[],[132,109,133,112,134,135,34,40,33,42,136,137,138,139,36,140,141,142,143,144],"exploit","services wmi exec exploit","exec","remote","team","across","crackmapexec","native","command","lateral movement","read","lateral-movement","Impacket",{"skillNo":146,"name":147,"nameZh":6,"description":148,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":151,"publishedAt":49},"01M71HAG6MHKNQV8KDZKMT4886","registry-artifact-extract","Extract and analyze Windows Registry hives to uncover user activity, installed software, autostart entries, and evidence of system compromise.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fregistry\u002Fartifact\u002Fextract\u002FSKILL.md",[],[152,153,154,155,156,157,40,33,158,42,159,160,36,142,161,162,163,164,165,60],"artifact","registry","registry artifact extract","extract","evidence-collection","artifact-analysis","collection","analyze","uncover","software","activity","digital-forensics","windows-registry","regripper",{"skillNo":167,"name":168,"nameZh":6,"description":169,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":170,"categories":171,"keywords":172,"publishedAt":49},"01M71HACR4A8XTWTTSXK4124AA","processes-token-impersonate-detect","Detect Windows token impersonation and privilege abuse including SeImpersonatePrivilege exploitation via Potato attacks and token stealing techniques.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Ftoken\u002Fimpersonate\u002Fdetect\u002FSKILL.md",[],[110,173,174,175,176,177,178,38,179,40,124,180,181,182,183,184,185,186,187,36],"processes token impersonate detect","token","processes","attacks","windows","escalation","techniques","privilege-escalation","seimpersonate","token-impersonation","printspoofer","exploitation","potato","impersonation","via",{"skillNo":189,"name":190,"nameZh":6,"description":191,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":192,"categories":193,"keywords":194,"publishedAt":49},"01M71HAABSB4Z6QFSXEG00R4RK","processes-thread-injection-detect","Detect Windows thread injection techniques including CreateRemoteThread, QueueUserAPC, NtCreateThreadEx, and thread hijacking via process memory analysis.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Fthread\u002Finjection\u002Fdetect\u002FSKILL.md",[],[195,196,110,197,175,177,198,38,199,179,40,124,42,32,200,201,202,187,36,114],"thread","processes thread injection detect","injection","memory","process-injection","apc-injection","thread-injection","nt-api",{"skillNo":204,"name":205,"nameZh":6,"description":206,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":207,"categories":208,"keywords":209,"publishedAt":49},"01M71HA7H311V5G14WMX58HQSS","processes-hollow-technique-detect","Detect process hollowing (RunPE) by identifying processes with mismatched image paths between PEB and VAD tree, or unmapped PE headers in memory.","https:\u002F\u002Fgithub.com\u002FDCx7C5\u002Fai-marketplace\u002Fblob\u002Fmain\u002Fskills\u002Fwindows\u002Fprocesses\u002Fhollow\u002Ftechnique\u002Fdetect\u002FSKILL.md",[],[210,110,175,211,198,38,212,213,40,124,214,215,216,217,218,219,36,114,220,221],"processes hollow technique detect","tree","memory-forensics","process-hollow","peb","runpe","image","pe-header","in memory","with","mismatched","headers"]