Skip to content

πŸ”’ [security fix] Restrict Gradio and FastAPI to localhost by default#4

Open
SarmaHighOnCode wants to merge 1 commit intomainfrom
security-fix-localhost-bind-gradio-fastapi-16310730726973963015
Open

πŸ”’ [security fix] Restrict Gradio and FastAPI to localhost by default#4
SarmaHighOnCode wants to merge 1 commit intomainfrom
security-fix-localhost-bind-gradio-fastapi-16310730726973963015

Conversation

@SarmaHighOnCode
Copy link
Owner

🎯 What: The vulnerability fixed

The application previously bound its web interfaces (Gradio and FastAPI) to 0.0.0.0, making them accessible from any network interface on the host.

⚠️ Risk: The potential impact if left unfixed

Exposing these interfaces to the public internet or untrusted networks could lead to unauthorized access to the handwriting synthesis engine, potentially leading to resource exhaustion or exploitation of any further vulnerabilities in the application.

πŸ›‘οΈ Solution: How the fix addresses the vulnerability

The fix changes the default binding address to 127.0.0.1 (localhost). This restricts access to the local machine only. For environments that require external access (like Docker or Hugging Face Spaces), the binding address can be explicitly configured via environment variables.


PR created automatically by Jules for task 16310730726973963015 started by @SarmaHighOnCode

This commit addresses a security vulnerability where the Gradio and FastAPI interfaces were exposed to all network interfaces (0.0.0.0).

Changes:
- Modified `app.py` to bind Gradio to `127.0.0.1` by default.
- Added support for `GRADIO_SERVER_NAME` environment variable to allow configuration in environments like Docker.
- Updated `backend/app/config.py` to set the default backend host to `127.0.0.1`.
- Updated `backend/.env.example` to reflect the new secure default.

This ensures the application is secure by default while remaining configurable for containerized deployments.

Co-authored-by: SarmaHighOnCode <218538054+SarmaHighOnCode@users.noreply.github.com>
@google-labs-jules
Copy link

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

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.

1 participant