strix-agent 0.4.0__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.
Files changed (118) hide show
  1. strix/__init__.py +0 -0
  2. strix/agents/StrixAgent/__init__.py +4 -0
  3. strix/agents/StrixAgent/strix_agent.py +89 -0
  4. strix/agents/StrixAgent/system_prompt.jinja +404 -0
  5. strix/agents/__init__.py +10 -0
  6. strix/agents/base_agent.py +518 -0
  7. strix/agents/state.py +163 -0
  8. strix/interface/__init__.py +4 -0
  9. strix/interface/assets/tui_styles.tcss +694 -0
  10. strix/interface/cli.py +230 -0
  11. strix/interface/main.py +500 -0
  12. strix/interface/tool_components/__init__.py +39 -0
  13. strix/interface/tool_components/agents_graph_renderer.py +123 -0
  14. strix/interface/tool_components/base_renderer.py +62 -0
  15. strix/interface/tool_components/browser_renderer.py +120 -0
  16. strix/interface/tool_components/file_edit_renderer.py +99 -0
  17. strix/interface/tool_components/finish_renderer.py +31 -0
  18. strix/interface/tool_components/notes_renderer.py +108 -0
  19. strix/interface/tool_components/proxy_renderer.py +255 -0
  20. strix/interface/tool_components/python_renderer.py +34 -0
  21. strix/interface/tool_components/registry.py +72 -0
  22. strix/interface/tool_components/reporting_renderer.py +53 -0
  23. strix/interface/tool_components/scan_info_renderer.py +64 -0
  24. strix/interface/tool_components/terminal_renderer.py +131 -0
  25. strix/interface/tool_components/thinking_renderer.py +29 -0
  26. strix/interface/tool_components/user_message_renderer.py +43 -0
  27. strix/interface/tool_components/web_search_renderer.py +28 -0
  28. strix/interface/tui.py +1274 -0
  29. strix/interface/utils.py +559 -0
  30. strix/llm/__init__.py +15 -0
  31. strix/llm/config.py +20 -0
  32. strix/llm/llm.py +465 -0
  33. strix/llm/memory_compressor.py +212 -0
  34. strix/llm/request_queue.py +87 -0
  35. strix/llm/utils.py +87 -0
  36. strix/prompts/README.md +64 -0
  37. strix/prompts/__init__.py +109 -0
  38. strix/prompts/cloud/.gitkeep +0 -0
  39. strix/prompts/coordination/root_agent.jinja +41 -0
  40. strix/prompts/custom/.gitkeep +0 -0
  41. strix/prompts/frameworks/fastapi.jinja +142 -0
  42. strix/prompts/frameworks/nextjs.jinja +126 -0
  43. strix/prompts/protocols/graphql.jinja +215 -0
  44. strix/prompts/reconnaissance/.gitkeep +0 -0
  45. strix/prompts/technologies/firebase_firestore.jinja +177 -0
  46. strix/prompts/technologies/supabase.jinja +189 -0
  47. strix/prompts/vulnerabilities/authentication_jwt.jinja +147 -0
  48. strix/prompts/vulnerabilities/broken_function_level_authorization.jinja +146 -0
  49. strix/prompts/vulnerabilities/business_logic.jinja +171 -0
  50. strix/prompts/vulnerabilities/csrf.jinja +174 -0
  51. strix/prompts/vulnerabilities/idor.jinja +195 -0
  52. strix/prompts/vulnerabilities/information_disclosure.jinja +222 -0
  53. strix/prompts/vulnerabilities/insecure_file_uploads.jinja +188 -0
  54. strix/prompts/vulnerabilities/mass_assignment.jinja +141 -0
  55. strix/prompts/vulnerabilities/open_redirect.jinja +177 -0
  56. strix/prompts/vulnerabilities/path_traversal_lfi_rfi.jinja +142 -0
  57. strix/prompts/vulnerabilities/race_conditions.jinja +164 -0
  58. strix/prompts/vulnerabilities/rce.jinja +154 -0
  59. strix/prompts/vulnerabilities/sql_injection.jinja +151 -0
  60. strix/prompts/vulnerabilities/ssrf.jinja +135 -0
  61. strix/prompts/vulnerabilities/subdomain_takeover.jinja +155 -0
  62. strix/prompts/vulnerabilities/xss.jinja +169 -0
  63. strix/prompts/vulnerabilities/xxe.jinja +184 -0
  64. strix/runtime/__init__.py +19 -0
  65. strix/runtime/docker_runtime.py +399 -0
  66. strix/runtime/runtime.py +29 -0
  67. strix/runtime/tool_server.py +205 -0
  68. strix/telemetry/__init__.py +4 -0
  69. strix/telemetry/tracer.py +337 -0
  70. strix/tools/__init__.py +64 -0
  71. strix/tools/agents_graph/__init__.py +16 -0
  72. strix/tools/agents_graph/agents_graph_actions.py +621 -0
  73. strix/tools/agents_graph/agents_graph_actions_schema.xml +226 -0
  74. strix/tools/argument_parser.py +121 -0
  75. strix/tools/browser/__init__.py +4 -0
  76. strix/tools/browser/browser_actions.py +236 -0
  77. strix/tools/browser/browser_actions_schema.xml +183 -0
  78. strix/tools/browser/browser_instance.py +533 -0
  79. strix/tools/browser/tab_manager.py +342 -0
  80. strix/tools/executor.py +305 -0
  81. strix/tools/file_edit/__init__.py +4 -0
  82. strix/tools/file_edit/file_edit_actions.py +141 -0
  83. strix/tools/file_edit/file_edit_actions_schema.xml +128 -0
  84. strix/tools/finish/__init__.py +4 -0
  85. strix/tools/finish/finish_actions.py +174 -0
  86. strix/tools/finish/finish_actions_schema.xml +45 -0
  87. strix/tools/notes/__init__.py +14 -0
  88. strix/tools/notes/notes_actions.py +191 -0
  89. strix/tools/notes/notes_actions_schema.xml +150 -0
  90. strix/tools/proxy/__init__.py +20 -0
  91. strix/tools/proxy/proxy_actions.py +101 -0
  92. strix/tools/proxy/proxy_actions_schema.xml +267 -0
  93. strix/tools/proxy/proxy_manager.py +785 -0
  94. strix/tools/python/__init__.py +4 -0
  95. strix/tools/python/python_actions.py +47 -0
  96. strix/tools/python/python_actions_schema.xml +131 -0
  97. strix/tools/python/python_instance.py +172 -0
  98. strix/tools/python/python_manager.py +131 -0
  99. strix/tools/registry.py +196 -0
  100. strix/tools/reporting/__init__.py +6 -0
  101. strix/tools/reporting/reporting_actions.py +63 -0
  102. strix/tools/reporting/reporting_actions_schema.xml +30 -0
  103. strix/tools/terminal/__init__.py +4 -0
  104. strix/tools/terminal/terminal_actions.py +35 -0
  105. strix/tools/terminal/terminal_actions_schema.xml +146 -0
  106. strix/tools/terminal/terminal_manager.py +151 -0
  107. strix/tools/terminal/terminal_session.py +447 -0
  108. strix/tools/thinking/__init__.py +4 -0
  109. strix/tools/thinking/thinking_actions.py +18 -0
  110. strix/tools/thinking/thinking_actions_schema.xml +52 -0
  111. strix/tools/web_search/__init__.py +4 -0
  112. strix/tools/web_search/web_search_actions.py +80 -0
  113. strix/tools/web_search/web_search_actions_schema.xml +83 -0
  114. strix_agent-0.4.0.dist-info/LICENSE +201 -0
  115. strix_agent-0.4.0.dist-info/METADATA +282 -0
  116. strix_agent-0.4.0.dist-info/RECORD +118 -0
  117. strix_agent-0.4.0.dist-info/WHEEL +4 -0
  118. strix_agent-0.4.0.dist-info/entry_points.txt +3 -0
