T09 · Insecure Skill Coding Practices
- Location
scripts/translator.py:11- Finding
API Credential Exposure in Request URL and Unrestricted Third-Party Document Transmission
- Content
View full analysis
Vulnerability Details
File Location:
scripts/translator.py, lines 11 and 56-77
Vulnerability Type: API credential exposure and insecure handling of sensitive document content
Risk Level: MediumVulnerable Code
python DEEPL_API_TEMPLATE = "https://api.deeplx.org/{api_key}/translate"python def translate_text(text: str, target_lang: str, api_key: str) -> str: """翻译单段文本""" if not text or not text.strip(): return text target_lang = normalize_language(target_lang) url = DEEPL_API_TEMPLATE.format(api_key=api_key) try: response = requests.post( url, json={"text": text, "target_lang": target_lang}, timeout=30 ) if response.status_code == 200: return response.json().get("data", text) except Exception as e: print(f"Translation error: {e}") return textTechnical Analysis
The translation API key is interpolated directly into the URL path. URLs are commonly recorded in reverse-proxy access logs, API gateway logs, network monitoring products, application telemetry, and exception reports. HTTPS protects the URL while it is in transit, but it does not prevent the destination service or terminating infrastructure from logging the complete path.
The request body also contains each document paragraph or table-cell value in plaintext JSON. The surrounding translation functions collect all non-empty paragraphs and table cells and pass them individually to this fixed third-party endpoint. Remote transmission is consistent with cloud translation and is documented in the Skill, so this is not hidden exfiltration. Nevertheless, the implementation does not provide endpoint configuration, redaction, data classification, explicit per-document consent, or a local-only mode. Documents containing proprietary, personal, operational, or credential-like information may therefor ...[truncated 2084 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove credentials from the URL. Use an official provider authentication header, such as
Authorization: Bearer ..., where supported. Do not place secrets in URL paths or query parameters. - Use a supported, configurable endpoint. Avoid forcing all document content through a single hard-coded third-party host. Validate configured endpoints against an administrator-controlled HTTPS allowlist to prevent arbitrary data destinations.
- Require informed user consent. Before remote translation, clearly state that document text will leave the local system, identify the destination provider, and obtain explicit confirmation.
- Provide a local-only option. Support model-based or on-device translation for confidential documents and fail closed when remote processing is not approved.
- Minimize transmitted data. Add optional redaction for credentials, personal data, access tokens, internal URLs, and other sensitive values. Send only text that actually requires translation.
- Harden secret input. Remove or discourage command-line API-key arguments because they may appear in shell history and process listings. Prefer a protected secret store, restricted environment injection, or interactive hidden input.
- Control logging. Ensure request URLs, authorization headers, and bodies are not emitted to logs or exception telemetry. Sanitize provider and proxy logs and define short retention periods.
- Improve failure handling. Avoid printing exceptions that could contain request metadata. Emit sanitized error messages instead.
- Document provider data handling. State retention, processing-region, and privacy implications so users can determine whether the service is appropriate for their documents.
- Rotate potentially exposed keys. Revoke and replace any API keys previously used in URLs if relevant logs may have retained them.
- Remove credentials from the URL. Use an official provider authentication header, such as
