fix(security): address CodeQL path-traversal and info-exposure findings
- Add _validate_plugin_name() guard on all {name} path param endpoints
(rejects /, \, .. before reaching plugin logic)
- Strip after_install_path from install response (no internal paths to client)
- Update nix/tui.nix lockfile hash to match committed package-lock.json
This commit is contained in:
parent
e2a4905606
commit
6549b0f2b7
@ -3780,12 +3780,22 @@ async def post_agent_plugin_install(request: Request, body: _AgentPluginInstallB
|
|||||||
detail=result.get("error") or "Install failed.",
|
detail=result.get("error") or "Install failed.",
|
||||||
)
|
)
|
||||||
_get_dashboard_plugins(force_rescan=True)
|
_get_dashboard_plugins(force_rescan=True)
|
||||||
|
# Strip internal paths from the response
|
||||||
|
result.pop("after_install_path", None)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def _validate_plugin_name(name: str) -> str:
|
||||||
|
"""Reject path-traversal attempts in plugin name URL parameters."""
|
||||||
|
if not name or "/" in name or "\\" in name or ".." in name:
|
||||||
|
raise HTTPException(status_code=400, detail="Invalid plugin name.")
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
@app.post("/api/dashboard/agent-plugins/{name}/enable")
|
@app.post("/api/dashboard/agent-plugins/{name}/enable")
|
||||||
async def post_agent_plugin_enable(request: Request, name: str):
|
async def post_agent_plugin_enable(request: Request, name: str):
|
||||||
_require_token(request)
|
_require_token(request)
|
||||||
|
name = _validate_plugin_name(name)
|
||||||
from hermes_cli.plugins_cmd import dashboard_set_agent_plugin_enabled
|
from hermes_cli.plugins_cmd import dashboard_set_agent_plugin_enabled
|
||||||
|
|
||||||
result = dashboard_set_agent_plugin_enabled(name, enabled=True)
|
result = dashboard_set_agent_plugin_enabled(name, enabled=True)
|
||||||
@ -3797,6 +3807,7 @@ async def post_agent_plugin_enable(request: Request, name: str):
|
|||||||
@app.post("/api/dashboard/agent-plugins/{name}/disable")
|
@app.post("/api/dashboard/agent-plugins/{name}/disable")
|
||||||
async def post_agent_plugin_disable(request: Request, name: str):
|
async def post_agent_plugin_disable(request: Request, name: str):
|
||||||
_require_token(request)
|
_require_token(request)
|
||||||
|
name = _validate_plugin_name(name)
|
||||||
from hermes_cli.plugins_cmd import dashboard_set_agent_plugin_enabled
|
from hermes_cli.plugins_cmd import dashboard_set_agent_plugin_enabled
|
||||||
|
|
||||||
result = dashboard_set_agent_plugin_enabled(name, enabled=False)
|
result = dashboard_set_agent_plugin_enabled(name, enabled=False)
|
||||||
@ -3808,6 +3819,7 @@ async def post_agent_plugin_disable(request: Request, name: str):
|
|||||||
@app.post("/api/dashboard/agent-plugins/{name}/update")
|
@app.post("/api/dashboard/agent-plugins/{name}/update")
|
||||||
async def post_agent_plugin_update(request: Request, name: str):
|
async def post_agent_plugin_update(request: Request, name: str):
|
||||||
_require_token(request)
|
_require_token(request)
|
||||||
|
name = _validate_plugin_name(name)
|
||||||
from hermes_cli.plugins_cmd import dashboard_update_user_plugin
|
from hermes_cli.plugins_cmd import dashboard_update_user_plugin
|
||||||
|
|
||||||
result = dashboard_update_user_plugin(name)
|
result = dashboard_update_user_plugin(name)
|
||||||
@ -3820,6 +3832,7 @@ async def post_agent_plugin_update(request: Request, name: str):
|
|||||||
@app.delete("/api/dashboard/agent-plugins/{name}")
|
@app.delete("/api/dashboard/agent-plugins/{name}")
|
||||||
async def delete_agent_plugin(request: Request, name: str):
|
async def delete_agent_plugin(request: Request, name: str):
|
||||||
_require_token(request)
|
_require_token(request)
|
||||||
|
name = _validate_plugin_name(name)
|
||||||
from hermes_cli.plugins_cmd import dashboard_remove_user_plugin
|
from hermes_cli.plugins_cmd import dashboard_remove_user_plugin
|
||||||
|
|
||||||
result = dashboard_remove_user_plugin(name)
|
result = dashboard_remove_user_plugin(name)
|
||||||
|
|||||||
@ -4,7 +4,7 @@ let
|
|||||||
src = ../ui-tui;
|
src = ../ui-tui;
|
||||||
npmDeps = pkgs.fetchNpmDeps {
|
npmDeps = pkgs.fetchNpmDeps {
|
||||||
inherit src;
|
inherit src;
|
||||||
hash = "sha256-Chz+NW9NXqboXHOa6PKwf5bhAkkcFtKNhvKWwg2XSPc=";
|
hash = "sha256-a/HGI9OgVcTnZrMXA7xFMGnFoVxyHe95fulVz+WNYB0=";
|
||||||
};
|
};
|
||||||
|
|
||||||
npm = hermesNpmLib.mkNpmPassthru { folder = "ui-tui"; attr = "tui"; pname = "hermes-tui"; };
|
npm = hermesNpmLib.mkNpmPassthru { folder = "ui-tui"; attr = "tui"; pname = "hermes-tui"; };
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user