Summary
TypeBot's file upload API accepts attacker-controlled file names and uses them directly in S3 object keys without authentication or proper path validation.
An anonymous visitor to a bot with a file input block can host arbitrary HTML, SVG, or JavaScript under public storage paths, including locations used by other tenants, which can lead to arbitrary content hosting and stored cross-origin XSS.
Affected context
The vulnerability occurs in TypeBot instances where:
- The
/api/blocks/file-input/v3/generate-upload-urlendpoint is reachable over the internet - Chatbots expose a file input block that triggers upload URL generation
- Uploaded files are stored in a shared S3/MinIO bucket under a
public/prefix and later served as static content - Object keys are derived from user-supplied
fileNamewithout sufficient normalization or scoping
In such deployments, any visitor interacting with a published bot can influence where and what content is stored under publicly accessible storage paths.
Exploit preconditions
- Attack surface: HTTP POST endpoint
/api/blocks/file-input/v3/generate-upload-urlexposed by the TypeBot backend. - Required access: No authentication; the attacker only needs to access a published bot that uses the file input block.
- Trigger point: Submission of crafted
fileNamevalues to the upload URL generator, followed by uploading attacker-controlled content using the returned presigned PUT URL. - Why exploitation is possible:
- The API trusts
fileNameand uses it directly to construct S3 object keys under a sharedpublic/prefix. - There is no tenant isolation or strict key prefixing enforced at the API level.
- Presigned URLs do not bind or restrict
Content-Type, allowing HTML, SVG, and JS uploads. - Forward-slash characters in
fileNameare honored as path separators, enabling injection into arbitrary subpaths even though../traversal is effectively blocked by S3/MinIO canonicalization.
Why this happens
At its core, this issue is a path injection vulnerability where untrusted input is used to build storage paths without proper normalization, scoping, or validation.
The backend constructs S3 object keys by concatenating public/ with a user-controlled fileName, implicitly assuming that the client will only provide benign filenames.
This behavior maps to CWE-22: Path Traversal, because the application allows user input to influence resource paths beyond the intended directory structure, even without classic ../ traversal.
The ability to upload active content (HTML, SVG, JS) into public paths that are later served directly to browsers leads to a secondary stored XSS (CWE-79) condition, as injected content can execute in the origin context of the storage or frontend domain.
Potential impact
- Attacker-controlled HTML or JavaScript can be hosted under the trusted storage origin, enabling stored cross-origin XSS when victims visit those URLs.
- Content spoofing or phishing pages can be deployed under paths that appear to belong to legitimate tenants.
- Overwriting or shadowing existing public result files of other tenants (where naming collisions are possible), causing data integrity issues or UI manipulation.
- Abuse of the storage bucket as a free arbitrary static file hosting service for malicious content.
- Potential pivot to session theft, token exfiltration, or drive-by attacks when injected pages interact with other application resources under the same origin.
General mitigation guidance
Effective mitigation focuses on strict key scoping, input normalization, and active content control:
- Derive storage object keys server-side from stable, trusted identifiers (e.g., tenant ID, bot ID, random UUID) instead of using raw user-supplied
fileNameas part of the path. - Normalize and validate any remaining filename component against an allowlist of characters and disallow embedded path separators such as
/. - Enforce strong tenant isolation in storage layout (e.g., per-tenant key prefixes that cannot be influenced by the client).
- Bind presigned URLs to expected
Content-Typevalues and restrict them to non-executable formats where possible. - Configure storage and CDN layers with content-type, caching, and security headers (e.g.,
Content-Security-Policy,X-Content-Type-Options) to reduce the risk of executable uploads becoming active XSS payloads. - Apply least-privilege policies for the service that generates presigned URLs so it can only issue keys within the intended tenant-specific prefixes.
How teams detect issues like this
Detection can rely on both code-centric and behavior-centric techniques:
- Static analysis and code review:
- Flag concatenation of user input into storage keys, filesystem paths, or URL paths without normalization or prefix enforcement.
- Look for presigned URL generation that accepts arbitrary
fileNameor path fragments, especially where authentication checks are absent or weak. - Identify code paths where uploads are accepted without validating
Content-Typeor file extensions against an allowlist. - Runtime and operational monitoring:
- Log and analyze upload keys and MIME types to detect unusual patterns, such as HTML/JS content stored in result or asset paths.
- Set alerts for spikes in uploads to shared public prefixes or for keys containing unexpected nested subpaths.
- Policy and CI integration:
- Incorporate security checks into CI/CD that scan for unsafe storage key construction patterns.
- Use automated review tools or linters configured with custom rules for path injection and unsafe upload endpoints.

