File size: 1,902 Bytes
497ac8a
898e68e
497ac8a
898e68e
 
497ac8a
898e68e
 
 
 
497ac8a
 
 
898e68e
 
 
773d81c
898e68e
 
773d81c
898e68e
 
 
 
497ac8a
 
898e68e
497ac8a
898e68e
497ac8a
898e68e
 
773d81c
898e68e
 
 
773d81c
 
898e68e
497ac8a
898e68e
497ac8a
898e68e
 
 
 
497ac8a
 
 
898e68e
 
497ac8a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import gradio as gr
import json

# Sample data with HuggingFace image URLs that redirect to cas-bridge-direct.xethub.hf.co
sample_loras = [
    {
        "image": "https://huggingface.co/Norod78/Flux_1_Dev_LoRA_Paper-Cutout-Style/resolve/main/08a19840b6214b76b0607b2f9d5a7e28_63159b9d98124c008efb1d36446a615c.png",
        "title": "Paper Cutout",
        "repo": "Norod78/Flux_1_Dev_LoRA_Paper-Cutout-Style",
        "trigger_word": ", Paper Cutout Style"
    }
]

def add_custom_lora_broken(custom_lora, selected_indices, current_loras, gallery):
    """This version breaks because it passes current_loras (containing HF URLs) as function input"""
    print("Starting to load a custom LoRA...")  # This won't print due to preprocessing error
    
    if custom_lora:
        pass
    
    return current_loras, gr.update(), gr.update(), gr.update(), selected_indices

# Initialize state with URLs that will cause SSRF validation issues
loras_state = gr.State(sample_loras)

with gr.Blocks() as demo:
    gr.Markdown("# SSRF Validation Bug Reproduction")
    
    selected_indices = gr.State([])
    
    custom_lora_input = gr.Textbox(label="Custom LoRA", placeholder="Enter custom LoRA")
        
    gallery = gr.Gallery(
        [(item["image"], item["title"]) for item in sample_loras],
        label="LoRA Gallery", 
        columns=2
    )
    
    broken_button = gr.Button("Add Custom LoRA (Broken - passes state with URLs)")
    
    error_display = gr.Textbox(label="Error/Success", interactive=False)
    
    broken_button.click(
        add_custom_lora_broken,
        inputs=[custom_lora_input, selected_indices, loras_state, gallery],  # ← loras_state causes SSRF error
        outputs=[loras_state, gallery, error_display, custom_lora_input, selected_indices]
    )

if __name__ == "__main__":
    # Set global variable for working version
    loras = sample_loras
    demo.launch()