fix: require admin role on POST /configure to prevent unauthorized co…#5128
Closed
AAtomical wants to merge 1 commit into
Closed
fix: require admin role on POST /configure to prevent unauthorized co…#5128AAtomical wants to merge 1 commit into
AAtomical wants to merge 1 commit into
Conversation
Contributor
|
Closing as superseded — this surface was addressed in PR #5360 (server hardening), which has been merged. Thanks for the report and the fix attempt, @AAtomical! |
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.
…nfig changes
Linked Issue
Fixes #5127
Description
POST /configuremodifies the global LLM/embedder provider configuration (endpoint URL, API key, model) for the entire Mem0 instance. This endpoint currently usesverify_authwhich validatestoken presence but never checks
user.role.Any holder of a distributed API key can call
POST /configureto redirect all users' LLM traffic to an arbitrary endpoint. This PR adds arequire_admindependency that enforcesuser.role == "admin"on this endpoint.Changes:
require_admin()auth dependency inserver/auth.pyPOST /configurefromDepends(verify_auth)toDepends(require_admin)403 ForbiddenType of Change
Breaking Changes
API keys created by admin and distributed to services will no longer be able to call
POST /configure. Only the admin account (via JWT orADMIN_API_KEYenv var) can modify configuration.GET /configureremains accessible to all authenticated users.Test Coverage
With
AUTH_DISABLED=false: