T09 · Insecure Skill Coding Practices
- Location
scripts/make_salute_text_to_video.py:12- Finding
SaluteSpeech Requests Disable TLS Certificate Verification
- Content
View full analysis
Vulnerability Details
File Location:
scripts/make_salute_text_to_video.py, lines 12–13 and 38–61
Vulnerability Type: Improper certificate validation for sensitive network requests
Risk Level: HighVulnerable Code
python import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)python def get_salute_token(auth_key: str, scope: str) -> str: """Get OAuth token from SaluteSpeech API. Token is valid for 30 minutes.""" url = "https://ngw.devices.sberbank.ru:9443/api/v2/oauth" headers = { "Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json", "RqUID": str(uuid.uuid4()), "Authorization": f"Basic {auth_key}", } r = requests.post(url, headers=headers, data={"scope": scope}, timeout=30, verify=False) r.raise_for_status() return r.json()["access_token"] def synthesize_salute(token: str, text: str, voice: str, audio_format: str) -> bytes: """Synthesize speech via SaluteSpeech REST API.""" url = "https://smartspeech.sber.ru/rest/v1/text:synthesize" params = {"format": audio_format, "voice": voice} headers = { "Authorization": f"Bearer {token}", "Content-Type": "application/text", } r = requests.post(url, headers=headers, params=params, data=text.encode("utf-8"), timeout=90, verify=False) if r.status_code == 401: raise SystemExit("SaluteSpeech auth failed (401). Check your SALUTE_SPEECH_AUTH key.") if r.status_code == 429: raise SystemExit("SaluteSpeech rate limit (429). Try again later.") r.raise_for_status() return r.contentTechnical Analysis
Both SaluteSpeech network requests explicitly set
verify=False, disabling TLS certificate-chain and hostname validation. The code also globally suppressesInsecureRequestWarning, concealing the unsafe connection from users and ...[truncated 2419 chars]- Remediation
View remediation
Remediation Suggestions
- Remove
verify=Falsefrom bothrequests.postcalls so that Requests uses the operating system orcertifitrust store by default. - Remove the global
urllib3.disable_warningscall. Certificate failures must remain visible and must terminate the operation. - If the deployment requires a private certificate authority, configure an explicit trusted CA bundle:
python requests.post(url, ..., verify="/path/to/trusted-ca-bundle.pem") - Do not implement a fallback that retries with certificate validation disabled.
- Catch
requests.exceptions.SSLErrorand report a clear error instructing the operator to repair the local trust configuration. - Prefer environment-based credential input over
--auth-key, because command-line arguments can be exposed through process listings and shell history. - After remediation, rotate any SaluteSpeech credentials previously used over untrusted networks with the vulnerable implementation.
- Add automated tests that verify requests do not set
verify=Falseand that invalid certificates cause the operation to fail closed.
- Remove