@@ -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
@@ -0,0 +1,177 @@
1
+ <firebase_firestore_security_guide>
2
+ <title>FIREBASE / FIRESTORE — ADVERSARIAL TESTING AND EXPLOITATION</title>
3
+
4
+ <critical>Most impactful findings in Firebase apps arise from weak Firestore/Realtime Database rules, Cloud Storage exposure, callable/onRequest Functions trusting client input, incorrect ID token validation, and over-trusted App Check. Treat every client-supplied field and token as untrusted. Bind subject/tenant on the server, not in the client.</critical>
5
+
6
+ <scope>
7
+ - Firestore (documents/collections, rules, REST/SDK)
8
+ - Realtime Database (JSON tree, rules)
9
+ - Cloud Storage (rules, signed URLs)
10
+ - Auth (ID tokens, custom claims, anonymous/sign-in providers)
11
+ - Cloud Functions (onCall/onRequest, triggers)
12
+ - Hosting rewrites, CDN/caching, CORS
13
+ - App Check (attestation) and its limits
14
+ </scope>
15
+
16
+ <methodology>
17
+ 1. Extract project config from client (apiKey, authDomain, projectId, appId, storageBucket, messagingSenderId). Identify all used Firebase products.
18
+ 2. Obtain multiple principals: unauth, anonymous (if enabled), basic user A, user B, and any staff/admin if available. Capture their ID tokens.
19
+ 3. Build Resource × Action × Principal matrix across Firestore/Realtime/Storage/Functions. Exercise every action via SDK and raw REST (googleapis) to detect parity gaps.
20
+ 4. Start from list/query paths (where allowed) to seed IDs; then swap document paths, tenants, and user IDs across principals and transports.
21
+ </methodology>
22
+
23
+ <architecture>
24
+ - Firestore REST: https://firestore.googleapis.com/v1/projects/<project>/databases/(default)/documents/<path>
25
+ - Storage REST: https://storage.googleapis.com/storage/v1/b/<bucket>
26
+ - Auth: Google-signed ID tokens (iss accounts.google.com/securetoken.google.com/<project>), aud <project/app-id>; identity is in sub/uid.
27
+ - Rules engines: separate for Firestore, Realtime DB, and Storage; Functions bypass rules when using Admin SDK.
28
+ </architecture>
29
+
30
+ <auth_and_tokens>
31
+ - ID token verification must enforce issuer, audience (project), signature (Google JWKS), expiration, and optionally App Check binding when used.
32
+ - Custom claims are appended by Admin SDK; client-supplied claims are ignored by Auth but may be trusted by app code if copied into docs.
33
+ - Pitfalls:
34
+ - Accepting any JWT with valid signature but wrong audience/project.
35
+ - Trusting uid/account IDs from request body instead of context.auth.uid in Functions.
36
+ - Mixing session cookies and ID tokens without verifying both paths equivalently.
37
+ - Tests:
38
+ - Replay tokens across environments/projects; expect strict aud/iss rejection server-side.
39
+ - Call Functions with and without Authorization; verify identical checks on both onCall and onRequest variants.
40
+ </auth_and_tokens>
41
+
42
+ <firestore_rules>
43
+ - Rules are not filters: a query must include constraints that make the rule true for all returned documents; otherwise reads fail. Do not rely on client to include where clauses correctly.
44
+ - Prefer ownership derived from request.auth.uid and server data, not from client payload fields.
45
+ - Common gaps:
46
+ - allow read: if request.auth != null (any user reads all data)
47
+ - allow write: if request.auth != null (mass write)
48
+ - Missing per-field validation (adds isAdmin/role/tenantId fields).
49
+ - Using client-supplied ownerId/orgId instead of enforcing doc.ownerId == request.auth.uid or membership in org.
50
+ - Over-broad list rules on root collections; per-doc checks exist but list still leaks via queries.
51
+ - Validation patterns:
52
+ - Restrict writes: request.resource.data.keys().hasOnly([...]) and forbid privilege fields.
53
+ - Enforce ownership: resource.data.ownerId == request.auth.uid && request.resource.data.ownerId == request.auth.uid
54
+ - Org membership: exists(/databases/(default)/documents/orgs/$(org)/members/$(request.auth.uid))
55
+ - Tests:
56
+ - Compare results for users A/B on identical queries; diff counts and IDs.
57
+ - Attempt cross-tenant reads: where orgId == otherOrg; try queries without org filter to confirm denial.
58
+ - Write-path: set/patch with foreign ownerId/orgId; attempt to flip privilege flags.
59
+ </firestore_rules>
60
+
61
+ <firestore_queries>
62
+ - Enumerate via REST to avoid SDK client-side constraints; try structured and REST filters.
63
+ - Probe composite index requirements: UI-driven queries may hide missing rule coverage when indexes are enabled but rules are broad.
64
+ - Explore collection group queries (collectionGroup) that may bypass per-collection rules if not mirrored.
65
+ - Use startAt/endAt/in/array-contains to probe rule edges and pagination cursors for cross-tenant bleed.
66
+ </firestore_queries>
67
+
68
+ <realtime_database>
69
+ - Misconfigured rules frequently expose entire JSON trees. Probe https://<project>.firebaseio.com/.json with and without auth.
70
+ - Confirm rules for read/write use auth.uid and granular path checks; avoid .read/.write: true or auth != null at high-level nodes.
71
+ - Attempt to write privilege-bearing nodes (roles, org membership) and observe downstream effects (e.g., Cloud Functions triggers).
72
+ </realtime_database>
73
+
74
+ <cloud_storage>
75
+ - Rules parallel Firestore but apply to object paths. Common issues:
76
+ - Public reads on sensitive buckets/paths.
77
+ - Signed URLs with long TTL, no content-disposition controls; replayable across tenants.
78
+ - List operations exposed: /o?prefix= enumerates object keys.
79
+ - Tests:
80
+ - GET gs:// paths via https endpoints without auth; verify content-type and Content-Disposition: attachment.
81
+ - Generate and reuse signed URLs across accounts and paths; try case/URL-encoding variants.
82
+ - Upload HTML/SVG and verify X-Content-Type-Options: nosniff; check for script execution.
83
+ </cloud_storage>
84
+
85
+ <cloud_functions>
86
+ - onCall provides context.auth automatically; onRequest must verify ID tokens explicitly. Admin SDK bypasses rules; all ownership/tenant checks must be enforced in code.
87
+ - Common gaps:
88
+ - Trusting client uid/orgId from request body instead of context.auth.
89
+ - Missing aud/iss verification when manually parsing tokens.
90
+ - Over-broad CORS allowing credentialed cross-origin requests; echoing Authorization in responses.
91
+ - Triggers (onCreate/onWrite) granting roles or issuing signed URLs solely based on document content controlled by the client.
92
+ - Tests:
93
+ - Call both onCall and equivalent onRequest endpoints with varied tokens and bodies; expect identical decisions.
94
+ - Create crafted docs to trigger privilege-granting functions; verify that server re-derives subject/tenant before acting.
95
+ - Attempt internal fetches (SSRF) via Functions to project/metadata endpoints.
96
+ </cloud_functions>
97
+
98
+ <app_check>
99
+ - App Check is not a substitute for authorization. Many apps enable App Check enforcement on client SDKs but do not verify on custom backends.
100
+ - Bypasses:
101
+ - Unenforced paths: REST calls directly to googleapis endpoints with ID token succeed regardless of App Check.
102
+ - Mobile reverse engineering: hook client and reuse ID token flows without attestation.
103
+ - Tests:
104
+ - Compare SDK vs REST behavior with/without App Check headers; confirm no elevated authorization via App Check alone.
105
+ </app_check>
106
+
107
+ <tenant_isolation>
108
+ - Apps often implement multi-tenant data models (orgs/<orgId>/...). Bind tenant from server context (membership doc or custom claim), not from client payload.
109
+ - Tests:
110
+ - Vary org header/subdomain/query while keeping token fixed; verify server denies cross-tenant access.
111
+ - Export/report Functions: ensure queries execute under caller scope; signed outputs must encode tenant and short TTL.
112
+ </tenant_isolation>
113
+
114
+ <bypass_techniques>
115
+ - Content-type switching: JSON vs form vs multipart to hit alternate code paths in onRequest Functions.
116
+ - Parameter/field pollution: duplicate JSON keys; last-one-wins in many parsers; attempt to sneak privilege fields.
117
+ - Caching/CDN: Hosting rewrites or proxies that key responses without Authorization or tenant headers.
118
+ - Race windows: write then read before background enforcements (e.g., post-write claim synchronizations) complete.
119
+ </bypass_techniques>
120
+
121
+ <blind_channels>
122
+ - Firestore: use error shape, document count, and ETag/length to infer existence under partial denial.
123
+ - Storage: length/timing differences on signed URL attempts leak validity.
124
+ - Functions: constant-time comparisons vs variable messages reveal authorization branches.
125
+ </blind_channels>
126
+
127
+ <tooling_and_automation>
128
+ - SDK + REST: httpie/curl + jq for REST; Firebase emulator and Rules Playground for rapid iteration.
129
+ - Mobile: apktool/objection/frida to extract config and hook SDK calls; inspect network logs for endpoints and tokens.
130
+ - Rules analysis: script rule probes for common patterns (auth != null, missing field validation, list vs get parity).
131
+ - Functions: fuzz onRequest endpoints with varied content-types and missing/forged Authorization; verify CORS and token handling.
132
+ - Storage: enumerate prefixes; test signed URL generation and reuse patterns.
133
+ </tooling_and_automation>
134
+
135
+ <reviewer_checklist>
136
+ - Do Firestore/Realtime/Storage rules derive subject and tenant from auth, not client fields?
137
+ - Are list/query rules aligned with per-doc checks (no broad list leaks)?
138
+ - Are privilege-bearing fields immutable or server-only (forbidden in writes)?
139
+ - Do Functions verify ID tokens (iss/aud/exp/signature) and re-derive identity before acting?
140
+ - Are Admin SDK operations scoped by server-side checks (ownership/tenant)?
141
+ - Is App Check treated as advisory, not authorization, across all paths?
142
+ - Are Hosting/CDN cache keys bound to Authorization/tenant to prevent leaks?
143
+ </reviewer_checklist>
144
+
145
+ <validation>
146
+ 1. Provide owner vs non-owner Firestore queries showing unauthorized access or metadata leak.
147
+ 2. Demonstrate Cloud Storage read/write beyond intended scope (public object, signed URL reuse, or list exposure).
148
+ 3. Show a Function accepting forged/foreign identity (wrong aud/iss) or trusting client uid/orgId.
149
+ 4. Document minimal reproducible requests with roles/tokens used and observed deltas.
150
+ </validation>
151
+
152
+ <false_positives>
153
+ - Public collections/objects documented and intended.
154
+ - Rules that correctly enforce per-doc checks with matching query constraints.
155
+ - Functions verifying tokens and ignoring client-supplied identifiers.
156
+ - App Check enforced but not relied upon for authorization.
157
+ </false_positives>
158
+
159
+ <impact>
160
+ - Cross-account and cross-tenant data exposure.
161
+ - Unauthorized state changes via Functions or direct writes.
162
+ - Exfiltration of PII/PHI and private files from Storage.
163
+ - Durable privilege escalation via misused custom claims or triggers.
164
+ </impact>
165
+
166
+ <pro_tips>
167
+ 1. Treat apiKey as project identifier only; identity must come from verified ID tokens.
168
+ 2. Start from rules: read them, then prove gaps with diffed owner/non-owner requests.
169
+ 3. Prefer REST for parity checks; SDKs can mask errors via client-side filters.
170
+ 4. Hunt privilege fields in docs and forbid them via rules; verify immutability.
171
+ 5. Probe collectionGroup queries and list rules; many leaks live there.
172
+ 6. Functions are the authority boundary—enforce subject/tenant there even if rules exist.
173
+ 7. Keep concise PoCs: one owner vs non-owner request per surface that clearly demonstrates the unauthorized delta.
174
+ </pro_tips>
175
+
176
+ <remember>Authorization must hold at every layer: rules, Functions, and Storage. Bind subject and tenant from verified tokens and server data, never from client payload or UI assumptions. Any gap becomes a cross-account or cross-tenant vulnerability.</remember>
177
+ </firebase_firestore_security_guide>
@@ -0,0 +1,189 @@
1
+ <supabase_security_guide>
2
+ <title>SUPABASE — ADVERSARIAL TESTING AND EXPLOITATION</title>
3
+
4
+ <critical>Supabase exposes Postgres through PostgREST, Realtime, GraphQL, Storage, Auth (GoTrue), and Edge Functions. Most impactful findings come from mis-scoped Row Level Security (RLS), unsafe RPCs, leaked service_role keys, lax Storage policies, GraphQL overfetching, and Edge Functions trusting headers or tokens without binding to issuer/audience/tenant.</critical>
5
+
6
+ <scope>
7
+ - PostgREST: table CRUD, filters, embeddings, RPC (remote functions)
8
+ - RLS: row ownership/tenant isolation via policies and auth.uid()
9
+ - Storage: buckets, objects, signed URLs, public/private policies
10
+ - Realtime: replication subscriptions, broadcast/presence channels
11
+ - GraphQL: pg_graphql over Postgres schema with RLS interaction
12
+ - Auth (GoTrue): JWTs, cookie/session, magic links, OAuth flows
13
+ - Edge Functions (Deno): server-side code calling Supabase with secrets
14
+ </scope>
15
+
16
+ <methodology>
17
+ 1. Inventory surfaces: REST /rest/v1, Storage /storage/v1, GraphQL /graphql/v1, Realtime wss, Auth /auth/v1, Functions https://<project>.functions.supabase.co/.
18
+ 2. Obtain tokens for: unauth (anon), basic user, other user, and (if disclosed) admin/staff; enumerate anon key exposure and verify if service_role leaked anywhere.
19
+ 3. Build a Resource × Action × Principal matrix and test each via REST and GraphQL. Confirm parity across channels and content-types (json/form/multipart).
20
+ 4. Start with list/search/export endpoints to gather IDs, then attempt direct reads/writes across principals, tenants, and transports. Validate RLS and function guards.
21
+ </methodology>
22
+
23
+ <architecture>
24
+ - Project endpoints: https://<ref>.supabase.co; REST at /rest/v1/<table>, RPC at /rest/v1/rpc/<fn>.
25
+ - Headers: apikey: <anon-or-service>, Authorization: Bearer <JWT>. Anon key only identifies the project; JWT binds user context.
26
+ - Roles: anon, authenticated; service_role bypasses RLS and must never be client-exposed.
27
+ - auth.uid(): current user UUID claim; policies must never trust client-supplied IDs over server context.
28
+ </architecture>
29
+
30
+ <rls>
31
+ - Enable RLS on every non-public table; absence or “permit-all” policies → bulk exposure.
32
+ - Common gaps:
33
+ - Policies check auth.uid() for read but forget UPDATE/DELETE/INSERT.
34
+ - Missing tenant constraints (org_id/tenant_id) allow cross-tenant reads/writes.
35
+ - Policies rely on client-provided columns (user_id in payload) instead of deriving from JWT.
36
+ - Complex joins where the effective policy is applied after filters, enabling inference via counts or projections.
37
+ - Tests:
38
+ - Compare results for two users: GET /rest/v1/<table>?select=*&Prefer=count=exact; diff row counts and IDs.
39
+ - Try cross-tenant: add &org_id=eq.<other_org> or use or=(org_id.eq.other,org_id.is.null).
40
+ - Write-path: PATCH/DELETE single row with foreign id; INSERT with foreign owner_id then read.
41
+ </rls>
42
+
43
+ <postgrest_and_rest>
44
+ - Filters: eq, neq, lt, gt, ilike, or, is, in; embed relations with select=*,profile(*); exploit embeddings to overfetch linked rows if resolvers skip per-row checks.
45
+ - Headers to know: Prefer: return=representation (echo writes), Prefer: count=exact (exposure via counts), Accept-Profile/Content-Profile to select schema.
46
+ - IDOR patterns: /rest/v1/<table>?select=*&id=eq.<other_id>; query alternative keys (slug, email) and composite keys.
47
+ - Search leaks: generous LIKE/ILIKE filters + lack of RLS → mass disclosure.
48
+ - Mass assignment: if RPC not used, PATCH can update unintended columns; verify restricted columns via database permissions/policies.
49
+ </postgrest_and_rest>
50
+
51
+ <rpc_functions>
52
+ - RPC endpoints map to SQL functions. SECURITY DEFINER bypasses RLS unless carefully coded; SECURITY INVOKER respects caller.
53
+ - Anti-patterns:
54
+ - SECURITY DEFINER + missing owner checks → vertical/horizontal bypass.
55
+ - set search_path left to public; function resolves unsafe objects.
56
+ - Trusting client-supplied user_id/tenant_id rather than auth.uid().
57
+ - Tests:
58
+ - Call /rest/v1/rpc/<fn> as different users with foreign ids in body.
59
+ - Remove or alter JWT entirely (Authorization: Bearer <anon>) to see if function still executes.
60
+ - Validate that functions perform explicit ownership/tenant checks inside SQL, not only in docs.
61
+ </rpc_functions>
62
+
63
+ <storage>
64
+ - Buckets: public vs private; objects live in storage.objects with RLS-like policies.
65
+ - Find misconfigs:
66
+ - Public buckets holding sensitive data: GET https://<ref>.supabase.co/storage/v1/object/public/<bucket>/<path>
67
+ - Signed URLs with long TTL and no audience binding; reuse/guess tokens across tenants/paths.
68
+ - Listing prefixes without auth: /storage/v1/object/list/<bucket>?prefix=
69
+ - Path confusion: mixed case, URL-encoding, “..” segments rejected at UI but accepted by API.
70
+ - Abuse vectors:
71
+ - Content-type/XSS: upload HTML/SVG served as text/html or image/svg+xml; confirm X-Content-Type-Options: nosniff and Content-Disposition: attachment.
72
+ - Signed URL replay across accounts/buckets if validation is lax.
73
+ </storage>
74
+
75
+ <realtime>
76
+ - Endpoint: wss://<ref>.supabase.co/realtime/v1. Join channels with apikey + Authorization.
77
+ - Risks:
78
+ - Channel names derived from table/schema/filters leaking other users’ updates when RLS or channel guards are weak.
79
+ - Broadcast/presence channels allowing cross-room join/publish without auth checks.
80
+ - Tests:
81
+ - Subscribe to public:realtime changes on protected tables; confirm row data visibility aligns with RLS.
82
+ - Attempt joining other users’ presence/broadcast channels (e.g., room:<user_id>, org:<id>).
83
+ </realtime>
84
+
85
+ <graphql>
86
+ - Endpoint: /graphql/v1 using pg_graphql with RLS. Risks:
87
+ - Introspection reveals schema relations; ensure it’s intentional.
88
+ - Overfetch via nested relations where field resolvers fail to re-check ownership/tenant.
89
+ - Global node IDs (if implemented) leaked and reusable via different viewers.
90
+ - Tests:
91
+ - Compare REST vs GraphQL responses for the same principal and query shape.
92
+ - Query deep nested fields and connections; verify RLS holds at each edge.
93
+ </graphql>
94
+
95
+ <auth_and_tokens>
96
+ - GoTrue issues JWTs with claims (sub=uid, role, aud=authenticated). Validate on server: issuer, audience, exp, signature, and tenant context.
97
+ - Pitfalls:
98
+ - Storing tokens in localStorage → XSS exfiltration; refresh mismanagement leading to long-lived sessions.
99
+ - Treating apikey as identity; it is project-scoped, not user identity.
100
+ - Exposing service_role key in client bundle or Edge Function responses.
101
+ - Tests:
102
+ - Replay tokens across services; check audience/issuer pinning.
103
+ - Try downgraded tokens (expired/other audience) against custom endpoints.
104
+ </auth_and_tokens>
105
+
106
+ <edge_functions>
107
+ - Deno-based functions often initialize server-side Supabase client with service_role. Risks:
108
+ - Trusting Authorization/apikey headers without verifying JWT against issuer/audience.
109
+ - CORS: wildcard origins with credentials; reflected Authorization in responses.
110
+ - SSRF via fetch; secrets exposed via error traces or logs.
111
+ - Tests:
112
+ - Call functions with and without Authorization; compare behavior.
113
+ - Try foreign resource IDs in function payloads; verify server re-derives user/tenant from JWT.
114
+ - Attempt to reach internal endpoints (metadata services, project endpoints) via function fetch.
115
+ </edge_functions>
116
+
117
+ <tenant_isolation>
118
+ - Ensure every query joins or filters by tenant_id/org_id derived from JWT context, not client input.
119
+ - Tests:
120
+ - Change subdomain/header/path tenant selectors while keeping JWT tenant constant; look for cross-tenant data.
121
+ - Export/report endpoints: confirm queries execute under caller scope; signed outputs must encode tenant and short TTL.
122
+ </tenant_isolation>
123
+
124
+ <bypass_techniques>
125
+ - Content-type switching: application/json ↔ application/x-www-form-urlencoded ↔ multipart/form-data to hit different code paths.
126
+ - Parameter pollution: duplicate keys in JSON/query; PostgREST chooses last/first depending on parser.
127
+ - GraphQL+REST parity probing: protections often drift; fetch via the weaker path.
128
+ - Race windows: parallel writes to bypass post-insert ownership updates.
129
+ </bypass_techniques>
130
+
131
+ <blind_channels>
132
+ - Use Prefer: count=exact and ETag/length diffs to infer unauthorized rows.
133
+ - Conditional requests (If-None-Match) to detect object existence without content exposure.
134
+ - Storage signed URLs: timing/length deltas to map valid vs invalid tokens.
135
+ </blind_channels>
136
+
137
+ <tooling_and_automation>
138
+ - PostgREST: httpie/curl + jq; enumerate tables with known names; fuzz filters (or=, ilike, neq, is.null).
139
+ - GraphQL: graphql-inspector, voyager; build deep queries to test field-level enforcement; complexity/batching tests.
140
+ - Realtime: custom ws client; subscribe to suspicious channels/tables; diff payloads per principal.
141
+ - Storage: enumerate bucket listing APIs; script signed URL generation/use patterns.
142
+ - Auth/JWT: jwt-cli/jose to validate audience/issuer; replay against Edge Functions.
143
+ - Policy diffing: maintain request sets per role and compare results across releases.
144
+ </tooling_and_automation>
145
+
146
+ <reviewer_checklist>
147
+ - Are all non-public tables RLS-enabled with explicit SELECT/INSERT/UPDATE/DELETE policies?
148
+ - Do policies derive subject/tenant from JWT (auth.uid(), tenant claim) rather than client payload?
149
+ - Do RPC functions run as SECURITY INVOKER, or if DEFINER, do they enforce ownership/tenant inside?
150
+ - Are Storage buckets private by default, with short-lived signed URLs bound to tenant/context?
151
+ - Does Realtime enforce RLS-equivalent filtering for subscriptions and block cross-room joins?
152
+ - Is GraphQL parity verified with REST; are nested resolvers guarded per field?
153
+ - Are Edge Functions verifying JWT (issuer/audience) and never exposing service_role to clients?
154
+ - Are CDN/cache keys bound to Authorization/tenant to prevent cache leaks?
155
+ </reviewer_checklist>
156
+
157
+ <validation>
158
+ 1. Provide owner vs non-owner requests for REST/GraphQL showing unauthorized access (content or metadata).
159
+ 2. Demonstrate a mis-scoped RPC or Storage signed URL usable by another user/tenant.
160
+ 3. Confirm Realtime or GraphQL exposure matches missing policy checks.
161
+ 4. Document minimal reproducible requests and role contexts used.
162
+ </validation>
163
+
164
+ <false_positives>
165
+ - Tables intentionally public (documented) with non-sensitive content.
166
+ - RLS-enabled tables returning only caller-owned rows; mismatched UI not backed by API responses.
167
+ - Signed URLs with very short TTL and audience binding.
168
+ - Edge Functions verifying tokens and re-deriving context before acting.
169
+ </false_positives>
170
+
171
+ <impact>
172
+ - Cross-account/tenant data exposure and unauthorized state changes.
173
+ - Exfiltration of PII/PHI/PCI, financial and billing artifacts, private files.
174
+ - Privilege escalation via RPC and Edge Functions; durable access via long-lived tokens.
175
+ - Regulatory and contractual violations stemming from tenant isolation failures.
176
+ </impact>
177
+
178
+ <pro_tips>
179
+ 1. Start with /rest/v1 list/search; counts and embeddings reveal policy drift fast.
180
+ 2. Treat UUIDs and signed URLs as untrusted; validate binding to subject/tenant and TTL.
181
+ 3. Focus on RPC and Edge Functions—they often centralize business logic and skip RLS.
182
+ 4. Test GraphQL and Realtime parity with REST; differences are where vulnerabilities hide.
183
+ 5. Keep role-separated request corpora and diff responses across deployments.
184
+ 6. Never assume apikey == identity; only JWT binds subject. Prove it.
185
+ 7. Prefer concise PoCs: one request per role that clearly shows the unauthorized delta.
186
+ </pro_tips>
187
+
188
+ <remember>RLS must bind subject and tenant on every path, and server-side code (RPC/Edge) must re-derive identity from a verified token. Any gap in binding, audience/issuer verification, or per-field enforcement becomes a cross-account or cross-tenant vulnerability.</remember>
189
+ </supabase_security_guide>