Conversation
🪼 branch checks and previews
Install Gradio from this PR pip install https://gradio-builds.s3.amazonaws.com/01a39bf774b6c215a0a29220b576bb40329c81e6/gradio-4.19.1-py3-none-any.whlInstall Gradio Python Client from this PR pip install "gradio-client @ git+https://github.com/gradio-app/gradio@01a39bf774b6c215a0a29220b576bb40329c81e6#subdirectory=client/python" |
🦄 change detectedThis Pull Request includes changes to the following packages.
With the following changelog entry.
Maintainers or the PR author can modify the PR title to modify this entry.
|
|
This fix looks great. Thank you for the resolution. |
akx
left a comment
There was a problem hiding this comment.
Wouldn't this be served by just setting allow_origin_regex for CORSMiddleware?
I don't believe so, no. We want to apply CORS only if the |
|
Thank you @whitphx @akx @pngwn for the reviews, and for @PinkDraconian for reporting the original issue! |
To prevent malicious 3rd party websites from making requests to Gradio applications running locally, this PR tightens the CORS rules around Gradio applications. In particular, based on @XciD's suggestion: it checks to see if the host header is
localhost(or one of its aliases) and if so, it requires the origin header (if present) to belocalhost(or one of its aliases) as well.To test this, you can start running any Gradio app, e.g. this one, locally:
And then open up different websites in your browser and simulate requests from them using the Inspector console, e.g.:
If you make the request from a website on localhost, the request should go through, but if you make the request while a different webpage is loaded, it should be blocked.
I also installed this PR in this Space: https://huggingface.co/spaces/abidlabs/test-cors, and confirmed that: