T09 · Insecure Skill Coding Practices
- Location
index.js:36- Finding
OCR Content Is Disclosed to an External Translation Service Through URL Query Parameters
- Content
View full analysis
Vulnerability Details
File Location:
index.js, lines 36–49
Vulnerability Type: Automatic external disclosure of potentially sensitive OCR content
Risk Level: MediumVulnerable Code
js async function translateIfEnglish(text) { const isEnglish = /^[\x00-\x7F]*$/.test(text); if (!isEnglish) return text; const resp = await axios.get('https://translate.googleapis.com/translate_a/single', { params: { client: 'gtx', sl: 'en', tl: 'zh-CN', dt: 't', q: text } }); return resp.data[0].map(item => item[0]).join(''); }Technical Analysis
OCR output is automatically transmitted to
translate.googleapis.comwhenever the entire value consists of ASCII characters. The regular expression is not a reliable English-language detector: it also accepts passwords, API tokens, identifiers, financial data, source code, numbers, and empty strings.Axios serializes
q: textinto the GET request's URL query string. Although HTTPS protects the request in transit, URLs can be recorded by the destination service and by client, proxy, gateway, observability, or security logging systems. This creates broader exposure than placing sensitive content in a controlled request body.The documentation discloses that translation is an exception to local processing, so the behavior is not hidden exfiltration. Nevertheless, the implementation does not obtain per-request consent, classify or redact sensitive OCR data, or provide a local-only enforcement control.
Attack Path
- A user submits an image containing sensitive ASCII text, such as a password, API token, customer record, or confidential internal document.
ocrImage()extracts that content as text.translateIfEnglish()treats the content as English solely because it contains only ASCII characters.- Axios inserts the full OCR output into the
qURL query parameter. - The request is sent to Google's translation endpoint.
- The sensitive conten ...[truncated 765 chars]
- Remediation
View remediation
Remediation Suggestions
- Require explicit user or administrator opt-in before sending OCR content to any external translation service.
- Provide and enforce a local-only mode in which outbound translation requests are prohibited.
- Replace the ASCII test with a proper language-detection mechanism, and do not translate empty, numeric-only, token-like, or identifier-like content.
- Scan and redact likely credentials, tokens, personal data, and other sensitive values before external transmission.
- Use a documented, authenticated translation API whose privacy, retention, regional processing, and data-handling terms are appropriate for the deployment.
- Prefer a POST request body instead of a GET query parameter where supported, while recognizing that this alone does not eliminate disclosure to the service.
- Apply request-size limits, timeouts, explicit destination allowlisting, and redirect restrictions.
- Clearly disclose the destination and transmitted fields before processing, and obtain consent appropriate to the data's sensitivity.
- Avoid logging raw OCR content or complete translation requests in application and infrastructure logs.
