fix: Unauthorized access to user plugin endpoints #2821
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.
Version: 0.7.2
CVSS: 3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N
Score: 9.1 (Critical)
Description
There are multiple Insecure Direct Object Reference (IDOR) vulnerabilities in the agent plugin management endpoints that allow unauthenticated attackers to access and modify any user's plugin data. The vulnerability exists in four critical endpoints that accept an optional 'user' parameter without any authentication or authorization checks.
The system falls back to a "default" user when no user is specified, and directly passes user-controlled parameters to database queries without validation. This design flaw allows complete bypass of access controls, enabling attackers to view, install, uninstall, and upload plugins under any user's account.
While there are authentication mechanisms in other parts of the codebase using
check_api_keydependencies, the agent hub controller endpoints are completely unprotected and accessible by default whenapi_keys = [](the default configuration).Source - Sink Analysis
Source: User-controlled
userparameter in HTTP requests to agent hub endpointsCall Chain:
/api/v1/agent/mywith user parametermy_agents()function inpackages/dbgpt-serve/src/dbgpt_serve/agent/hub/controller.py:88plugin_hub.get_my_plugin(user)inpackages/dbgpt-serve/src/dbgpt_serve/agent/hub/plugin_hub.py:404my_plugin_dao.get_by_user(user)inpackages/dbgpt-serve/src/dbgpt_serve/agent/hub/plugin_hub.py:408packages/dbgpt-serve/src/dbgpt_serve/agent/hub/db/my_plugin_db.py:90Similar flow applies to:
/api/v1/agent/install→install_plugin()→get_by_user_and_plugin()/api/v1/agent/uninstall→uninstall_plugin()→get_by_user_and_plugin()/api/v1/personal/agent/upload→upload_my_plugin()→ database insertion with user parameterProof of Concept
Impact
cc: @fangyinc @Aries-ckt