VoiceStudio is the open-source, fully-local ElevenLabs alternative — voice cloning, voice design, video dubbing, dictation, transcription & audiobook creation in 646 languages.
Python aiaudiobookcudadubbingelevenlabs-alternativehuggingfacelocal-firstmlxomnivoice-studiospeech-to-texttext-to-speechtranscriptiontranslatettsvoice-aivoice-cloningvoice-generationvoicestudioworkflow
fix: normalize legacy VirusTotal upload URLs to HTTPS
Shimul Debnathf196e39fc378
diff --git a/.github/SECURITY.md b/.github/SECURITY.mdindex 784aa7deb..bc8150efb 100644--- a/.github/SECURITY.md+++ b/.github/SECURITY.md@@ -119,7 +119,10 @@ appropriate paid licence when those terms do not cover your use.The tool spaces requests 16 seconds apart, automatically requests the[large-file upload URL](https://docs.virustotal.com/reference/files-upload-url)-above 32 MiB, and streams files up to 650 MiB. It prints the SHA-256, report URL,+above 32 MiB, and streams files up to 650 MiB.+VirusTotal's legacy HTTP-form `www.virustotal.com/_ah/upload/` URLs are upgraded+locally to HTTPS before uploading; credentials and files are never sent over+HTTP. Other origins and redirects remain rejected. It prints the SHA-256, report URL,analysis ID and flagged vendor labels, and waits up to 10 minutes for results.Exit status is 0 for a completed analysis with no flags, 1 for malicious orsuspicious detections, and 2 for errors or an inconclusive/pending analysis.diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1b43038a3..b31c0a77b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -32,6 +32,7 @@ metadata and the backend fallback mirror it.### Fixed+- Large VirusTotal uploads upgrade the documented legacy upload URL to HTTPS before sending files or credentials (#3237)- iPhone: tapping Play right after generating speech starts playback instead of doing nothing (#3233)- Android app icons preserve transparent waveform paths from the shared logo, including themed icons (#2969)- Speak keeps your script when switching between the phone and computer on Android (#2969)diff --git a/scripts/virustotal.py b/scripts/virustotal.pyindex 3baaf658e..e3cd4454b 100644--- a/scripts/virustotal.py+++ b/scripts/virustotal.py@@ -36,14 +36,36 @@ class NoRedirects(HTTPRedirectHandler):def validate_url(url: str) -> str:- parsed = urlsplit(url)- if (parsed.scheme != "https" or parsed.hostname != "www.virustotal.com"- or parsed.port not in (None, 443) or parsed.username or parsed.password- or parsed.fragment):- raise ScanError("VirusTotal returned an unexpected upload URL; refusing to send the file/key.")+ try:+ parsed = urlsplit(url)+ allowed = (parsed.scheme == "https" and parsed.hostname == "www.virustotal.com"+ and parsed.port in (None, 443) and not parsed.username+ and not parsed.password and not parsed.fragment)+ except ValueError:+ raise ScanError("VirusTotal returned a malformed upload URL; refusing to send the file/key.") from None+ if not allowed:+ # Report only the origin, never the one-use upload token/path/query.+ scheme = re.sub(r"[^A-Za-z0-9.-]", "?", parsed.scheme or "missing")[:16]+ host = re.sub(r"[^A-Za-z0-9.:-]", "?", parsed.hostname or "missing")[:255]+ origin = f"{scheme}://{host}"+ raise ScanError(f"VirusTotal returned an unexpected upload origin ({origin}); refusing to send the file/key.")return url+def normalize_upload_url(url: str) -> str:+ # The official /files/upload_url example uses http://www.virustotal.com/+ # _ah/upload/… . Upgrade that known legacy form locally, before any request.+ try:+ parsed = urlsplit(url)+ if (parsed.scheme == "http" and parsed.hostname == "www.virustotal.com"+ and parsed.port in (None, 80) and not parsed.username+ and not parsed.password and parsed.path.startswith("/_ah/upload/")):+ url = parsed._replace(scheme="https", netloc="www.virustotal.com").geturl()+ except ValueError:+ raise ScanError("VirusTotal returned a malformed upload URL; refusing to send the file/key.") from None+ return validate_url(url)++def multipart(path: Path, boundary: str):# Send a basename only; never expose the local directory in the multipart header.filename = re.sub(r"[^A-Za-z0-9._-]", "_", path.name)@@ -112,6 +134,7 @@ class Client:url = self.request("GET", f"{API}/files/upload_url")["data"]if not isinstance(url, str):raise ScanError("VirusTotal returned an invalid upload URL.")+ url = normalize_upload_url(url)result = self.request("POST", url, file=path)analysis_id = result.get("data", {}).get("id")if not isinstance(analysis_id, str) or not analysis_id:diff --git a/tests/test_virustotal.py b/tests/test_virustotal.pyindex 20e8dda89..dd796aa6a 100644--- a/tests/test_virustotal.py+++ b/tests/test_virustotal.py@@ -57,6 +57,22 @@ class VirusTotalTests(unittest.TestCase):self.assertEqual([(r.get_method(), r.full_url) for r in requests],[("GET", f"{vt.API}/files/upload_url"), ("POST", upload_url)])+ def test_documented_http_upload_urls_are_upgraded_before_sending_credentials(self):+ # VirusTotal's own /files/upload_url example uses an HTTP-form URL.+ for authority in ("www.virustotal.com", "www.virustotal.com:80"):+ with self.subTest(authority=authority):+ self.client.last_request = None+ self.client.opener.open.reset_mock()+ self.client.opener.open.side_effect = [+ response({"data": f"http://{authority}/_ah/upload/token/?query=preserved"}),+ response({"data": {"id": "legacy-upload"}}),+ ]+ with patch.object(vt, "DIRECT_LIMIT", 1), patch.object(vt.time, "sleep"):+ self.assertEqual(self.client.upload(self.path), "legacy-upload")+ request = self.client.opener.open.call_args.args[0]+ self.assertEqual(request.full_url, "https://www.virustotal.com/_ah/upload/token/?query=preserved")+ self.assertEqual(request.get_header("X-apikey"), "private-test-key")+def test_empty_or_oversize_files_make_no_requests(self):for limit in (0, 1):with self.subTest(limit=limit), patch.object(vt, "MAX_SIZE", limit):@@ -70,7 +86,12 @@ class VirusTotalTests(unittest.TestCase):def test_untrusted_upload_url_cannot_receive_file_or_key(self):for url in ("http://www.virustotal.com/upload", "https://evil.example/upload","https://www.virustotal.com.evil.example/upload",- "https://[email protected]/upload", "https://www.virustotal.com:444/upload"):+ "https://[email protected]/upload", "https://www.virustotal.com:444/upload",+ "http://www.virustotal.com:443/_ah/upload/token",+ "http://[email protected]/_ah/upload/token",+ "http://www.virustotal.com/_ah/upload/token#fragment",+ "http://www.virustotal.com.evil.example/_ah/upload/token",+ "https://www.virustotal.com:invalid/_ah/upload/token"):with self.subTest(url=url), patch.object(vt, "DIRECT_LIMIT", 1):self.client.opener.open.reset_mock()self.client.opener.open.side_effect = None@@ -79,6 +100,18 @@ class VirusTotalTests(unittest.TestCase):self.client.upload(self.path)self.assertEqual(self.client.opener.open.call_count, 1)+ def test_rejected_upload_url_diagnostic_omits_tokens_and_credentials(self):+ with self.assertRaises(vt.ScanError) as caught:+ vt.normalize_upload_url("https://[email protected]/_ah/upload/private-token/?secret=private-query")+ self.assertIn("other.example", str(caught.exception))+ for sensitive in ("private-test-key", "private-token", "private-query"):+ self.assertNotIn(sensitive, str(caught.exception))++ def test_generic_requests_still_refuse_http(self):+ with self.assertRaises(vt.ScanError):+ self.client.request("GET", "http://www.virustotal.com/api/v3/files/upload_url")+ self.client.opener.open.assert_not_called()+def test_redirects_never_forward_credentials(self):self.assertIsNone(vt.NoRedirects().redirect_request(None, None, 302, "", {}, "https://evil.example"))