Skip to content

Commit 5f01171

Browse files
committed
shut down gradio's "everything allowed" CORS policy; I checked the main functionality to work with this, but if this breaks some exotic workflow, I'm sorry.
1 parent f2b6970 commit 5f01171

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,15 @@ The documentation was moved from this README over to the project's [wiki](https:
155155
- Swin2SR - https://github.com/mv-lab/swin2sr
156156
- LDSR - https://github.com/Hafiidz/latent-diffusion
157157
- Ideas for optimizations - https://github.com/basujindal/stable-diffusion
158-
- Doggettx - Cross Attention layer optimization - https://github.com/Doggettx/stable-diffusion, original idea for prompt editing.
159-
- InvokeAI, lstein - Cross Attention layer optimization - https://github.com/invoke-ai/InvokeAI (originally http://github.com/lstein/stable-diffusion)
160-
- Rinon Gal - Textual Inversion - https://github.com/rinongal/textual_inversion (we're not using his code, but we are using his ideas).
158+
- Cross Attention layer optimization - Doggettx - https://github.com/Doggettx/stable-diffusion, original idea for prompt editing.
159+
- Cross Attention layer optimization - InvokeAI, lstein - https://github.com/invoke-ai/InvokeAI (originally http://github.com/lstein/stable-diffusion)
160+
- Textual Inversion - Rinon Gal - https://github.com/rinongal/textual_inversion (we're not using his code, but we are using his ideas).
161161
- Idea for SD upscale - https://github.com/jquesnelle/txt2imghd
162162
- Noise generation for outpainting mk2 - https://github.com/parlance-zz/g-diffuser-bot
163163
- CLIP interrogator idea and borrowing some code - https://github.com/pharmapsychotic/clip-interrogator
164164
- Idea for Composable Diffusion - https://github.com/energy-based-model/Compositional-Visual-Generation-with-Composable-Diffusion-Models-PyTorch
165165
- xformers - https://github.com/facebookresearch/xformers
166166
- DeepDanbooru - interrogator for anime diffusers https://github.com/KichangKim/DeepDanbooru
167+
- Security advice - RyotaK
167168
- Initial Gradio script - posted on 4chan by an Anonymous user. Thank you Anonymous user.
168169
- (You)

webui.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ def webui():
141141
# after initial launch, disable --autolaunch for subsequent restarts
142142
cmd_opts.autolaunch = False
143143

144+
# gradio uses a very open CORS policy via app.user_middleware, which makes it possible for
145+
# an attacker to trick the user into opening a malicious HTML page, which makes a request to the
146+
# running web ui and do whatever the attcker wants, including installing an extension and
147+
# runnnig its code. We disable this here. Suggested by RyotaK.
148+
app.user_middleware = [x for x in app.user_middleware if x.cls.__name__ != 'CORSMiddleware']
149+
144150
app.add_middleware(GZipMiddleware, minimum_size=1000)
145151

146152
if launch_api:

0 commit comments

Comments
 (0)