Prevent POST /dev/unload behind an opt-in setting#483
Open
sanjaygulati13 wants to merge 1 commit into
Open
Conversation
Currently /dev/unload is mounted by default with no authentication, so any caller that can reach the API can unload the active model from memory and can possibly force repeated reload cycles (remsky#478). Add an 'allow_dev_unload' setting (default False) and return 403 when disabled, so the endpoint is off by default and can be re-enabled with ALLOW_DEV_UNLOAD=true for trusted deployments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently /dev/unload is mounted by default with no authentication, so any caller that can reach the API can unload the active model from memory and can possibly force repeated reload cycles (#478).
Added an
allow_dev_unloadsetting (defaultFalse) and return 403 when disabled. The endpoint is off by default and can be re-enabled with ALLOW_DEV_UNLOAD=true for trusted deployments.Testing:
uv run pytest(94 tests passed, I have included a new 403-when-disabled test) plus tried live, non-Docker run and I confirm/dev/unloadreturns 403 by default and 200 withALLOW_DEV_UNLOAD=trueset.Did not test via Docker Compose or on CUDA hardware (I have Apple Silicon Mac). The change is a config flag and an early return guard with no docker container or GPU specific paths, but appreciate if someone else can confirm on other environments.