strix-agent 0.1.17__py3-none-any.whl → 0.1.19__py3-none-any.whl
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.
Potentially problematic release.
This version of strix-agent might be problematic. Click here for more details.
- strix/agents/StrixAgent/strix_agent.py +2 -1
- strix/agents/StrixAgent/system_prompt.jinja +8 -10
- strix/agents/base_agent.py +20 -0
- strix/agents/state.py +18 -1
- strix/cli/app.py +92 -15
- strix/cli/main.py +81 -24
- strix/cli/tool_components/base_renderer.py +2 -2
- strix/cli/tool_components/reporting_renderer.py +2 -1
- strix/llm/llm.py +9 -0
- strix/prompts/README.md +64 -0
- strix/prompts/__init__.py +1 -1
- strix/prompts/cloud/.gitkeep +0 -0
- strix/prompts/custom/.gitkeep +0 -0
- strix/prompts/frameworks/fastapi.jinja +142 -0
- strix/prompts/frameworks/nextjs.jinja +126 -0
- strix/prompts/protocols/graphql.jinja +215 -0
- strix/prompts/reconnaissance/.gitkeep +0 -0
- strix/prompts/technologies/firebase_firestore.jinja +177 -0
- strix/prompts/technologies/supabase.jinja +189 -0
- strix/prompts/vulnerabilities/authentication_jwt.jinja +133 -115
- strix/prompts/vulnerabilities/broken_function_level_authorization.jinja +146 -0
- strix/prompts/vulnerabilities/business_logic.jinja +146 -118
- strix/prompts/vulnerabilities/csrf.jinja +137 -131
- strix/prompts/vulnerabilities/idor.jinja +149 -118
- strix/prompts/vulnerabilities/insecure_file_uploads.jinja +188 -0
- strix/prompts/vulnerabilities/mass_assignment.jinja +141 -0
- strix/prompts/vulnerabilities/path_traversal_lfi_rfi.jinja +142 -0
- strix/prompts/vulnerabilities/race_conditions.jinja +135 -165
- strix/prompts/vulnerabilities/rce.jinja +128 -180
- strix/prompts/vulnerabilities/sql_injection.jinja +128 -192
- strix/prompts/vulnerabilities/ssrf.jinja +118 -151
- strix/prompts/vulnerabilities/xss.jinja +144 -196
- strix/prompts/vulnerabilities/xxe.jinja +151 -243
- strix/tools/agents_graph/agents_graph_actions.py +4 -3
- strix/tools/agents_graph/agents_graph_actions_schema.xml +10 -14
- strix/tools/registry.py +1 -1
- {strix_agent-0.1.17.dist-info → strix_agent-0.1.19.dist-info}/METADATA +55 -16
- {strix_agent-0.1.17.dist-info → strix_agent-0.1.19.dist-info}/RECORD +41 -28
- {strix_agent-0.1.17.dist-info → strix_agent-0.1.19.dist-info}/LICENSE +0 -0
- {strix_agent-0.1.17.dist-info → strix_agent-0.1.19.dist-info}/WHEEL +0 -0
- {strix_agent-0.1.17.dist-info → strix_agent-0.1.19.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
<fastapi_security_testing_guide>
|
|
2
|
+
<title>FASTAPI — ADVERSARIAL TESTING PLAYBOOK</title>
|
|
3
|
+
|
|
4
|
+
<critical>FastAPI (on Starlette) spans HTTP, WebSocket, and background tasks with powerful dependency injection and automatic OpenAPI. Security breaks where identity, authorization, and validation drift across routers, middlewares, proxies, and channels. Treat every dependency, header, and object reference as untrusted until bound to the caller and tenant.</critical>
|
|
5
|
+
|
|
6
|
+
<surface_map>
|
|
7
|
+
- ASGI stack: Starlette middlewares (CORS, TrustedHost, ProxyHeaders, Session), exception handlers, lifespan events
|
|
8
|
+
- Routers/sub-apps: APIRouter with prefixes/tags, mounted apps (StaticFiles, admin subapps), `include_router`, versioned paths
|
|
9
|
+
- Security and DI: `Depends`, `Security`, `OAuth2PasswordBearer`, `HTTPBearer`, scopes, per-router vs per-route dependencies
|
|
10
|
+
- Models and validation: Pydantic v1/v2 models, unions/Annotated, custom validators, extra fields policy, coercion
|
|
11
|
+
- Docs and schema: `/openapi.json`, `/docs`, `/redoc`, alternative docs_url/redoc_url, schema extensions
|
|
12
|
+
- Files and static: `UploadFile`, `File`, `FileResponse`, `StaticFiles` mounts, template engines (`Jinja2Templates`)
|
|
13
|
+
- Channels: HTTP (sync/async), WebSocket, StreamingResponse/SSE, BackgroundTasks/Task queues
|
|
14
|
+
- Deployment: Uvicorn/Gunicorn, reverse proxies/CDN, TLS termination, header trust
|
|
15
|
+
</surface_map>
|
|
16
|
+
|
|
17
|
+
<methodology>
|
|
18
|
+
1. Enumerate routes from OpenAPI and via crawling; diff with 404-fuzzing for hidden endpoints (`include_in_schema=False`).
|
|
19
|
+
2. Build a Principal × Channel × Content-Type matrix (unauth, user, staff/admin; HTTP vs WebSocket; JSON/form/multipart) and capture baselines.
|
|
20
|
+
3. For each route, identify dependencies (router-level and route-level). Attempt to satisfy security dependencies minimally, then mutate context (tokens, scopes, tenant headers) and object IDs.
|
|
21
|
+
4. Compare behavior across deployments: dev/stage/prod often differ in middlewares (CORS, TrustedHost, ProxyHeaders) and docs exposure.
|
|
22
|
+
</methodology>
|
|
23
|
+
|
|
24
|
+
<high_value_targets>
|
|
25
|
+
- `/openapi.json`, `/docs`, `/redoc` in production (full attack surface map; securitySchemes and server URLs)
|
|
26
|
+
- Auth flows: token endpoints, session/cookie bridges, OAuth device/PKCE, scope checks
|
|
27
|
+
- Admin/staff routers, feature-flagged routes, `include_in_schema=False` endpoints
|
|
28
|
+
- File upload/download, import/export/report endpoints, signed URL generators
|
|
29
|
+
- WebSocket endpoints carrying notifications, admin channels, or commands
|
|
30
|
+
- Background job creation/fetch (`/jobs/{id}`, `/tasks/{id}/result`)
|
|
31
|
+
- Mounted subapps (admin UI, storage browsers, metrics/health endpoints)
|
|
32
|
+
</high_value_targets>
|
|
33
|
+
|
|
34
|
+
<advanced_techniques>
|
|
35
|
+
<openapi_and_docs>
|
|
36
|
+
- Try default and alternate locations: `/openapi.json`, `/docs`, `/redoc`, `/api/openapi.json`, `/internal/openapi.json`.
|
|
37
|
+
- If OpenAPI is exposed, mine: paths, parameter names, securitySchemes, scopes, servers; find endpoints hidden in UI but present in schema.
|
|
38
|
+
- Schema drift: endpoints with `include_in_schema=False` won’t appear—use wordlists based on tags/prefixes and common admin/debug names.
|
|
39
|
+
</openapi_and_docs>
|
|
40
|
+
|
|
41
|
+
<dependency_injection_and_security>
|
|
42
|
+
- Router vs route dependencies: routes may miss security dependencies present elsewhere; check for unprotected variants of protected actions.
|
|
43
|
+
- Minimal satisfaction: `OAuth2PasswordBearer` only yields a token string—verify if any route treats token presence as auth without verification.
|
|
44
|
+
- Scope checks: ensure scopes are enforced by the dependency (e.g., `Security(...)`); routes using `Depends` instead may ignore requested scopes.
|
|
45
|
+
- Header/param aliasing: DI sources headers/cookies/query by name; try case variations and duplicates to influence which value binds.
|
|
46
|
+
</dependency_injection_and_security>
|
|
47
|
+
|
|
48
|
+
<auth_and_jwt>
|
|
49
|
+
- Token misuse: developers may decode JWTs without verifying signature/issuer/audience; attempt unsigned/attacker-signed tokens and cross-service audiences.
|
|
50
|
+
- Algorithm/key confusion: try HS/RS cross-use if verification is not pinned; inject `kid` header targeting local files/paths where custom key lookup exists.
|
|
51
|
+
- Session bridges: check cookies set via SessionMiddleware or custom cookies. Attempt session fixation and forging if weak `secret_key` or predictable signing is used.
|
|
52
|
+
- Device/PKCE flows: verify strict PKCE S256 and state/nonce enforcement if OAuth/OIDC is integrated.
|
|
53
|
+
</auth_and_jwt>
|
|
54
|
+
|
|
55
|
+
<cors_and_csrf>
|
|
56
|
+
- CORS reflection: broad `allow_origin_regex` or mis-specified origins can permit cross-site reads; test arbitrary Origins and credentialed requests.
|
|
57
|
+
- CSRF: FastAPI/Starlette lack built-in CSRF. If cookies carry auth, attempt state-changing requests via cross-site forms/XHR; validate origin header checks and same-site settings.
|
|
58
|
+
</cors_and_csrf>
|
|
59
|
+
|
|
60
|
+
<proxy_and_host_trust>
|
|
61
|
+
- ProxyHeadersMiddleware: if enabled without network boundary, spoof `X-Forwarded-For/Proto` to influence auth/IP gating and secure redirects.
|
|
62
|
+
- TrustedHostMiddleware absent or lax: perform Host header poisoning; attempt password reset links / absolute URL generation under attacker host.
|
|
63
|
+
- Upstream/CDN cache keys: ensure Vary on Authorization/Cookie/Tenant; try cache key confusion to leak personalized responses.
|
|
64
|
+
</proxy_and_host_trust>
|
|
65
|
+
|
|
66
|
+
<static_and_uploads>
|
|
67
|
+
- UploadFile.filename: attempt path traversal and control characters; verify server joins/sanitizes and enforces storage roots.
|
|
68
|
+
- FileResponse/StaticFiles: confirm directory boundaries and index/auto-listing; probe symlinks and case/encoding variants.
|
|
69
|
+
- Parser differentials: send JSON vs multipart for the same route to hit divergent code paths/validators.
|
|
70
|
+
</static_and_uploads>
|
|
71
|
+
|
|
72
|
+
<template_injection>
|
|
73
|
+
- Jinja2 templates via `TemplateResponse`: search for unescaped injection in variables and filters. Probe with minimal expressions:
|
|
74
|
+
{% raw %}- `{{7*7}}` → arithmetic confirmation
|
|
75
|
+
- `{{cycler.__init__.__globals__['os'].popen('id').read()}}` for RCE in unsafe contexts{% endraw %}
|
|
76
|
+
- Confirm autoescape and strict sandboxing; inspect custom filters/globals.
|
|
77
|
+
</template_injection>
|
|
78
|
+
|
|
79
|
+
<ssrf_and_outbound>
|
|
80
|
+
- Endpoints fetching user-supplied URLs (imports, previews, webhooks validation): test loopback/RFC1918/IPv6, redirects, DNS rebinding, and header control.
|
|
81
|
+
- Library behavior (httpx/requests): examine redirect policy, header forwarding, and protocol support; try `file://`, `ftp://`, or gopher-like shims if custom clients are used.
|
|
82
|
+
</ssrf_and_outbound>
|
|
83
|
+
|
|
84
|
+
<websockets>
|
|
85
|
+
- Authenticate each connection (query/header/cookie). Attempt cross-origin handshakes and cookie-bearing WS from untrusted origins.
|
|
86
|
+
- Topic naming and authorization: if using user/tenant IDs in channels, subscribe/publish to foreign IDs.
|
|
87
|
+
- Message-level checks: ensure per-message authorization, not only at handshake.
|
|
88
|
+
</websockets>
|
|
89
|
+
|
|
90
|
+
<background_tasks_and_jobs>
|
|
91
|
+
- BackgroundTasks that act on IDs must re-enforce ownership/tenant at execution time. Attempt to fetch/cancel others’ jobs by referencing their IDs.
|
|
92
|
+
- Export/import pipelines: test job/result endpoints for IDOR and cross-tenant leaks.
|
|
93
|
+
</background_tasks_and_jobs>
|
|
94
|
+
|
|
95
|
+
<multi_app_mounting>
|
|
96
|
+
- Mounted subapps (e.g., `/admin`, `/static`, `/metrics`) may bypass global middlewares. Confirm middleware parity and auth on mounts.
|
|
97
|
+
</multi_app_mounting>
|
|
98
|
+
</advanced_techniques>
|
|
99
|
+
|
|
100
|
+
<bypass_techniques>
|
|
101
|
+
- Content-type switching: `application/json` ↔ `application/x-www-form-urlencoded` ↔ `multipart/form-data` to traverse alternate validators/handlers.
|
|
102
|
+
- Parameter duplication and case variants to exploit DI precedence.
|
|
103
|
+
- Method confusion via proxies (e.g., `X-HTTP-Method-Override`) if upstream respects it while app does not.
|
|
104
|
+
- Race windows around dependency-validated state transitions (issue token then mutate with parallel requests).
|
|
105
|
+
</bypass_techniques>
|
|
106
|
+
|
|
107
|
+
<special_contexts>
|
|
108
|
+
<pydantic_edges>
|
|
109
|
+
- Coercion: strings to ints/bools, empty strings to None; exploit truthiness and boundary conditions.
|
|
110
|
+
- Extra fields: if models allow/ignore extras, sneak in control fields for downstream logic (scope/role/ownerId) that are later trusted.
|
|
111
|
+
- Unions and `Annotated`: craft shapes hitting unintended branches.
|
|
112
|
+
</pydantic_edges>
|
|
113
|
+
|
|
114
|
+
<graphql_and_alt_stacks>
|
|
115
|
+
- If GraphQL (Strawberry/Graphene) is mounted, validate resolver-level authorization and IDOR on node/global IDs.
|
|
116
|
+
- If SQLModel/SQLAlchemy present, probe for raw query usage and row-level authorization gaps.
|
|
117
|
+
</graphql_and_alt_stacks>
|
|
118
|
+
</special_contexts>
|
|
119
|
+
|
|
120
|
+
<validation>
|
|
121
|
+
1. Show unauthorized data access or action with side-by-side owner vs non-owner requests (or different tenants).
|
|
122
|
+
2. Demonstrate cross-channel consistency (HTTP and WebSocket) for the same rule.
|
|
123
|
+
3. Include proof where proxies/headers/caches alter outcomes (Host/XFF/CORS).
|
|
124
|
+
4. Provide minimal payloads confirming template/SSRF execution or token misuse, with safe or OAST-based oracles.
|
|
125
|
+
5. Document exact dependency paths (router-level, route-level) that missed enforcement.
|
|
126
|
+
</validation>
|
|
127
|
+
|
|
128
|
+
<pro_tips>
|
|
129
|
+
1. Always fetch `/openapi.json` first; it’s the blueprint. If hidden, brute-force likely admin/report/export routes.
|
|
130
|
+
2. Trace dependencies per route; map which ones enforce auth/scopes vs merely parse input.
|
|
131
|
+
3. Treat tokens returned by `OAuth2PasswordBearer` as untrusted strings—verify actual signature and claims on the server.
|
|
132
|
+
4. Test CORS with arbitrary Origins and with credentials; verify preflight and actual request deltas.
|
|
133
|
+
5. Add Host and X-Forwarded-* fuzzing when behind proxies; watch for redirect/absolute URL differences.
|
|
134
|
+
6. For uploads, vary filename encodings, dot segments, and NUL-like bytes; verify storage paths and served URLs.
|
|
135
|
+
7. Use content-type toggling to hit alternate validators and code paths.
|
|
136
|
+
8. For WebSockets, test cookie-based auth, origin restrictions, and per-message authorization.
|
|
137
|
+
9. Mine client bundles/env for secret paths and preview/admin flags; many teams hide routes via UI only.
|
|
138
|
+
10. Keep PoCs minimal and durable (IDs, headers, small payloads) and prefer reproducible diffs over noisy payloads.
|
|
139
|
+
</pro_tips>
|
|
140
|
+
|
|
141
|
+
<remember>Authorization and validation must be enforced in the dependency graph and at the resource boundary for every path and channel. If any route, middleware, or mount skips binding subject, action, and object/tenant, expect cross-user and cross-tenant breakage.</remember>
|
|
142
|
+
</fastapi_security_testing_guide>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<nextjs_security_testing_guide>
|
|
2
|
+
<title>NEXT.JS — ADVERSARIAL TESTING PLAYBOOK</title>
|
|
3
|
+
|
|
4
|
+
<critical>Modern Next.js combines multiple execution contexts (Edge, Node, RSC, client) with smart caching (ISR/RSC fetch cache), middleware, and server actions. Authorization and cache boundaries must be enforced consistently across all paths or attackers will cross tenants, leak data, or invoke privileged actions.</critical>
|
|
5
|
+
|
|
6
|
+
<surface_map>
|
|
7
|
+
- Routers: App Router (`app/`) and Pages Router (`pages/`) coexist; test both
|
|
8
|
+
- Runtimes: Node.js vs Edge (V8 isolates with restricted APIs)
|
|
9
|
+
- Data paths: RSC (server components), Client components, Route Handlers (`app/api/**`), API routes (`pages/api/**`)
|
|
10
|
+
- Middleware: `middleware.ts`/`_middleware.ts`
|
|
11
|
+
- Rendering modes: SSR, SSG, ISR, on-demand revalidation, draft/preview mode
|
|
12
|
+
- Images: `next/image` optimization and remote loader
|
|
13
|
+
- Auth: NextAuth.js (callbacks, CSRF/state, callbackUrl), custom JWT/session bridges
|
|
14
|
+
- Server Actions: streamed POST with `Next-Action` header and action IDs
|
|
15
|
+
</surface_map>
|
|
16
|
+
|
|
17
|
+
<methodology>
|
|
18
|
+
1. Inventory routes (pages + app), static vs dynamic segments, and params. Map middleware coverage and runtime per path.
|
|
19
|
+
2. Capture baseline for each role (unauth, user, admin) across SSR, API routes, Route Handlers, Server Actions, and streaming data.
|
|
20
|
+
3. Diff responses while toggling runtime (Edge/Node), content-type, fetch cache directives, and preview/draft mode.
|
|
21
|
+
4. Probe caching and revalidation boundaries (ISR, RSC fetch, CDN) for cross-user/tenant leaks.
|
|
22
|
+
</methodology>
|
|
23
|
+
|
|
24
|
+
<high_value_targets>
|
|
25
|
+
- Middleware-protected routes (auth, geo, A/B)
|
|
26
|
+
- Admin/staff paths, draft/preview content, on-demand revalidate endpoints
|
|
27
|
+
- RSC payloads and flight data, streamed responses (server actions)
|
|
28
|
+
- Image optimizer and custom loaders, remotePatterns/domains
|
|
29
|
+
- NextAuth callbacks (`/api/auth/callback/*`), sign-in providers, CSRF/state handling
|
|
30
|
+
- Edge-only features (bot protection, IP gates) and their Node equivalents
|
|
31
|
+
</high_value_targets>
|
|
32
|
+
|
|
33
|
+
<advanced_techniques>
|
|
34
|
+
<middleware_bypass>
|
|
35
|
+
- Test for CVE-class middleware bypass via `x-middleware-subrequest` crafting and `x-nextjs-data` probing. Look for 307 + `x-middleware-rewrite`/`x-nextjs-redirect` headers and attempt bypass on protected routes.
|
|
36
|
+
- Attempt direct route access on Node vs Edge runtimes; confirm protection parity.
|
|
37
|
+
</middleware_bypass>
|
|
38
|
+
|
|
39
|
+
<server_actions>
|
|
40
|
+
- Capture streamed POSTs containing `Next-Action` headers. Map hashed action IDs via source maps or specialized tooling to discover hidden actions.
|
|
41
|
+
- Invoke actions out of UI flow and with alternate content-types; verify server-side authorization is enforced per action and not assumed from client state.
|
|
42
|
+
- Try cross-tenant/object references within action payloads to expose BOLA/IDOR via server actions.
|
|
43
|
+
</server_actions>
|
|
44
|
+
|
|
45
|
+
<rsc_and_cache>
|
|
46
|
+
- RSC fetch cache: probe `fetch` cache modes (force-cache, default, no-store) and revalidate tags/paths. Look for user-bound data cached without identity keys (ETag/Set-Cookie unaware).
|
|
47
|
+
- Confirm that personalized data is rendered via `no-store` or properly keyed; attempt cross-user content via shared caches/CDN.
|
|
48
|
+
- Inspect Flight data streams for serialized sensitive fields leaking through props.
|
|
49
|
+
</rsc_and_cache>
|
|
50
|
+
|
|
51
|
+
<isr_and_revalidation>
|
|
52
|
+
- Identify ISR pages (stale-while-revalidate). Check if responses may include user-bound fragments or tenant-dependent content.
|
|
53
|
+
- On-demand revalidation endpoints: look for weak secrets in URLs, referer-disclosed tokens, or unvalidated hosts triggering `revalidatePath`/`revalidateTag`.
|
|
54
|
+
- Attempt header-smuggling or method variations to trigger revalidation flows.
|
|
55
|
+
</isr_and_revalidation>
|
|
56
|
+
|
|
57
|
+
<draft_preview_mode>
|
|
58
|
+
- Draft/preview mode toggles via secret URLs/cookies; search for preview enable endpoints and secrets in client bundles/env leaks.
|
|
59
|
+
- Try setting preview cookies from subdomains, alternate paths, or through open redirects; observe content differences and persistence.
|
|
60
|
+
</draft_preview_mode>
|
|
61
|
+
|
|
62
|
+
<next_image_ssrf>
|
|
63
|
+
- Review `images.domains`/`remotePatterns` in `next.config.js`; test SSRF to internal hosts (IPv4/IPv6 variants, DNS rebinding) if patterns are broad.
|
|
64
|
+
- Custom loader functions may fetch with arbitrary URLs; test protocol smuggling and redirection chains.
|
|
65
|
+
- Attempt cache poisoning: craft same URL with different normalization to affect other users.
|
|
66
|
+
</next_image_ssrf>
|
|
67
|
+
|
|
68
|
+
<nextauth_pitfalls>
|
|
69
|
+
- State/nonce/PKCE: validate per-provider correctness; attempt missing/relaxed checks leading to login CSRF or token mix-up.
|
|
70
|
+
- Callback URL restrictions: open redirect in `callbackUrl` or mis-scoped allowed hosts; hijack sessions by forcing callbacks.
|
|
71
|
+
- JWT/session bridges: audience/issuer not enforced across API routes/Route Handlers; attempt cross-service token reuse.
|
|
72
|
+
</nextauth_pitfalls>
|
|
73
|
+
|
|
74
|
+
<edge_runtime_diffs>
|
|
75
|
+
- Edge runtime lacks certain Node APIs; defenses relying on Node-only modules may be skipped. Compare behavior of the same route in Edge vs Node.
|
|
76
|
+
- Header trust and IP determination can differ at the edge; test auth decisions tied to `x-forwarded-*` variance.
|
|
77
|
+
</edge_runtime_diffs>
|
|
78
|
+
|
|
79
|
+
<client_and_dom>
|
|
80
|
+
- Identify `dangerouslySetInnerHTML`, Markdown renderers, and user-controlled href/src attributes. Validate CSP/Trusted Types coverage for SSR/CSR/hydration.
|
|
81
|
+
- Attack hydration boundaries: server vs client render mismatches can enable gadget-based XSS.
|
|
82
|
+
</client_and_dom>
|
|
83
|
+
</advanced_techniques>
|
|
84
|
+
|
|
85
|
+
<bypass_techniques>
|
|
86
|
+
- Content-type switching: `application/json` ↔ `multipart/form-data` ↔ `application/x-www-form-urlencoded` to traverse alternate code paths.
|
|
87
|
+
- Method override/tunneling: `_method`, `X-HTTP-Method-Override`, GET on endpoints unexpectedly accepting writes.
|
|
88
|
+
- Case/param aliasing and query duplication affecting middleware vs handler parsing.
|
|
89
|
+
- Cache key confusion at CDN/proxy (lack of Vary on auth cookies/headers) to leak personalized SSR/ISR content.
|
|
90
|
+
</bypass_techniques>
|
|
91
|
+
|
|
92
|
+
<special_contexts>
|
|
93
|
+
<uploads_and_files>
|
|
94
|
+
- API routes and Route Handlers handling file uploads: check MIME sniffing, Content-Disposition, stored path traversal, and public serving of user files.
|
|
95
|
+
- Validate signing/scoping of any generated file URLs (short TTL, audience-bound).
|
|
96
|
+
</uploads_and_files>
|
|
97
|
+
|
|
98
|
+
<integrations_and_webhooks>
|
|
99
|
+
- Webhooks that trigger revalidation/imports: require HMAC verification; test with replay and cross-tenant object IDs.
|
|
100
|
+
- Analytics/AB testing flags controlled via cookies/headers; ensure they do not unlock privileged server paths.
|
|
101
|
+
</integrations_and_webhooks>
|
|
102
|
+
</special_contexts>
|
|
103
|
+
|
|
104
|
+
<validation>
|
|
105
|
+
1. Provide side-by-side requests for different principals showing cross-user/tenant content or actions.
|
|
106
|
+
2. Prove cache boundary failure (RSC/ISR/CDN) with response diffs or ETag collisions.
|
|
107
|
+
3. Demonstrate server action invocation outside UI with insufficient authorization checks.
|
|
108
|
+
4. Show middleware bypass (where applicable) with explicit headers and resulting protected content.
|
|
109
|
+
5. Include runtime parity checks (Edge vs Node) proving inconsistent enforcement.
|
|
110
|
+
</validation>
|
|
111
|
+
|
|
112
|
+
<pro_tips>
|
|
113
|
+
1. Enumerate with both App and Pages routers: many apps ship a hybrid surface.
|
|
114
|
+
2. Treat caching as an identity boundary—test with cookies stripped, altered, and with Vary/ETag diffs.
|
|
115
|
+
3. Decode client bundles for preview/revalidate secrets, action IDs, and hidden routes.
|
|
116
|
+
4. Use streaming-aware tooling to capture server actions and RSC payloads; diff flight data.
|
|
117
|
+
5. For NextAuth, fuzz provider params (state, nonce, scope, callbackUrl) and verify strictness.
|
|
118
|
+
6. Always retest under Edge and Node; misconfigurations often exist in only one runtime.
|
|
119
|
+
7. Probe `next/image` aggressively but safely—test IPv6/obscure encodings and redirect behavior.
|
|
120
|
+
8. Validate negative paths: other-user IDs, other-tenant headers/subdomains, lower roles.
|
|
121
|
+
9. Focus on export/report/download endpoints; they often bypass resolver-level checks.
|
|
122
|
+
10. Document minimal, reproducible PoCs; avoid noisy payloads—prefer precise diffs.
|
|
123
|
+
</pro_tips>
|
|
124
|
+
|
|
125
|
+
<remember>Next.js security breaks where identity, authorization, and caching diverge across routers, runtimes, and data paths. Bind subject, action, and object on every path, and key caches to identity and tenant explicitly.</remember>
|
|
126
|
+
</nextjs_security_testing_guide>
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
<graphql_protocol_guide>
|
|
2
|
+
<title>GRAPHQL — ADVANCED TESTING AND EXPLOITATION</title>
|
|
3
|
+
|
|
4
|
+
<critical>GraphQL’s flexibility enables powerful data access, but also unique failures: field- and edge-level authorization drift, schema exposure (even with introspection off), alias/batch abuse, resolver injection, federated trust gaps, and complexity/fragment bombs. Bind subject→action→object at resolver boundaries and validate across every transport and feature flag.</critical>
|
|
5
|
+
|
|
6
|
+
<scope>
|
|
7
|
+
- Queries, mutations, subscriptions (graphql-ws, graphql-transport-ws)
|
|
8
|
+
- Persisted queries/Automatic Persisted Queries (APQ)
|
|
9
|
+
- Federation (Apollo/GraphQL Mesh): _service SDL and _entities
|
|
10
|
+
- File uploads (GraphQL multipart request spec)
|
|
11
|
+
- Relay conventions: global node IDs, connections/cursors
|
|
12
|
+
</scope>
|
|
13
|
+
|
|
14
|
+
<methodology>
|
|
15
|
+
1. Fingerprint endpoint(s), transport(s), and stack (framework, plugins, gateway). Note GraphiQL/Playground exposure and CORS/credentials.
|
|
16
|
+
2. Obtain multiple principals (unauth, basic, premium, admin/staff) and capture at least one valid object ID per subject.
|
|
17
|
+
3. Acquire schema via introspection; if disabled, infer iteratively from errors, field suggestions, __typename probes, vocabulary brute-force.
|
|
18
|
+
4. Build an Actor × Operation × Type/Field matrix. Exercise each resolver path with swapped IDs, roles, tenants, and channels (REST proxies, GraphQL HTTP, WS).
|
|
19
|
+
5. Validate consistency: same authorization and validation across queries, mutations, subscriptions, batch/alias, persisted queries, and federation.
|
|
20
|
+
</methodology>
|
|
21
|
+
|
|
22
|
+
<discovery_techniques>
|
|
23
|
+
<endpoint_finding>
|
|
24
|
+
- Common paths: /graphql, /api/graphql, /v1/graphql, /gql
|
|
25
|
+
- Probe with minimal canary:
|
|
26
|
+
{% raw %}
|
|
27
|
+
POST /graphql {"query":"{__typename}"}
|
|
28
|
+
GET /graphql?query={__typename}
|
|
29
|
+
{% endraw %}
|
|
30
|
+
- Detect GraphiQL/Playground; note if accessible cross-origin and with credentials.
|
|
31
|
+
</endpoint_finding>
|
|
32
|
+
|
|
33
|
+
<introspection_and_inference>
|
|
34
|
+
- If enabled, dump full schema; otherwise:
|
|
35
|
+
- Use __typename on candidate fields to confirm types
|
|
36
|
+
- Abuse field suggestions and error shapes to enumerate names/args
|
|
37
|
+
- Infer enums from “expected one of” errors; coerce types by providing wrong shapes
|
|
38
|
+
- Reconstruct edges from pagination and connection hints (pageInfo, edges/node)
|
|
39
|
+
</introspection_and_inference>
|
|
40
|
+
|
|
41
|
+
<schema_construction>
|
|
42
|
+
- Map root operations, object types, interfaces/unions, directives (@auth, @defer, @stream), and custom scalars (Upload, JSON, DateTime)
|
|
43
|
+
- Identify sensitive fields: email, tokens, roles, billing, file keys, admin flags
|
|
44
|
+
- Note cascade paths where child resolvers may skip auth under parent assumptions
|
|
45
|
+
</schema_construction>
|
|
46
|
+
</discovery_techniques>
|
|
47
|
+
|
|
48
|
+
<exploitation_techniques>
|
|
49
|
+
<authorization_and_idor>
|
|
50
|
+
- Test field-level and edge-level checks, not just top-level gates. Pair owned vs foreign IDs within the same request via aliases to diff responses.
|
|
51
|
+
{% raw %}
|
|
52
|
+
query {
|
|
53
|
+
me { id }
|
|
54
|
+
a: order(id:"A_OWNER") { id total owner { id email } }
|
|
55
|
+
b: order(id:"B_FOREIGN") { id total owner { id email } }
|
|
56
|
+
}
|
|
57
|
+
{% endraw %}
|
|
58
|
+
- Probe mutations for partial updates that bypass validation (JSON Merge Patch semantics in inputs).
|
|
59
|
+
- Validate node/global ID resolvers (Relay) bind to the caller; decode/replace base64 IDs and compare access.
|
|
60
|
+
</authorization_and_idor>
|
|
61
|
+
|
|
62
|
+
<batching_and_alias>
|
|
63
|
+
- Alias to perform many logically separate reads in one operation; watch for per-request vs per-field auth discrepancies
|
|
64
|
+
- If array batching is supported (non-standard), submit multiple operations to bypass rate limits and achieve partial failures
|
|
65
|
+
{% raw %}
|
|
66
|
+
query {
|
|
67
|
+
u1:user(id:"1"){email}
|
|
68
|
+
u2:user(id:"2"){email}
|
|
69
|
+
u3:user(id:"3"){email}
|
|
70
|
+
}
|
|
71
|
+
{% endraw %}
|
|
72
|
+
</batching_and_alias>
|
|
73
|
+
|
|
74
|
+
<variable_and_shape_abuse>
|
|
75
|
+
- Scalars vs objects vs arrays: {% raw %}{id:123}{% endraw} vs {% raw %}{id:"123"}{% endraw} vs {% raw %}{id:[123]}{% endraw}; send null/empty/0/-1 and extra object keys retained by backend
|
|
76
|
+
- Duplicate keys in JSON variables: {% raw %}{"id":1,"id":2}{% endraw} (parser precedence), default argument values, coercion errors leaking field names
|
|
77
|
+
</variable_and_shape_abuse>
|
|
78
|
+
|
|
79
|
+
<cursor_and_projection>
|
|
80
|
+
- Decode cursors (often base64) to manipulate offsets/IDs and skip filters
|
|
81
|
+
- Abuse selection sets and fragments to force overfetching of sensitive subfields
|
|
82
|
+
</cursor_and_projection>
|
|
83
|
+
|
|
84
|
+
<file_uploads>
|
|
85
|
+
- GraphQL multipart: test multiple Upload scalars, filename/path tricks, unexpected content-types, oversize chunks; verify server-side ownership/scoping for returned URLs
|
|
86
|
+
</file_uploads>
|
|
87
|
+
</exploitation_techniques>
|
|
88
|
+
|
|
89
|
+
<advanced_techniques>
|
|
90
|
+
<introspection_bypass>
|
|
91
|
+
- Field suggestion leakage: submit near-miss names to harvest suggestions
|
|
92
|
+
- Error taxonomy: different codes/messages for unknown field vs unauthorized field reveal existence
|
|
93
|
+
- __typename sprinkling on edges to confirm types without schema
|
|
94
|
+
</introspection_bypass>
|
|
95
|
+
|
|
96
|
+
<defer_and_stream>
|
|
97
|
+
- Use @defer and @stream to obtain partial results or subtrees hidden by parent checks; confirm server supports incremental delivery
|
|
98
|
+
{% raw %}
|
|
99
|
+
query @defer {
|
|
100
|
+
me { id }
|
|
101
|
+
... @defer { adminPanel { secrets } }
|
|
102
|
+
}
|
|
103
|
+
{% endraw %}
|
|
104
|
+
</defer_and_stream>
|
|
105
|
+
|
|
106
|
+
<fragment_and_complexity_bombs>
|
|
107
|
+
- Recursive fragment spreads and wide selection sets cause CPU/memory spikes; craft minimal reproducible bombs to validate cost limits
|
|
108
|
+
{% raw %}
|
|
109
|
+
fragment x on User { friends { ...x } }
|
|
110
|
+
query { me { ...x } }
|
|
111
|
+
{% endraw %}
|
|
112
|
+
- Validate depth/complexity limiting, query cost analyzers, and timeouts
|
|
113
|
+
</fragment_and_complexity_bombs>
|
|
114
|
+
|
|
115
|
+
<federation>
|
|
116
|
+
- Apollo Federation: query _service { sdl } if exposed; target _entities to materialize foreign objects by key without proper auth in subgraphs
|
|
117
|
+
{% raw %}
|
|
118
|
+
query {
|
|
119
|
+
_entities(representations:[
|
|
120
|
+
{__typename:"User", id:"TARGET"}
|
|
121
|
+
]) { ... on User { email roles } }
|
|
122
|
+
}
|
|
123
|
+
{% endraw %}
|
|
124
|
+
- Look for auth done at gateway but skipped in subgraph resolvers; cross-subgraph IDOR via inconsistent ownership checks
|
|
125
|
+
</federation>
|
|
126
|
+
|
|
127
|
+
<subscriptions>
|
|
128
|
+
- Check message-level authorization, not only handshake; attempt to subscribe to channels for other users/tenants; test cross-tenant event leakage
|
|
129
|
+
- Abuse filter args in subscription resolvers to reference foreign IDs
|
|
130
|
+
</subscriptions>
|
|
131
|
+
|
|
132
|
+
<persisted_queries>
|
|
133
|
+
- APQ hashes can be guessed/bruteforced or leaked from clients; replay privileged operations by supplying known hashes with attacker variables
|
|
134
|
+
- Validate that hash→operation mapping enforces principal and operation allowlists
|
|
135
|
+
</persisted_queries>
|
|
136
|
+
|
|
137
|
+
<csrf_and_cors>
|
|
138
|
+
- If cookie-auth is used and GET is accepted, test CSRF on mutations via query parameters; verify SameSite and origin checks
|
|
139
|
+
- Cross-origin GraphiQL/Playground exposure with credentials can leak data via postMessage bridges
|
|
140
|
+
</csrf_and_cors>
|
|
141
|
+
|
|
142
|
+
<waf_evasion>
|
|
143
|
+
- Reshape queries: comments, block strings, Unicode escapes, alias/fragment indirection, JSON variables vs inline args, GET vs POST vs application/graphql
|
|
144
|
+
- Split fields across fragments and inline spreads to avoid naive signatures
|
|
145
|
+
</waf_evasion>
|
|
146
|
+
</advanced_techniques>
|
|
147
|
+
|
|
148
|
+
<bypass_techniques>
|
|
149
|
+
<transport_and_parsers>
|
|
150
|
+
- Toggle content-types: application/json, application/graphql, multipart/form-data; try GET with query and variables params
|
|
151
|
+
- HTTP/2 multiplexing and connection reuse to widen timing windows and rate limits
|
|
152
|
+
</transport_and_parsers>
|
|
153
|
+
|
|
154
|
+
<naming_and_aliasing>
|
|
155
|
+
- Case/underscore variations, Unicode homoglyphs (server-dependent), aliases masking sensitive field names
|
|
156
|
+
</naming_and_aliasing>
|
|
157
|
+
|
|
158
|
+
<gateway_and_cache>
|
|
159
|
+
- CDN/key confusion: responses cached without considering Authorization or variables; manipulate Vary and Accept headers
|
|
160
|
+
- Redirects and 304/206 behaviors leaking partially cached GraphQL responses
|
|
161
|
+
</gateway_and_cache>
|
|
162
|
+
</bypass_techniques>
|
|
163
|
+
|
|
164
|
+
<special_contexts>
|
|
165
|
+
<relay>
|
|
166
|
+
- node(id:…) global resolution: decode base64, swap type/id pairs, ensure per-type authorization is enforced inside resolvers
|
|
167
|
+
- Connections: verify that filters (owner/tenant) apply before pagination; cursor tampering should not cross ownership boundaries
|
|
168
|
+
</relay>
|
|
169
|
+
|
|
170
|
+
<server_plugins>
|
|
171
|
+
- Custom directives (@auth, @private) and plugins often annotate intent but do not enforce; verify actual checks in each resolver path
|
|
172
|
+
</server_plugins>
|
|
173
|
+
</special_contexts>
|
|
174
|
+
|
|
175
|
+
<chaining_attacks>
|
|
176
|
+
- GraphQL + IDOR: enumerate IDs via list fields, then fetch or mutate foreign objects
|
|
177
|
+
- GraphQL + CSRF: trigger mutations cross-origin when cookies/auth are accepted without proper checks
|
|
178
|
+
- GraphQL + SSRF: resolvers that fetch URLs (webhooks, metadata) abused to reach internal services
|
|
179
|
+
</chaining_attacks>
|
|
180
|
+
|
|
181
|
+
<validation>
|
|
182
|
+
1. Provide paired requests (owner vs non-owner) differing only in identifiers/roles that demonstrate unauthorized access or mutation.
|
|
183
|
+
2. Prove resolver-level bypass: show top-level checks present but child field/edge exposes data.
|
|
184
|
+
3. Demonstrate transport parity: reproduce via HTTP and WS (subscriptions) or via persisted queries.
|
|
185
|
+
4. Minimize payloads; document exact selection sets and variable shapes used.
|
|
186
|
+
</validation>
|
|
187
|
+
|
|
188
|
+
<false_positives>
|
|
189
|
+
- Introspection available only on non-production/stub endpoints
|
|
190
|
+
- Public fields by design with documented scopes
|
|
191
|
+
- Aggregations or counts without sensitive attributes
|
|
192
|
+
- Properly enforced depth/complexity and per-resolver authorization across transports
|
|
193
|
+
</false_positives>
|
|
194
|
+
|
|
195
|
+
<impact>
|
|
196
|
+
- Cross-account/tenant data exposure and unauthorized state changes
|
|
197
|
+
- Bypass of federation boundaries enabling lateral access across services
|
|
198
|
+
- Credential/session leakage via lax CORS/CSRF around GraphiQL/Playground
|
|
199
|
+
</impact>
|
|
200
|
+
|
|
201
|
+
<pro_tips>
|
|
202
|
+
1. Always diff the same operation under multiple principals with aliases in one request.
|
|
203
|
+
2. Sprinkle __typename to map types quickly when schema is hidden.
|
|
204
|
+
3. Attack edges: child resolvers often skip auth compared to parents.
|
|
205
|
+
4. Try @defer/@stream and subscriptions to slip gated data in incremental events.
|
|
206
|
+
5. Decode cursors and node IDs; assume base64 unless proven otherwise.
|
|
207
|
+
6. Federation: exercise _entities with crafted representations; subgraphs frequently trust gateway auth.
|
|
208
|
+
7. Persisted queries: extract hashes from clients; replay with attacker variables.
|
|
209
|
+
8. Keep payloads small and structured; restructure rather than enlarge to evade WAFs.
|
|
210
|
+
9. Validate defenses by code/config review where possible; don’t trust directives alone.
|
|
211
|
+
10. Prove impact with role-separated, transport-separated, minimal PoCs.
|
|
212
|
+
</pro_tips>
|
|
213
|
+
|
|
214
|
+
<remember>GraphQL security is resolver security. If any resolver on the path to a field fails to bind subject, object, and action, the graph leaks. Validate every path, every transport, every environment.</remember>
|
|
215
|
+
</graphql_protocol_guide>
|
|
File without changes
|