fix: validate URL in compare_extraction before newspaper/requests fetch

Close SSRF gap where compare_extraction fetched via newspaper3k and
requests.get without _validate_url, unlike the trafilatura path.

Co-authored-by: Mervin Praison <[email protected]>
This commit is contained in:
praisonai-triage-agent[bot]andMervin Praison committed 2026-08-13 10:25:25 +00:00
1 parent b60ce7d517
commit df99b2b4c7
1 file changed
+11 -1
@@ -279,7 +279,17 @@ class TrafilaturaTools:
"newspaper": None,
"spider": None
}
# Validate the URL once before any fetcher runs so the newspaper and
# requests paths below are protected against SSRF, just like the
# trafilatura path (which validates inside extract_content).
if not self._validate_url(url):
error = {"error": f"Invalid or unsafe URL: {url}"}
comparison["trafilatura"] = error
comparison["newspaper"] = error
comparison["spider"] = error
return comparison
# Get Trafilatura extraction
try:
comparison["trafilatura"] = self.extract_content(url)