[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6ETREAFF16MATK5PS8VQ0D2":3,"skill-same:01M6ETREAFF16MATK5PS8VQ0D2":99},{"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":60,"commitSha":61,"skillDirectory":62,"forksCount":63,"repositoryHtmlUrl":64,"repositoryHomepageUrl":6,"ownerHtmlUrl":65,"ownerBlogUrl":6,"ownerDescription":66,"updatedAt":67,"install":68,"resources":81},"01M6ETREAFF16MATK5PS8VQ0D2","detecting-shadow-api-endpoints",null,"Discover and inventory shadow API endpoints that operate outside documented specifications using traffic analysis, code scanning, and API discovery platforms.","luokai0\u002Fai-agent-skills-by-luo-kai","luokai0","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F266954973?v=4","01M6E16VNT42JB8B3X3254QWJ7","luo kai","01M6E16VTFVP6S5XJF1V1MPV90",14,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fdetecting-shadow-api-endpoints\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],"detecting","endpoints","Shadow","api","detecting shadow api endpoints","analysis","specifications","discover","scanning","discovery","inventory","cybersecurity","zombie-apis","undocumented-apis","api-discovery","shadow-apis","attack-surface","api-security","code","governance","2026-11-10 10:12:30",false,"---\nname: detecting-shadow-api-endpoints\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: [api-security, shadow-apis, api-discovery, undocumented-apis, zombie-apis, api-inventory, attack-surface-management, api-governance]\nversion: \"1.0\"\nauthor: mahipal\nlicense: Apache-2.0\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,"author":58,"domain":40,"license":15,"version":59,"subdomain":46,"description":7},[46,44,43,42,41,55,56,57],"api-inventory","attack-surface-management","api-governance","mahipal","1.0","main","4d2fb89cdfb75f3f6fd3c6c5ec9ad90ea129eb3c","ai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fdetecting-shadow-api-endpoints",1,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai","https:\u002F\u002Fgithub.com\u002Fluokai0","a solo builder.","2026-05-06 04:29:04",{"source":8,"skillName":5,"commands":69,"prompt":79,"zipAvailable":80},[70,73,76],{"tool":71,"command":72},"npx","npx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill detecting-shadow-api-endpoints",{"tool":74,"command":75},"bunx","bunx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill detecting-shadow-api-endpoints",{"tool":77,"command":78},"pnpm","pnpm dlx skills add luokai0\u002Fai-agent-skills-by-luo-kai --skill detecting-shadow-api-endpoints","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fdetecting-shadow-api-endpoints\u002FSKILL.md",true,[82,87,93],{"path":83,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fdetecting-shadow-api-endpoints\u002FLICENSE",{"path":88,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":91,"sourceHtmlUrl":92},"references\u002Fapi-reference.md","REFERENCE","参考文档",2212,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fdetecting-shadow-api-endpoints\u002Freferences\u002Fapi-reference.md",{"path":94,"resourceType":95,"resourceTypeDesc":96,"sizeBytes":97,"sourceHtmlUrl":98},"scripts\u002Fagent.py","SCRIPT","脚本",5723,"https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F21-external-registries\u002F08-pinkpixel-collection\u002Fdetecting-shadow-api-endpoints\u002Fscripts\u002Fagent.py",[100,128,145,172,205,234],{"skillNo":101,"name":102,"nameZh":6,"description":103,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":104,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":49},"01M6F2SKTE208174C7S7JJCZC7","write-contracts","Generates secure Aptos Move V2 smart contracts with Object model, Digital Asset integration, security patterns, and storage type guidance. Includes comprehensive storage decision framework for optimal data structure selection. Triggers on: 'write contract', 'create NFT collection', 'build marketplace', 'implement minting', 'generate Move module', 'create token contract', 'build DAO', 'implement staking'. Ask storage questions when: 'store', 'track', 'registry', 'mapping', 'list', 'collection'.","MIT","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fwrite-contracts\u002FSKILL.md",[],[108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127],"write","contracts","write contracts","storage","secure","create","generate","collection","model","decision","ask","smart-contracts","selection","objects","structure","nft","token","aptos","critical","move",{"skillNo":129,"name":130,"nameZh":6,"description":131,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":104,"licenseFileUrl":6,"sourceHtmlUrl":132,"categories":133,"keywords":134,"publishedAt":49},"01M6F2RFXJ6T9MKW0A7N7GM45B","web-search","通用网络搜索技能，支持多引擎搜索（百度、必应、DuckDuckGo），无需API密钥即可获取实时信息","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fweb-search-ex-skill\u002FSKILL.md",[],[135,136,137,138,139,140,141,142,143,144],"web","search","web search","搜索","baidu","bing","duckduckgo","百度","多引擎","internet",{"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":104,"licenseFileUrl":6,"sourceHtmlUrl":149,"categories":150,"keywords":154,"publishedAt":49},"01M6F2K968G1FZEZFPW2E6B222","solo-build","Execute implementation plan tasks with TDD workflow, auto-commit, and phase gates. Use when user says \"build it\", \"start building\", \"execute plan\", \"implement tasks\", \"ship it\", or references a track ID. Do NOT use for planning (use \u002Fplan) or scaffolding (use \u002Fscaffold).","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fsolo-build\u002FSKILL.md",[151],{"categoryNo":152,"categoryName":153,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[155,156,157,158,159,160,161,47,136,162,163,164,108,165,166,167,168,169,170,171],"build","solo","solo build","MCP","workflow","commit","tasks","Bash","plan","read","auto","references","context7","query","scaffolding","ship it","project",{"skillNo":173,"name":174,"nameZh":6,"description":175,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":104,"licenseFileUrl":6,"sourceHtmlUrl":176,"categories":177,"keywords":184,"publishedAt":49},"01M6F2GKN39SGHSPWYB3662YC8","react-email","Use when building HTML email templates with React components, adding a visual email editor to an application using the React Email visual editor, rendering emails to HTML, or sending emails with Resend. Covers welcome emails, password resets, notifications, order confirmations, newsletters, transactional emails, and the embeddable email editor component.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Freact-email-skills\u002FSKILL.md",[178,181],{"categoryNo":179,"categoryName":180,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000005","邮件与沟通",{"categoryNo":182,"categoryName":183,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000009","前端开发",[185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204],"react","email","react email","github","editor","components","react components","component","welcome","https","notifications","password","node","use","html","resend","visual","emails","rendering","with",{"skillNo":206,"name":207,"nameZh":6,"description":208,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":104,"licenseFileUrl":6,"sourceHtmlUrl":209,"categories":210,"keywords":217,"publishedAt":49},"01M6F2FBVGVDFSG8SSFJGXA40C","APITester Agent-Driven API Testing","Test API endpoints and document responses. Define tests in plain English, run them, get formatted results. Agent-driven Postman alternative.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fopenclaw-api-tester\u002FSKILL.md",[211,214,215,216],{"categoryNo":212,"categoryName":213,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":152,"categoryName":153,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":24,"categoryName":25,"taxonomyType":26,"taxonomyTypeDesc":27},[218,32,219,220,221,222,223,224,225,226,227,30,228,229,230,231,232,233],"testing","api testing","driven","APITester Agent Driven API Testing","test","run","postman","results","plain english","tester","document","get","define","tests","english","api-tester",{"skillNo":235,"name":236,"nameZh":6,"description":237,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":104,"licenseFileUrl":6,"sourceHtmlUrl":238,"categories":239,"keywords":240,"publishedAt":49},"01M6F273Y3NGAPVJZ608BC0G9G","hubspot-implementation-plan","Generate a phased implementation plan from a HubSpot audit report. Creates prioritized, sequenced cleanup processes with effort estimates, dependencies, and automation feasibility. Use after running \u002Fhubspot-audit.","https:\u002F\u002Fgithub.com\u002Fluokai0\u002Fai-agent-skills-by-luo-kai\u002Fblob\u002Fmain\u002Fai-agent-skills\u002F22-clawhub-skills\u002Fhubspot-implementation-plan\u002FSKILL.md",[],[163,241,242,243,244,245,246,114,247,248,249,250,251,198,252,253,204,254],"implementation","hubspot","hubspot implementation plan","automation","feasibility","cleanup","planning","report","audit","audit report","phased implementation","dependencies","processes","hubspot audit"]