[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M732EZ2ECTGM2DN29BMSYHAV":3,"skill-same:01M732EZ2ECTGM2DN29BMSYHAV":90},{"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":16,"sourceHtmlUrl":17,"categories":18,"keywords":19,"publishedAt":20,"linkOnly":21,"markdownContent":22,"markdownBody":23,"frontMatter":24,"refName":50,"commitSha":51,"skillDirectory":52,"forksCount":53,"repositoryHtmlUrl":54,"repositoryHomepageUrl":55,"ownerHtmlUrl":56,"ownerBlogUrl":57,"ownerDescription":58,"updatedAt":59,"install":60,"resources":73},"01M732EZ2ECTGM2DN29BMSYHAV","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.","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdetecting-shadow-api-endpoints\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdetecting-shadow-api-endpoints\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: detecting-shadow-api-endpoints\ndescription: Discover and inventory shadow API endpoints that operate outside documented\n  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\nversion: '1.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- T1133\n- T1526\n- T1213\nsource: https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\nsource_commit: 04450304b12645cb2b974ab96d28c0664758a88d\nnote: \"Vendored verbatim from an external Apache-2.0 security-skill library, pinned by commit. Exceeds the internal 300-line skill guideline (agent-code-constraints.md) -- kept as-is because this is vendored reference material (forensics\u002Fthreat-intel procedure), not Yana AI-authored content, and trimming would damage technical accuracy.\"\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,"note":25,"tags":26,"author":35,"domain":36,"source":37,"license":15,"version":38,"nist_csf":39,"subdomain":27,"description":7,"mitre_attack":44,"source_commit":49},"Vendored verbatim from an external Apache-2.0 security-skill library, pinned by commit. Exceeds the internal 300-line skill guideline (agent-code-constraints.md) -- kept as-is because this is vendored reference material (forensics\u002Fthreat-intel procedure), not Yana AI-authored content, and trimming would damage technical accuracy.",[27,28,29,30,31,32,33,34],"api-security","shadow-apis","api-discovery","undocumented-apis","zombie-apis","api-inventory","attack-surface-management","api-governance","mahipal","cybersecurity","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills","1.0",[40,41,42,43],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[45,46,47,48],"T1190","T1133","T1526","T1213","04450304b12645cb2b974ab96d28c0664758a88d","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa",".claude\u002Fskills\u002Fdetecting-shadow-api-endpoints",2,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-14 13:24:09",{"source":8,"skillName":5,"commands":61,"prompt":71,"zipAvailable":72},[62,65,68],{"tool":63,"command":64},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill detecting-shadow-api-endpoints",{"tool":66,"command":67},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill detecting-shadow-api-endpoints",{"tool":69,"command":70},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill detecting-shadow-api-endpoints","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdetecting-shadow-api-endpoints\u002FSKILL.md",true,[74,78,84],{"path":75,"resourceType":75,"resourceTypeDesc":76,"sizeBytes":77,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"references\u002Fapi-reference.md","REFERENCE","参考文档",2212,"https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdetecting-shadow-api-endpoints\u002Freferences\u002Fapi-reference.md",{"path":85,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":88,"sourceHtmlUrl":89},"scripts\u002Fagent.py","SCRIPT","脚本",5723,"https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdetecting-shadow-api-endpoints\u002Fscripts\u002Fagent.py",[91,99,106,114,122,130],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":95,"licenseFileUrl":6,"sourceHtmlUrl":96,"categories":97,"keywords":98,"publishedAt":20},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":100,"name":101,"nameZh":6,"description":102,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":103,"categories":104,"keywords":105,"publishedAt":20},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":107,"name":108,"nameZh":6,"description":109,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":110,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":20},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":118,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":20},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":126,"sourceHtmlUrl":127,"categories":128,"keywords":129,"publishedAt":20},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":131,"name":132,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":135,"publishedAt":20},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]