T09 · Insecure Skill Coding Practices
Warning
- Location
- scripts/uydi.mjs:13
- Finding
- Unrestricted Service Origin Can Redirect OAuth and Sensitive Voice Data<![CDATA[ ## Vulnerability Details **File Location**: `scripts/uydi.mjs:13`, `scripts/uydi.mjs:25-36`, `scripts/uydi.mjs:55` **Vulnerability Type**: Unvalidated security-sensitive service endpoint **Risk Level**: Medium ### Vulnerable Code ```js const BASE_URL = (process.env.UYDI_BASE_URL || 'https://uydi.com').replace(/\/+$/, ''); ``` ```js function loadToken() { try { const data = JSON.parse(readFileSync(CRED_FILE, 'utf8')); if (data.baseUrl === BASE_URL && data.accessToken) return data.accessToken; } catch {} return null; } function saveToken(accessToken) { mkdirSync(CRED_DIR, { recursive: true, mode: 0o700 }); writeFileSync( CRED_FILE, JSON.stringify({ baseUrl: BASE_URL, accessToken, savedAt: new Date().toISOString() }, null, 2), { mode: 0o600 } ); } ``` ```js const res = await fetch(`${BASE_URL}${path}`, { method, headers, body }); ``` ### Technical Analysis `UYDI_BASE_URL` controls the origin used for OAuth authorization, token exchange, authenticated API operations, voice-sample uploads, synthesis text, and audio downloads. The value is accepted without validating its scheme, hostname, URL credentials, or trust status. This functionality is documented as supporting development and self-hosted deployments, but its implementation does not enforce HTTPS or require explicit confirmation before transmitting sensitive information to a non-default origin. A maliciously modified process environment can therefore redirect the entire workflow to an attacker-controlled server. The credential storage itself follows appropriate local file permissions: the credential directory is created with mode `0700`, and the credential file is written with mode `0600`. The application also binds a stored token to its corresponding `baseUrl`, so changing the environment after a legitimate Uydi login does not directly cause the existing `uydi.com` token to be sent to another host. Nevertheless, a substituted origin can conduct a deceptive O ...[truncated 1777 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Parse the configured endpoint with `new URL()` and reject malformed URLs. 2. Allow `https://uydi.com` by default and maintain an explicit allowlist for approved production origins. 3. Reject non-HTTPS endpoints unless a dedicated development-only option explicitly permits loopback addresses such as `http://127.0.0.1`. 4. Reject URLs containing embedded usernames or passwords. 5. Require interactive confirmation before authenticating with or uploading data to a non-default origin. Display the normalized scheme, hostname, and port. 6. Consider separating production and development modes so an ambient environment variable cannot silently redirect security-sensitive traffic. 7. Update the documentation to clarify that OAuth approval occurs on the configured deployment, not necessarily on `uydi.com`. 8. Preserve the current binding between stored tokens and their normalized service origins. ]]>
