Skip to content

Commit 5331077

Browse files
fix: add url validation to mitigate SSRF issue (#29)
* fix: add url validation to mitigate SSRF issue * fix: only allow prefix with strandsagent.com
1 parent 561daeb commit 5331077

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/strands_mcp_server/server.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def fetch_doc(uri: str = "") -> Dict[str, Any]:
9999
- title: Document title
100100
- content: Full document text content
101101
- error: Error message (if fetch failed)
102-
102+
103103
Or when uri is empty:
104104
- urls: List of all available document URLs with titles
105105
@@ -109,18 +109,12 @@ def fetch_doc(uri: str = "") -> Dict[str, Any]:
109109
# If no URI provided, return all available URLs (llms.txt catalog)
110110
if not uri:
111111
url_titles = cache.get_url_titles()
112-
return {
113-
"urls": [
114-
{"url": url, "title": title}
115-
for url, title in url_titles.items()
116-
]
117-
}
118-
119-
# Accept HTTP/HTTPS URLs
120-
if uri.startswith("http://") or uri.startswith("https://"):
121-
url = uri
122-
else:
123-
return {"error": "unsupported uri", "url": uri}
112+
return {"urls": [{"url": url, "title": title} for url, title in url_titles.items()]}
113+
# Only accept https://strandsagents.com URLs
114+
if not uri.startswith("https://strandsagents.com"):
115+
return {"error": "only https://strandsagents.com URLs allowed", "url": uri}
116+
117+
url = uri
124118

125119
page = cache.ensure_page(url)
126120
if page is None:

0 commit comments

Comments
 (0)