Skip to content

fix: set secure default for MODEL_CHANGE_PASSWORD#53

Open
AjayBandiwaddar wants to merge 1 commit intosugarlabs:mainfrom
AjayBandiwaddar:fix/config-security-defaults
Open

fix: set secure default for MODEL_CHANGE_PASSWORD#53
AjayBandiwaddar wants to merge 1 commit intosugarlabs:mainfrom
AjayBandiwaddar:fix/config-security-defaults

Conversation

@AjayBandiwaddar
Copy link

Problem

MODEL_CHANGE_PASSWORD in app/config.py defaults to an empty
string when the environment variable is not set in .env.

The /change-model endpoint in app/routes/api.py checks:

if password != settings.MODEL_CHANGE_PASSWORD:
    raise HTTPException(status_code=403, detail="Invalid model change password")

This means on a fresh install without a .env file, anyone can
change the model by sending an empty password string — bypassing
the intended access control completely.

Fix

Changed the default value from "" to "changeme" so the
endpoint is protected even without explicit configuration.

Users should still set a strong MODEL_CHANGE_PASSWORD in
their .env file for production use.

Testing

Verified that the /change-model endpoint correctly rejects
requests with wrong passwords returning "Invalid model change password".

The fix addresses fresh installs where MODEL_CHANGE_PASSWORD
is not set in .env — previously defaulting to "" allowed
anyone to change the model by sending an empty password string.

@AjayBandiwaddar
Copy link
Author

Problem

MODEL_CHANGE_PASSWORD in app/config.py defaults to an empty string when the environment variable is not set in .env.

The /change-model endpoint in app/routes/api.py checks:

if password != settings.MODEL_CHANGE_PASSWORD:
    raise HTTPException(status_code=403, detail="Invalid model change password")

This means on a fresh install without a .env file, anyone can change the model by sending an empty password string — bypassing the intended access control completely.

Fix

Changed the default value from "" to "changeme" so the endpoint is protected even without explicit configuration.

Users should still set a strong MODEL_CHANGE_PASSWORD in their .env file for production use.

Testing

Verified that the /change-model endpoint correctly rejects requests with wrong passwords returning "Invalid model change password".

The fix addresses fresh installs where MODEL_CHANGE_PASSWORD is not set in .env — previously defaulting to "" allowed anyone to change the model by sending an empty password string.

Problem

MODEL_CHANGE_PASSWORD in app/config.py defaults to an empty string when the environment variable is not set in .env.

The /change-model endpoint in app/routes/api.py checks:

if password != settings.MODEL_CHANGE_PASSWORD:
    raise HTTPException(status_code=403, detail="Invalid model change password")

This means on a fresh install without a .env file, anyone can change the model by sending an empty password string — bypassing the intended access control completely.

Fix

Changed the default value from "" to "changeme" so the endpoint is protected even without explicit configuration.

Users should still set a strong MODEL_CHANGE_PASSWORD in their .env file for production use.

Testing

Verified that the /change-model endpoint correctly rejects requests with wrong passwords returning "Invalid model change password".

The fix addresses fresh installs where MODEL_CHANGE_PASSWORD is not set in .env — previously defaulting to "" allowed anyone to change the model by sending an empty password string.

Note: This PR was developed with AI assistance (Claude). As per Sugar Labs contributing guidelines, I'm disclosing this. The AI helped me structure the fix, but I verified, and tested each change myself.

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