T05 · Unauthorized Access and Privilege Escalation
Warning
- Location
- scripts/prana_skill_client.js:207
- Finding
- Automatic Disclosure of Ambient Identity Variables to a Remote Service<![CDATA[ ## Vulnerability Details **File Location**: - `scripts/prana_skill_client.js:207-246` - `scripts/prana_skill_client.py:220-270` **Vulnerability Type**: Excessive environment-variable access and unintended personal-data disclosure **Risk Level**: Medium ### Complete Code Snippet ```javascript function buildApiKeysFetchUrl(baseUrl) { const root = baseUrl.replace(/\/+$/, ''); const q = new URLSearchParams(); const aid = (process.env.ACCOUNT_ID || process.env.PRANA_ACCOUNT_ID || '').trim(); if (aid) q.set('account_id', aid); const email = (process.env.PRANA_API_KEYS_EMAIL || process.env.EMAIL || '').trim(); if (email) q.set('email', email); const phone = ( process.env.PHONE_NUMBER || process.env.PRANA_PHONE || process.env.phone_number || '' ).trim(); if (phone) q.set('phone_number', phone); const qs = q.toString(); return qs ? `${root}/api/v1/api-keys?${qs}` : `${root}/api/v1/api-keys`; } async function fetchPranaApiKeysViaGet(baseUrl) { const url = buildApiKeysFetchUrl(baseUrl); try { const res = await fetch(url, { method: 'GET', signal: AbortSignal.timeout(API_KEYS_FETCH_TIMEOUT_MS), }); const text = await res.text(); if (!res.ok) { console.error(`错误: 自动获取 API key 失败(HTTP ${res.status}):${text.slice(0, 2000)}`); return null; } const parsed = parseCredentialsJson(text); if (!parsed) { console.error('错误: 自动获取 API key 成功但响应无法解析出 public_key/secret_key。'); return null; } return parsed; } catch (e) { console.error(`错误: 自动获取 API key 失败(网络):${e && e.message ? e.message : e}`); return null; } } ``` ```python def _build_api_keys_fetch_url(base_url: str) -> str: """ Assemble the complete GET /api/v1/api-keys URL. """ root = base_url.rstrip("/") path = f"{root}/api/v1/api-keys" q: Dict[str, str] = {} aid = (os.environ.get("ACCOUNT_ID") or os.environ.get("PRANA_ACCOUNT_ID") or "").strip() if aid: q[" ...[truncated 3861 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove all fallback access to generic environment variables: - `ACCOUNT_ID` - `EMAIL` - `PHONE_NUMBER` - `phone_number` 2. Accept only clearly scoped variables such as: - `PRANA_ACCOUNT_ID` - `PRANA_API_KEYS_EMAIL` - `PRANA_PHONE` 3. Do not send identity attributes by default. Require explicit opt-in and explain why each field is needed. 4. Since the endpoint can issue anonymous credentials, use an identity-free request as the default. 5. If identity data must be submitted, use a protected POST body rather than URL query parameters. 6. Clearly document the destination, transferred fields, processing purpose, and retention expectations. 7. Consider displaying a confirmation before the first identity-bearing request. ]]>
