[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7D7MWCMK6T32MNK7PCBZYJN":3,"skill-same:01M7D7MWCMK6T32MNK7PCBZYJN":87},{"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":48,"commitSha":49,"skillDirectory":50,"forksCount":51,"repositoryHtmlUrl":52,"repositoryHomepageUrl":6,"ownerHtmlUrl":53,"ownerBlogUrl":54,"ownerDescription":55,"updatedAt":56,"install":57,"resources":70},"01M7D7MWCMK6T32MNK7PCBZYJN","detecting-api-enumeration-attacks",null,"Detect API enumeration attacks (BOLA\u002FIDOR, OWASP API1:2023) by writing SIEM detection rules that flag sequential or UUID identifier iteration, parameter tampering, and mixed 200\u002F401\u002F403 response patterns from API gateway and WAF logs. Use when investigating suspected object-level authorization abuse, building threat-hunting queries for API access-control bypass, or hardening API logging\u002Frate-limiting against enumeration.","SaiVatsal\u002FSkills-I-Use","SaiVatsal","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F242597752?v=4","01M7D5YM1T4VXW9203M0GFAHZ1","SaiVatsalPolimera","01M7D5YM2D61ST39XVR2V7B7ZJ",3,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-api-enumeration-attacks\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-api-enumeration-attacks\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: detecting-api-enumeration-attacks\ndescription: Detect API enumeration attacks (BOLA\u002FIDOR, OWASP API1:2023) by writing SIEM\n  detection rules that flag sequential or UUID identifier iteration, parameter tampering,\n  and mixed 200\u002F401\u002F403 response patterns from API gateway and WAF logs. Use when\n  investigating suspected object-level authorization abuse, building threat-hunting\n  queries for API access-control bypass, or hardening API logging\u002Frate-limiting against\n  enumeration.\ndomain: cybersecurity\nsubdomain: api-security\ntags:\n- api-security\n- enumeration\n- bola\n- idor\n- broken-object-level-authorization\n- owasp-api-top-10\n- access-control\n- rate-limiting\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- T1595\n- T1595.002\n- T1046\n- T1190\n- T1087\n---\n\n# Detecting API Enumeration Attacks\n\n## Overview\n\nAPI enumeration attacks occur when attackers systematically probe API endpoints with sequential or predictable identifiers to discover and access unauthorized resources. Broken Object Level Authorization (BOLA), ranked as API1:2023 in the OWASP API Security Top 10, is the most critical API vulnerability. Attackers manipulate object identifiers (user IDs, order numbers, account references) in API requests to bypass authorization and access other users' data. Detection requires monitoring for patterns of rapid sequential access attempts, authorization failures, and abnormal API usage behavior.\n\n\n## When to Use\n\n- When investigating security incidents that require detecting api enumeration attacks\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 logging enabled (Kong, AWS API Gateway, Apigee)\n- SIEM platform (Splunk, Elastic SIEM, or Microsoft Sentinel)\n- Access to API server logs with request details\n- Web Application Firewall (WAF) with API protection capabilities\n- Understanding of the API's authorization model and object identifier schemes\n\n## Attack Patterns to Detect\n\n### 1. Sequential ID Enumeration\n\nAttackers iterate through numeric or predictable identifiers:\n\n```\nGET \u002Fapi\u002Fv1\u002Fusers\u002F1001 -> 200 OK\nGET \u002Fapi\u002Fv1\u002Fusers\u002F1002 -> 200 OK\nGET \u002Fapi\u002Fv1\u002Fusers\u002F1003 -> 403 Forbidden\nGET \u002Fapi\u002Fv1\u002Fusers\u002F1004 -> 200 OK\nGET \u002Fapi\u002Fv1\u002Fusers\u002F1005 -> 200 OK\n...\n```\n\n**Detection Indicators:**\n- Rapid sequential requests to the same endpoint with incrementing IDs\n- Mix of 200\u002F403\u002F401 responses from same source\n- Request rate exceeding normal user behavior\n- Access to resources outside authenticated user's scope\n\n### 2. UUID\u002FGUID Enumeration\n\nEven non-sequential identifiers can be enumerated if leaked through other endpoints:\n\n```\n# Attacker first harvests UUIDs from a list endpoint\nGET \u002Fapi\u002Fv1\u002Fposts?page=1  -> Returns post objects with author UUIDs\n\n# Then uses those UUIDs to access restricted user data\nGET \u002Fapi\u002Fv1\u002Fusers\u002Fa3f2c1e4-... -> Private user profile\nGET \u002Fapi\u002Fv1\u002Fusers\u002Fb7d9e8f1-... -> Private user profile\n```\n\n### 3. Parameter Tampering Enumeration\n\n```\n# Authenticated as user_id=100, attempting to access other users' orders\nGET \u002Fapi\u002Fv1\u002Forders?user_id=101\nGET \u002Fapi\u002Fv1\u002Forders?user_id=102\nGET \u002Fapi\u002Fv1\u002Forders?user_id=103\n```\n\n## Detection Rules\n\n### Splunk Detection Queries\n\n```spl\n# Detect sequential ID enumeration on API endpoints\nindex=api_logs sourcetype=api_access\n| rex field=uri_path \"(?\u003Cendpoint>\u002Fapi\u002Fv\\d+\u002F\\w+\u002F)(?\u003Cobject_id>\\d+)\"\n| stats count as request_count,\n        dc(object_id) as unique_ids,\n        values(status_code) as status_codes,\n        min(_time) as first_seen,\n        max(_time) as last_seen\n  by src_ip, endpoint, user_session\n| eval time_span = last_seen - first_seen\n| eval requests_per_second = request_count \u002F max(time_span, 1)\n| where unique_ids > 20 AND requests_per_second > 2\n| eval severity = case(\n    unique_ids > 100, \"critical\",\n    unique_ids > 50, \"high\",\n    unique_ids > 20, \"medium\",\n    1==1, \"low\"\n  )\n| sort - unique_ids\n| table src_ip, endpoint, unique_ids, request_count, requests_per_second,\n        status_codes, severity\n\n# Detect BOLA via authorization failure patterns\nindex=api_logs sourcetype=api_access status_code IN (401, 403)\n| bin _time span=5m\n| stats count as failure_count,\n        dc(uri_path) as unique_paths,\n        values(uri_path) as attempted_paths\n  by _time, src_ip, user_id\n| where failure_count > 10\n| eval attack_type = if(unique_paths > 5, \"enumeration\", \"brute_force\")\n```\n\n### Elastic SIEM Detection Rules\n\n```json\n{\n  \"rule\": {\n    \"name\": \"API Object Enumeration Detection\",\n    \"description\": \"Detects rapid sequential access to API objects with mixed authorization results\",\n    \"type\": \"threshold\",\n    \"index\": [\"api-access-*\"],\n    \"query\": {\n      \"bool\": {\n        \"must\": [\n          { \"regexp\": { \"url.path\": \"\u002Fapi\u002Fv[0-9]+\u002F[a-z]+\u002F[0-9]+\" } }\n        ],\n        \"should\": [\n          { \"term\": { \"http.response.status_code\": 200 } },\n          { \"term\": { \"http.response.status_code\": 403 } },\n          { \"term\": { \"http.response.status_code\": 401 } }\n        ]\n      }\n    },\n    \"threshold\": {\n      \"field\": [\"source.ip\"],\n      \"value\": 50,\n      \"cardinality\": [\n        { \"field\": \"url.path\", \"value\": 20 }\n      ]\n    },\n    \"schedule\": { \"interval\": \"5m\" },\n    \"severity\": \"high\",\n    \"risk_score\": 73,\n    \"tags\": [\"OWASP-API1\", \"BOLA\", \"Enumeration\"]\n  }\n}\n```\n\n### Custom Detection Script\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"API Enumeration Attack Detector\n\nAnalyzes API access logs to detect enumeration patterns\nincluding BOLA, IDOR, and sequential ID probing.\n\"\"\"\n\nimport re\nimport sys\nimport json\nfrom collections import defaultdict\nfrom datetime import datetime, timedelta\nfrom dataclasses import dataclass, field\nfrom typing import List, Dict, Optional\n\n@dataclass\nclass AccessRecord:\n    timestamp: datetime\n    source_ip: str\n    user_id: Optional[str]\n    method: str\n    path: str\n    status_code: int\n    object_id: Optional[str] = None\n\n@dataclass\nclass EnumerationAlert:\n    source_ip: str\n    user_id: Optional[str]\n    endpoint_pattern: str\n    unique_object_ids: int\n    total_requests: int\n    time_window_seconds: float\n    requests_per_second: float\n    auth_failure_ratio: float\n    severity: str\n    attack_type: str\n    sample_ids: List[str] = field(default_factory=list)\n\nclass EnumerationDetector:\n    # Regex patterns for extracting object IDs from API paths\n    ID_PATTERNS = [\n        re.compile(r'\u002Fapi\u002Fv\\d+\u002F(\\w+)\u002F(\\d+)'),           # Numeric IDs\n        re.compile(r'\u002Fapi\u002Fv\\d+\u002F(\\w+)\u002F([a-f0-9\\-]{36})'), # UUIDs\n        re.compile(r'\u002Fapi\u002Fv\\d+\u002F(\\w+)\u002F([a-zA-Z0-9]{20,})'), # Long alphanumeric IDs\n    ]\n\n    def __init__(self, time_window_minutes: int = 5,\n                 min_unique_ids: int = 15,\n                 max_requests_per_second: float = 5.0):\n        self.time_window = timedelta(minutes=time_window_minutes)\n        self.min_unique_ids = min_unique_ids\n        self.max_rps = max_requests_per_second\n        self.access_log: List[AccessRecord] = []\n\n    def parse_log_line(self, line: str) -> Optional[AccessRecord]:\n        \"\"\"Parse a common log format line into an AccessRecord.\"\"\"\n        log_pattern = re.compile(\n            r'(?P\u003Cip>[\\d.]+)\\s+\\S+\\s+(?P\u003Cuser>\\S+)\\s+'\n            r'\\[(?P\u003Ctime>[^\\]]+)\\]\\s+'\n            r'\"(?P\u003Cmethod>\\w+)\\s+(?P\u003Cpath>\\S+)\\s+\\S+\"\\s+'\n            r'(?P\u003Cstatus>\\d+)'\n        )\n        match = log_pattern.match(line)\n        if not match:\n            return None\n\n        path = match.group('path')\n        object_id = None\n        for pattern in self.ID_PATTERNS:\n            id_match = pattern.search(path)\n            if id_match:\n                object_id = id_match.group(2)\n                break\n\n        return AccessRecord(\n            timestamp=datetime.strptime(match.group('time'), '%d\u002F%b\u002F%Y:%H:%M:%S %z'),\n            source_ip=match.group('ip'),\n            user_id=match.group('user') if match.group('user') != '-' else None,\n            method=match.group('method'),\n            path=path,\n            status_code=int(match.group('status')),\n            object_id=object_id\n        )\n\n    def analyze(self, records: List[AccessRecord]) -> List[EnumerationAlert]:\n        \"\"\"Analyze access records for enumeration patterns.\"\"\"\n        alerts = []\n\n        # Group by source IP and endpoint pattern\n        grouped = defaultdict(list)\n        for record in records:\n            if record.object_id:\n                # Normalize endpoint by removing the specific object ID\n                endpoint = re.sub(r'\u002F[a-f0-9\\-]{36}', '\u002F{id}',\n                         re.sub(r'\u002F\\d+', '\u002F{id}', record.path))\n                key = (record.source_ip, record.user_id, endpoint)\n                grouped[key].append(record)\n\n        for (src_ip, user_id, endpoint), records_group in grouped.items():\n            if len(records_group) \u003C self.min_unique_ids:\n                continue\n\n            # Sort by timestamp\n            records_group.sort(key=lambda r: r.timestamp)\n\n            # Analyze time windows\n            window_start = 0\n            for window_start in range(len(records_group)):\n                window_records = []\n                for r in records_group[window_start:]:\n                    if r.timestamp - records_group[window_start].timestamp \u003C= self.time_window:\n                        window_records.append(r)\n\n                unique_ids = set(r.object_id for r in window_records)\n                if len(unique_ids) \u003C self.min_unique_ids:\n                    continue\n\n                time_span = (window_records[-1].timestamp -\n                           window_records[0].timestamp).total_seconds()\n                rps = len(window_records) \u002F max(time_span, 1)\n\n                auth_failures = sum(1 for r in window_records\n                                   if r.status_code in (401, 403))\n                failure_ratio = auth_failures \u002F len(window_records)\n\n                # Determine severity\n                if len(unique_ids) > 100:\n                    severity = \"critical\"\n                elif len(unique_ids) > 50 or failure_ratio > 0.5:\n                    severity = \"high\"\n                elif len(unique_ids) > 20:\n                    severity = \"medium\"\n                else:\n                    severity = \"low\"\n\n                # Determine attack type\n                ids_list = sorted([r.object_id for r in window_records\n                                  if r.object_id and r.object_id.isdigit()])\n                is_sequential = self._check_sequential(ids_list)\n                attack_type = \"sequential_enumeration\" if is_sequential else \"random_enumeration\"\n\n                alert = EnumerationAlert(\n                    source_ip=src_ip,\n                    user_id=user_id,\n                    endpoint_pattern=endpoint,\n                    unique_object_ids=len(unique_ids),\n                    total_requests=len(window_records),\n                    time_window_seconds=time_span,\n                    requests_per_second=round(rps, 2),\n                    auth_failure_ratio=round(failure_ratio, 2),\n                    severity=severity,\n                    attack_type=attack_type,\n                    sample_ids=list(unique_ids)[:10]\n                )\n                alerts.append(alert)\n                break  # One alert per group\n\n        return alerts\n\n    def _check_sequential(self, ids: List[str]) -> bool:\n        \"\"\"Check if numeric IDs follow a sequential pattern.\"\"\"\n        if len(ids) \u003C 5:\n            return False\n        try:\n            numeric_ids = sorted(int(i) for i in ids)\n            sequential_count = sum(\n                1 for i in range(1, len(numeric_ids))\n                if numeric_ids[i] - numeric_ids[i-1] \u003C= 2\n            )\n            return sequential_count \u002F len(numeric_ids) > 0.7\n        except ValueError:\n            return False\n\n\ndef main():\n    detector = EnumerationDetector(\n        time_window_minutes=5,\n        min_unique_ids=15\n    )\n\n    log_file = sys.argv[1] if len(sys.argv) > 1 else \"\u002Fvar\u002Flog\u002Fapi\u002Faccess.log\"\n    records = []\n    with open(log_file, 'r') as f:\n        for line in f:\n            record = detector.parse_log_line(line.strip())\n            if record:\n                records.append(record)\n\n    alerts = detector.analyze(records)\n\n    if alerts:\n        print(f\"\\n[!] {len(alerts)} enumeration attack(s) detected:\\n\")\n        for alert in alerts:\n            print(f\"  Source IP: {alert.source_ip}\")\n            print(f\"  User ID: {alert.user_id}\")\n            print(f\"  Endpoint: {alert.endpoint_pattern}\")\n            print(f\"  Unique IDs Accessed: {alert.unique_object_ids}\")\n            print(f\"  Requests\u002Fsec: {alert.requests_per_second}\")\n            print(f\"  Auth Failure Ratio: {alert.auth_failure_ratio}\")\n            print(f\"  Attack Type: {alert.attack_type}\")\n            print(f\"  Severity: {alert.severity.upper()}\")\n            print(f\"  Sample IDs: {alert.sample_ids}\")\n            print()\n    else:\n        print(\"[+] No enumeration attacks detected.\")\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## Prevention Controls\n\n### Server-Side Authorization Enforcement\n\n```python\n# Always validate object ownership at the data layer\ndef get_user_order(request, order_id):\n    order = Order.objects.get(id=order_id)\n    if order.user_id != request.user.id:\n        raise PermissionDenied(\"Not authorized to access this order\")\n    return order\n```\n\n### Use Unpredictable Identifiers\n\n```python\nimport uuid\n\n# Use UUIDs instead of sequential integers\nclass Order(Model):\n    id = UUIDField(default=uuid.uuid4, primary_key=True)\n```\n\n### Implement Rate Limiting Per Endpoint\n\n```yaml\n# Kong rate limiting per API route\nplugins:\n  - name: rate-limiting\n    config:\n      minute: 30\n      policy: redis\n      limit_by: credential\n```\n\n## References\n\n- OWASP API1:2023 Broken Object Level Authorization: https:\u002F\u002Fowasp.org\u002FAPI-Security\u002Feditions\u002F2023\u002Fen\u002F0xa1-broken-object-level-authorization\u002F\n- Traceable.ai BOLA Deep Dive: https:\u002F\u002Fwww.traceable.ai\u002Fblog-post\u002Fa-deep-dive-on-the-most-critical-api-vulnerability----bola-broken-object-level-authorization\n- Cequence BOLA Prevention: https:\u002F\u002Fwww.cequence.ai\u002Fsolutions\u002Fbola-and-enumeration-attack-prevention\u002F\n- Cloudflare API Shield BOLA Detection: https:\u002F\u002Fcommunity.cloudflare.com\u002Ft\u002Fapi-shield-new-bola-vulnerability-detection-for-api-shield\u002F883021\n- Sycope IDOR Detection via HTTP Traffic Analysis: https:\u002F\u002Fwww.sycope.com\u002Fpost\u002Fidor-vulnerability-how-to-detect-an-attack-on-web-applications-through-http-traffic-analysis\n","# Detecting API Enumeration Attacks\n\n## Overview\n\nAPI enumeration attacks occur when attackers systematically probe API endpoints with sequential or predictable identifiers to discover and access unauthorized resources. Broken Object Level Authorization (BOLA), ranked as API1:2023 in the OWASP API Security Top 10, is the most critical API vulnerability. Attackers manipulate object identifiers (user IDs, order numbers, account references) in API requests to bypass authorization and access other users' data. Detection requires monitoring for patterns of rapid sequential access attempts, authorization failures, and abnormal API usage behavior.\n\n\n## When to Use\n\n- When investigating security incidents that require detecting api enumeration attacks\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 logging enabled (Kong, AWS API Gateway, Apigee)\n- SIEM platform (Splunk, Elastic SIEM, or Microsoft Sentinel)\n- Access to API server logs with request details\n- Web Application Firewall (WAF) with API protection capabilities\n- Understanding of the API's authorization model and object identifier schemes\n\n## Attack Patterns to Detect\n\n### 1. Sequential ID Enumeration\n\nAttackers iterate through numeric or predictable identifiers:\n\n```\nGET \u002Fapi\u002Fv1\u002Fusers\u002F1001 -> 200 OK\nGET \u002Fapi\u002Fv1\u002Fusers\u002F1002 -> 200 OK\nGET \u002Fapi\u002Fv1\u002Fusers\u002F1003 -> 403 Forbidden\nGET \u002Fapi\u002Fv1\u002Fusers\u002F1004 -> 200 OK\nGET \u002Fapi\u002Fv1\u002Fusers\u002F1005 -> 200 OK\n...\n```\n\n**Detection Indicators:**\n- Rapid sequential requests to the same endpoint with incrementing IDs\n- Mix of 200\u002F403\u002F401 responses from same source\n- Request rate exceeding normal user behavior\n- Access to resources outside authenticated user's scope\n\n### 2. UUID\u002FGUID Enumeration\n\nEven non-sequential identifiers can be enumerated if leaked through other endpoints:\n\n```\n# Attacker first harvests UUIDs from a list endpoint\nGET \u002Fapi\u002Fv1\u002Fposts?page=1  -> Returns post objects with author UUIDs\n\n# Then uses those UUIDs to access restricted user data\nGET \u002Fapi\u002Fv1\u002Fusers\u002Fa3f2c1e4-... -> Private user profile\nGET \u002Fapi\u002Fv1\u002Fusers\u002Fb7d9e8f1-... -> Private user profile\n```\n\n### 3. Parameter Tampering Enumeration\n\n```\n# Authenticated as user_id=100, attempting to access other users' orders\nGET \u002Fapi\u002Fv1\u002Forders?user_id=101\nGET \u002Fapi\u002Fv1\u002Forders?user_id=102\nGET \u002Fapi\u002Fv1\u002Forders?user_id=103\n```\n\n## Detection Rules\n\n### Splunk Detection Queries\n\n```spl\n# Detect sequential ID enumeration on API endpoints\nindex=api_logs sourcetype=api_access\n| rex field=uri_path \"(?\u003Cendpoint>\u002Fapi\u002Fv\\d+\u002F\\w+\u002F)(?\u003Cobject_id>\\d+)\"\n| stats count as request_count,\n        dc(object_id) as unique_ids,\n        values(status_code) as status_codes,\n        min(_time) as first_seen,\n        max(_time) as last_seen\n  by src_ip, endpoint, user_session\n| eval time_span = last_seen - first_seen\n| eval requests_per_second = request_count \u002F max(time_span, 1)\n| where unique_ids > 20 AND requests_per_second > 2\n| eval severity = case(\n    unique_ids > 100, \"critical\",\n    unique_ids > 50, \"high\",\n    unique_ids > 20, \"medium\",\n    1==1, \"low\"\n  )\n| sort - unique_ids\n| table src_ip, endpoint, unique_ids, request_count, requests_per_second,\n        status_codes, severity\n\n# Detect BOLA via authorization failure patterns\nindex=api_logs sourcetype=api_access status_code IN (401, 403)\n| bin _time span=5m\n| stats count as failure_count,\n        dc(uri_path) as unique_paths,\n        values(uri_path) as attempted_paths\n  by _time, src_ip, user_id\n| where failure_count > 10\n| eval attack_type = if(unique_paths > 5, \"enumeration\", \"brute_force\")\n```\n\n### Elastic SIEM Detection Rules\n\n```json\n{\n  \"rule\": {\n    \"name\": \"API Object Enumeration Detection\",\n    \"description\": \"Detects rapid sequential access to API objects with mixed authorization results\",\n    \"type\": \"threshold\",\n    \"index\": [\"api-access-*\"],\n    \"query\": {\n      \"bool\": {\n        \"must\": [\n          { \"regexp\": { \"url.path\": \"\u002Fapi\u002Fv[0-9]+\u002F[a-z]+\u002F[0-9]+\" } }\n        ],\n        \"should\": [\n          { \"term\": { \"http.response.status_code\": 200 } },\n          { \"term\": { \"http.response.status_code\": 403 } },\n          { \"term\": { \"http.response.status_code\": 401 } }\n        ]\n      }\n    },\n    \"threshold\": {\n      \"field\": [\"source.ip\"],\n      \"value\": 50,\n      \"cardinality\": [\n        { \"field\": \"url.path\", \"value\": 20 }\n      ]\n    },\n    \"schedule\": { \"interval\": \"5m\" },\n    \"severity\": \"high\",\n    \"risk_score\": 73,\n    \"tags\": [\"OWASP-API1\", \"BOLA\", \"Enumeration\"]\n  }\n}\n```\n\n### Custom Detection Script\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"API Enumeration Attack Detector\n\nAnalyzes API access logs to detect enumeration patterns\nincluding BOLA, IDOR, and sequential ID probing.\n\"\"\"\n\nimport re\nimport sys\nimport json\nfrom collections import defaultdict\nfrom datetime import datetime, timedelta\nfrom dataclasses import dataclass, field\nfrom typing import List, Dict, Optional\n\n@dataclass\nclass AccessRecord:\n    timestamp: datetime\n    source_ip: str\n    user_id: Optional[str]\n    method: str\n    path: str\n    status_code: int\n    object_id: Optional[str] = None\n\n@dataclass\nclass EnumerationAlert:\n    source_ip: str\n    user_id: Optional[str]\n    endpoint_pattern: str\n    unique_object_ids: int\n    total_requests: int\n    time_window_seconds: float\n    requests_per_second: float\n    auth_failure_ratio: float\n    severity: str\n    attack_type: str\n    sample_ids: List[str] = field(default_factory=list)\n\nclass EnumerationDetector:\n    # Regex patterns for extracting object IDs from API paths\n    ID_PATTERNS = [\n        re.compile(r'\u002Fapi\u002Fv\\d+\u002F(\\w+)\u002F(\\d+)'),           # Numeric IDs\n        re.compile(r'\u002Fapi\u002Fv\\d+\u002F(\\w+)\u002F([a-f0-9\\-]{36})'), # UUIDs\n        re.compile(r'\u002Fapi\u002Fv\\d+\u002F(\\w+)\u002F([a-zA-Z0-9]{20,})'), # Long alphanumeric IDs\n    ]\n\n    def __init__(self, time_window_minutes: int = 5,\n                 min_unique_ids: int = 15,\n                 max_requests_per_second: float = 5.0):\n        self.time_window = timedelta(minutes=time_window_minutes)\n        self.min_unique_ids = min_unique_ids\n        self.max_rps = max_requests_per_second\n        self.access_log: List[AccessRecord] = []\n\n    def parse_log_line(self, line: str) -> Optional[AccessRecord]:\n        \"\"\"Parse a common log format line into an AccessRecord.\"\"\"\n        log_pattern = re.compile(\n            r'(?P\u003Cip>[\\d.]+)\\s+\\S+\\s+(?P\u003Cuser>\\S+)\\s+'\n            r'\\[(?P\u003Ctime>[^\\]]+)\\]\\s+'\n            r'\"(?P\u003Cmethod>\\w+)\\s+(?P\u003Cpath>\\S+)\\s+\\S+\"\\s+'\n            r'(?P\u003Cstatus>\\d+)'\n        )\n        match = log_pattern.match(line)\n        if not match:\n            return None\n\n        path = match.group('path')\n        object_id = None\n        for pattern in self.ID_PATTERNS:\n            id_match = pattern.search(path)\n            if id_match:\n                object_id = id_match.group(2)\n                break\n\n        return AccessRecord(\n            timestamp=datetime.strptime(match.group('time'), '%d\u002F%b\u002F%Y:%H:%M:%S %z'),\n            source_ip=match.group('ip'),\n            user_id=match.group('user') if match.group('user') != '-' else None,\n            method=match.group('method'),\n            path=path,\n            status_code=int(match.group('status')),\n            object_id=object_id\n        )\n\n    def analyze(self, records: List[AccessRecord]) -> List[EnumerationAlert]:\n        \"\"\"Analyze access records for enumeration patterns.\"\"\"\n        alerts = []\n\n        # Group by source IP and endpoint pattern\n        grouped = defaultdict(list)\n        for record in records:\n            if record.object_id:\n                # Normalize endpoint by removing the specific object ID\n                endpoint = re.sub(r'\u002F[a-f0-9\\-]{36}', '\u002F{id}',\n                         re.sub(r'\u002F\\d+', '\u002F{id}', record.path))\n                key = (record.source_ip, record.user_id, endpoint)\n                grouped[key].append(record)\n\n        for (src_ip, user_id, endpoint), records_group in grouped.items():\n            if len(records_group) \u003C self.min_unique_ids:\n                continue\n\n            # Sort by timestamp\n            records_group.sort(key=lambda r: r.timestamp)\n\n            # Analyze time windows\n            window_start = 0\n            for window_start in range(len(records_group)):\n                window_records = []\n                for r in records_group[window_start:]:\n                    if r.timestamp - records_group[window_start].timestamp \u003C= self.time_window:\n                        window_records.append(r)\n\n                unique_ids = set(r.object_id for r in window_records)\n                if len(unique_ids) \u003C self.min_unique_ids:\n                    continue\n\n                time_span = (window_records[-1].timestamp -\n                           window_records[0].timestamp).total_seconds()\n                rps = len(window_records) \u002F max(time_span, 1)\n\n                auth_failures = sum(1 for r in window_records\n                                   if r.status_code in (401, 403))\n                failure_ratio = auth_failures \u002F len(window_records)\n\n                # Determine severity\n                if len(unique_ids) > 100:\n                    severity = \"critical\"\n                elif len(unique_ids) > 50 or failure_ratio > 0.5:\n                    severity = \"high\"\n                elif len(unique_ids) > 20:\n                    severity = \"medium\"\n                else:\n                    severity = \"low\"\n\n                # Determine attack type\n                ids_list = sorted([r.object_id for r in window_records\n                                  if r.object_id and r.object_id.isdigit()])\n                is_sequential = self._check_sequential(ids_list)\n                attack_type = \"sequential_enumeration\" if is_sequential else \"random_enumeration\"\n\n                alert = EnumerationAlert(\n                    source_ip=src_ip,\n                    user_id=user_id,\n                    endpoint_pattern=endpoint,\n                    unique_object_ids=len(unique_ids),\n                    total_requests=len(window_records),\n                    time_window_seconds=time_span,\n                    requests_per_second=round(rps, 2),\n                    auth_failure_ratio=round(failure_ratio, 2),\n                    severity=severity,\n                    attack_type=attack_type,\n                    sample_ids=list(unique_ids)[:10]\n                )\n                alerts.append(alert)\n                break  # One alert per group\n\n        return alerts\n\n    def _check_sequential(self, ids: List[str]) -> bool:\n        \"\"\"Check if numeric IDs follow a sequential pattern.\"\"\"\n        if len(ids) \u003C 5:\n            return False\n        try:\n            numeric_ids = sorted(int(i) for i in ids)\n            sequential_count = sum(\n                1 for i in range(1, len(numeric_ids))\n                if numeric_ids[i] - numeric_ids[i-1] \u003C= 2\n            )\n            return sequential_count \u002F len(numeric_ids) > 0.7\n        except ValueError:\n            return False\n\n\ndef main():\n    detector = EnumerationDetector(\n        time_window_minutes=5,\n        min_unique_ids=15\n    )\n\n    log_file = sys.argv[1] if len(sys.argv) > 1 else \"\u002Fvar\u002Flog\u002Fapi\u002Faccess.log\"\n    records = []\n    with open(log_file, 'r') as f:\n        for line in f:\n            record = detector.parse_log_line(line.strip())\n            if record:\n                records.append(record)\n\n    alerts = detector.analyze(records)\n\n    if alerts:\n        print(f\"\\n[!] {len(alerts)} enumeration attack(s) detected:\\n\")\n        for alert in alerts:\n            print(f\"  Source IP: {alert.source_ip}\")\n            print(f\"  User ID: {alert.user_id}\")\n            print(f\"  Endpoint: {alert.endpoint_pattern}\")\n            print(f\"  Unique IDs Accessed: {alert.unique_object_ids}\")\n            print(f\"  Requests\u002Fsec: {alert.requests_per_second}\")\n            print(f\"  Auth Failure Ratio: {alert.auth_failure_ratio}\")\n            print(f\"  Attack Type: {alert.attack_type}\")\n            print(f\"  Severity: {alert.severity.upper()}\")\n            print(f\"  Sample IDs: {alert.sample_ids}\")\n            print()\n    else:\n        print(\"[+] No enumeration attacks detected.\")\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## Prevention Controls\n\n### Server-Side Authorization Enforcement\n\n```python\n# Always validate object ownership at the data layer\ndef get_user_order(request, order_id):\n    order = Order.objects.get(id=order_id)\n    if order.user_id != request.user.id:\n        raise PermissionDenied(\"Not authorized to access this order\")\n    return order\n```\n\n### Use Unpredictable Identifiers\n\n```python\nimport uuid\n\n# Use UUIDs instead of sequential integers\nclass Order(Model):\n    id = UUIDField(default=uuid.uuid4, primary_key=True)\n```\n\n### Implement Rate Limiting Per Endpoint\n\n```yaml\n# Kong rate limiting per API route\nplugins:\n  - name: rate-limiting\n    config:\n      minute: 30\n      policy: redis\n      limit_by: credential\n```\n\n## References\n\n- OWASP API1:2023 Broken Object Level Authorization: https:\u002F\u002Fowasp.org\u002FAPI-Security\u002Feditions\u002F2023\u002Fen\u002F0xa1-broken-object-level-authorization\u002F\n- Traceable.ai BOLA Deep Dive: https:\u002F\u002Fwww.traceable.ai\u002Fblog-post\u002Fa-deep-dive-on-the-most-critical-api-vulnerability----bola-broken-object-level-authorization\n- Cequence BOLA Prevention: https:\u002F\u002Fwww.cequence.ai\u002Fsolutions\u002Fbola-and-enumeration-attack-prevention\u002F\n- Cloudflare API Shield BOLA Detection: https:\u002F\u002Fcommunity.cloudflare.com\u002Ft\u002Fapi-shield-new-bola-vulnerability-detection-for-api-shield\u002F883021\n- Sycope IDOR Detection via HTTP Traffic Analysis: https:\u002F\u002Fwww.sycope.com\u002Fpost\u002Fidor-vulnerability-how-to-detect-an-attack-on-web-applications-through-http-traffic-analysis\n",{"name":5,"tags":25,"author":34,"domain":35,"license":15,"version":36,"nist_csf":37,"subdomain":26,"description":7,"mitre_attack":42},[26,27,28,29,30,31,32,33],"api-security","enumeration","bola","idor","broken-object-level-authorization","owasp-api-top-10","access-control","rate-limiting","mahipal","cybersecurity","1.0",[38,39,40,41],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[43,44,45,46,47],"T1595","T1595.002","T1046","T1190","T1087","main","8a3b3de73262a4c4db64523949360f3c599c2fb1","Anthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-api-enumeration-attacks",0,"https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use","https:\u002F\u002Fgithub.com\u002FSaiVatsal","https:\u002F\u002Fsaivatsal.github.io\u002FPortfolio\u002F","The Longer It Takes The Stronger It Becomes ","2026-09-21 22:45:58",{"source":8,"skillName":5,"commands":58,"prompt":68,"zipAvailable":69},[59,62,65],{"tool":60,"command":61},"npx","npx skills add SaiVatsal\u002FSkills-I-Use --skill detecting-api-enumeration-attacks",{"tool":63,"command":64},"bunx","bunx skills add SaiVatsal\u002FSkills-I-Use --skill detecting-api-enumeration-attacks",{"tool":66,"command":67},"pnpm","pnpm dlx skills add SaiVatsal\u002FSkills-I-Use --skill detecting-api-enumeration-attacks","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-api-enumeration-attacks\u002FSKILL.md",true,[71,75,81],{"path":72,"resourceType":72,"resourceTypeDesc":73,"sizeBytes":74,"sourceHtmlUrl":16},"LICENSE","许可证",11255,{"path":76,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":79,"sourceHtmlUrl":80},"references\u002Fapi-reference.md","REFERENCE","参考文档",1931,"https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-api-enumeration-attacks\u002Freferences\u002Fapi-reference.md",{"path":82,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},"scripts\u002Fagent.py","SCRIPT","脚本",6726,"https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002FAnthropic-Cybersecurity-Skills-main\u002Fskills\u002Fdetecting-api-enumeration-attacks\u002Fscripts\u002Fagent.py",[88,96,104,113,120,127],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":92,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":20},"01M7DJZP6E6KMBQV4CZSDPZEZ8","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":100,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":20},"01M7DJZFTS5TS06K2TV3MDTE67","web-artifacts-builder","Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn\u002Fui). Use for complex artifacts requiring state management, routing, or shadcn\u002Fui components - not for simple single-file HTML\u002FJSX artifacts.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fweb-artifacts-builder\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fweb-artifacts-builder\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":108,"licenseFileUrl":109,"sourceHtmlUrl":110,"categories":111,"keywords":112,"publishedAt":20},"01M7DJRK4SRQ908F2TJM6EZ7EV","ui-styling","Create beautiful, accessible user interfaces with shadcn\u002Fui components (built on Radix UI + Tailwind), Tailwind CSS utility-first styling, and canvas-based visual designs. Use when building user interfaces, implementing design systems, creating responsive layouts, adding accessible components (dialogs, dropdowns, forms, tables), customizing themes and colors, implementing dark mode, generating visual designs and posters, or establishing consistent styling patterns across applications.","MIT","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fui-styling\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fui-styling\u002FSKILL.md",[],[],{"skillNo":114,"name":115,"nameZh":6,"description":116,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":108,"licenseFileUrl":6,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":20},"01M7DJR902059VEQP23PVM2WA0","design","Comprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social\u002Fads\u002Fweb\u002Fprint), icon design (15 styles, SVG, Gemini 3.1 Pro), social photos (HTML→screenshot, multi-platform). Actions: design logo, create CIP, generate mockups, build slides, design banner, generate icon, create social photos, social media images, brand identity, design system. Platforms: Facebook, Twitter, LinkedIn, YouTube, Instagram, Pinterest, TikTok, Threads, Google Ads.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fdesign\u002FSKILL.md",[],[],{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":108,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":20},"01M7DJR56QF5N6XYTCPCFHFMNP","design-system","Token architecture, component specifications, and slide generation. Three-layer tokens (primitive→semantic→component), CSS variables, spacing\u002Ftypography scales, component specs, strategic slide creation. Use for design tokens, systematic design, brand-compliant presentations.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fdesign-system\u002FSKILL.md",[],[],{"skillNo":128,"name":129,"nameZh":6,"description":130,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":108,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":133,"publishedAt":20},"01M7DJQXB6M0SFF7NX8J5N01AH","banner-design","Design banners for social media, ads, website heroes, creative assets, and print. Multiple art direction options with AI-generated visuals. Actions: design, create, generate banner. Platforms: Facebook, Twitter\u002FX, LinkedIn, YouTube, Instagram, Google Display, website hero, print. Styles: minimalist, gradient, bold typography, photo-based, illustrated, geometric, retro, glassmorphism, 3D, neon, duotone, editorial, collage. Uses ui-ux-pro-max, frontend-design, ai-artist, ai-multimodal skills.","https:\u002F\u002Fgithub.com\u002FSaiVatsal\u002FSkills-I-Use\u002Fblob\u002Fmain\u002Fui-ux-pro-max-skill-main\u002Fcli\u002Fassets\u002Fskills\u002Fbanner-design\u002FSKILL.md",[],[]]