Summary
Typebot versions prior to 3.13.2 contain a client-side script execution flaw that, combined with improper authorization on a credential retrieval endpoint, allows theft of other users' stored API keys and passwords.
When a victim clicks "Run" to preview a malicious typebot, attacker-controlled JavaScript executes in the victim's browser and calls /api/trpc/credentials.getCredentials, which returns plaintext credentials without verifying ownership.
Affected context
The vulnerability affects Typebot instances where:
- Users can create or load typebots that include untrusted or attacker-controlled content.
- The preview/"Run" feature renders this content in the victim's browser without strict isolation or sanitization.
- The backend credential API (
/api/trpc/credentials.getCredentials) exposes stored secrets in plaintext based only on session context, without strong per-credential ownership checks.
Under these conditions, any user who previews a malicious typebot may have their stored OpenAI keys, Google Sheets tokens, SMTP passwords, or similar secrets exfiltrated.
Exploit preconditions
- Attack surface: Web UI of the Typebot builder and preview interface.
- Required access: Ability to get a victim to open or preview a crafted typebot (e.g., shared workspace, imported bot template, or social engineering).
- Trigger point: Victim clicks "Run" or otherwise loads the malicious typebot preview, causing embedded JavaScript to execute in their browser context.
- Why exploitation is possible:
- The preview context allows execution of attacker-supplied JavaScript (client-side script injection/XSS-like behavior).
- The browser session has access to
/api/trpc/credentials.getCredentials. - The credentials endpoint returns plaintext API keys for the current session without robust verification that the caller owns or is authorized to access each credential object (broken access control / IDOR).
Why this happens
The issue is a combination of client-side script injection and weak authorization around sensitive data access.
On the client side, user-controlled content is rendered in the preview environment with enough privilege to run arbitrary JavaScript (CWE-79: Improper Neutralization of Input During Web Page Generation). This gives an attacker code execution in the victim's authenticated browser session.
On the backend, the /api/trpc/credentials.getCredentials endpoint exposes secrets in plaintext without sufficiently enforcing that the caller is the legitimate owner of each credential (CWE-284: Improper Access Control, CWE-639: Insecure Direct Object Reference). The endpoint effectively trusts the authenticated session without finer-grained checks and returns highly sensitive values (CWE-200: Exposure of Sensitive Information, CWE-522/CWE-311: Insufficient Protection of Credentials/Encryption of Sensitive Data). The combination of these flaws allows malicious scripts to programmatically retrieve and exfiltrate secrets belonging to the victim.
Potential impact
- Theft of OpenAI API keys, enabling unauthorized use, prompt exfiltration, or data exposure through the victim's AI integrations.
- Compromise of Google Sheets tokens, allowing unauthorized access to spreadsheets, data modification, or data exfiltration.
- Exposure of SMTP passwords, enabling spam campaigns, phishing emails, and impersonation of the victim's email identity.
- Lateral movement into other connected services and applications that rely on the stolen credentials.
- Financial impact from abusive use of metered APIs (e.g., AI providers or email delivery services).
- Damage to brand reputation if attackers use compromised email or integrations to target customers.
General mitigation guidance
Effective mitigation involves both hardening the client rendering path and tightening backend access control for secret data.
On the client/UI side:
- Prefer safe-by-default rendering of user-supplied content, avoiding direct insertion of HTML/JS where possible.
- Apply rigorous output encoding and sanitization for any content that may render in a browser context.
- Isolate untrusted content in sandboxed iframes with restricted capabilities, ensuring it cannot access parent page JavaScript, cookies, or sensitive APIs.
- Disable or strictly gate any feature that would allow arbitrary script execution in preview contexts.
On the backend/credentials side:
- Enforce strong ownership and authorization checks for each credential object before returning it; require explicit association between the requesting identity and the credential record.
- Minimize data exposure by returning only what is required for the current operation and avoiding sending plaintext secrets to the browser unless strictly necessary.
- Store credentials using patterns that separate raw secret material from general runtime queries, making bulk or generic retrieval harder.
- Apply least-privilege design: separate roles for creating, using, and administrating credentials, and ensure UI/API operations respect those roles.
- Consider patterns such as server-side token use, where the server performs third-party API calls on behalf of a user instead of exposing secrets to the client.
How teams detect issues like this
Detection can focus on both code-level signals and runtime behavior.
Code-level and review-based strategies:
- Use static analysis and linters to flag direct use of dangerous DOM APIs (e.g.,
innerHTML,dangerouslySetInnerHTML, direct event handler injection) in preview or builder components. - Search for any endpoints returning credential-like data without explicit per-entity access checks (e.g., missing owner filters, workspace boundaries, or role validation).
- Add code review checklists that explicitly call out:
- "Does this view render user-controlled content?"
- "Can this API return secrets or tokens, and if so, how is authorization enforced?"
- Apply security-focused tests that exercise preview rendering with malicious payloads to confirm scripts cannot execute or cannot access sensitive APIs.
Runtime and operational strategies:
- Monitor access logs for unusual or bulk calls to
/api/trpc/credentials.getCredentials, especially those followed by outbound requests to unknown domains. - Implement Content Security Policy (CSP) reporting to detect inline script execution and suspicious script sources in preview contexts.
- Add telemetry around credential access paths, including which user, which workspace, and how often credentials are returned to clients.
- Periodically run dynamic application security testing (DAST) or use automated tools that probe for XSS and IDOR patterns in web applications.

