Skip to content

Hardcoded CORS wildcard on TTS endpoint enables cross-origin credential abuse from any webpage#5901

Open
christopherholland-workday wants to merge 5 commits intomainfrom
text-to-speach-fixes
Open

Hardcoded CORS wildcard on TTS endpoint enables cross-origin credential abuse from any webpage#5901
christopherholland-workday wants to merge 5 commits intomainfrom
text-to-speach-fixes

Conversation

@christopherholland-workday
Copy link
Contributor

@christopherholland-workday christopherholland-workday commented Mar 4, 2026

FLOWISE-289.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the security of the text-to-speech functionality by introducing robust authentication and authorization mechanisms. It ensures that requests providing credentials in the body are properly authenticated and that the specified credentials are valid and belong to the user's active workspace, thereby preventing unauthorized access and misuse of resources.

Highlights

  • Authentication Enforcement: Implemented authentication checks for text-to-speech requests when credentials are provided in the request body, ensuring that only authenticated users can utilize this feature with their own credentials.
  • Credential Validation: Added validation to ensure that any credentialId supplied in the request body belongs to the authenticated user's active workspace, preventing unauthorized use of credentials.
  • CORS Header Removal: Removed Access-Control-Allow-Origin and Access-Control-Allow-Headers from text-to-speech responses, likely to align with the new authentication requirements and enhance security.
Changelog
  • packages/server/src/controllers/text-to-speech/index.ts
    • Imported the credentialsService to facilitate credential validation.
    • Added logic to verify user authentication and the presence of a credentialId when credentials are provided in the request body.
    • Implemented a check to confirm that the credentialId belongs to the authenticated user's active workspace.
    • Removed Access-Control-Allow-Origin and Access-Control-Allow-Headers from the response headers for text-to-speech streams.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces important security fixes for the text-to-speech endpoint, adding authentication and authorization checks for credentialId usage and centralizing CORS policy management by removing local headers. These changes effectively mitigate potential Insecure Direct Object Reference (IDOR) vulnerabilities. I've provided a suggestion for improving error handling for missing parameters, modified to align with the repository's rule on combining preliminary checks, and noted a typo in the pull request title: 'speach' should be 'speech'.

@christopherholland-workday christopherholland-workday marked this pull request as ready for review March 4, 2026 19:26
@yau-wd
Copy link
Contributor

yau-wd commented Mar 5, 2026

@0xi4o is the best person to review this PR.

@yau-wd yau-wd requested review from 0xi4o and removed request for HenryHengZJ and yau-wd March 5, 2026 06:56
@HenryHengZJ
Copy link
Contributor

HenryHengZJ commented Mar 9, 2026

TTS is currently a whitelisted endpoint.

Anyone who can start a prediction for a public flow (with those ids) can also call the text to speech functionality.

This ties to the issue where every flows by default have unauthenticated access. Once we solve that issue where we require:

  • API key to access published flows API
  • Client Secret to access ChatEmbed

We can then get rid of these whitelisted endpoints (i.e: prediction, tts, etc)

#5917

@christopherholland-workday christopherholland-workday changed the title Text to speach authentication fixes Hardcoded CORS wildcard on TTS endpoint enables cross-origin credential abuse from any webpage Mar 9, 2026
@HenryHengZJ
Copy link
Contributor

HenryHengZJ commented Mar 9, 2026

With this changes, will all existing users not able to use TTS unless explicitly configure CORS process env? What about users that do not know how to setup these? Shouldnt this follow the getCorsOptions function?

image

@christopherholland-workday
Copy link
Contributor Author

@HenryHengZJ The TTS URL (/api/v1/text-to-speech/) does not match ALLOWED_SLUGS in https://github.com/FlowiseAI/Flowise/blob/main/packages/server/src/utils/domainValidation.ts#L10, so the cors middleware treats it as an authenticated endpoint even today.

The original wildcard allowed bypass of cors, but it should be following the same rules as other endpoints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants