T09 · Insecure Skill Coding Practices
- Location
references/embedding.md:29- Finding
Browser-Side Exposure of Trugen API Credentials
- Content
View full analysis
**⚠️ Security Note**: The examples below follow the official Trugen docs pattern. In production, consider injecting the `apiKey` value server-side rather than hardcoding it in client-facing HTML, as it will be visible to anyone inspecting the page. **1. Configure the widget before the script tag:** ```html ``` ``` ### Technical Analysis The example places an API credential in a global browser-side JavaScript object. If a developer replaces the placeholder with a real management key, the credential becomes accessible through page source, developer tools, browser extensions, injected scripts, and any third-party script executing in the page context. The remotely hosted `trugen-chat.js` script can also read the global object. Rendering the key into HTML through server-side template injection does not protect it because the resulting credential is still delivered to the browser. This contradicts the safer guidance in `SKILL.md`, which states that client-side embeds should use a server-side proxy. ### Attack Path 1. A developer copies the widget example and replaces `x-api-key` with a working Trugen API key. 2. The application delivers the key in client-facing HTML. 3. An attacker opens developer tools, views the source, reads `window.TrugenWidget`, or uses a script running in the same origin. 4. The attacker extracts the API key. 5. The attacker sends authenticated requests to Trugen API endpoints using ...[truncated 831 chars]- Remediation
View remediation
