Skip to content

fix: enforce CORS config and prevent path traversal in model loading#441

Open
RinZ27 wants to merge 1 commit intoGradientHQ:mainfrom
RinZ27:fix/backend-security-hardening
Open

fix: enforce CORS config and prevent path traversal in model loading#441
RinZ27 wants to merge 1 commit intoGradientHQ:mainfrom
RinZ27:fix/backend-security-hardening

Conversation

@RinZ27
Copy link
Copy Markdown

@RinZ27 RinZ27 commented Mar 23, 2026

main.py had a CORS middleware being added twice, with the first call at the top of the file hardcoding * and overriding any user-provided --allowed-origins from the CLI. This update moves the middleware initialization to the main block, ensuring it respects the parsed arguments.

Default value for allowed_origins is now set to http://localhost:3000 to avoid exposing the backend by default on non-local networks.

Additionally, get_model_info in static_config.py now uses Path(name).resolve() and includes a .is_dir() check. This prevents arbitrary file access and ensures the loader only attempts to read from valid directories, reducing the risk of directory traversal when initializing models via the /scheduler/init endpoint.

@RinZ27 RinZ27 requested a review from a team March 23, 2026 15:47
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