Sec: PC-Executor Bearer-Token-Pflicht (RCE-Lücke schließen)
executor.py erzwingt jetzt HERMES_PC_TOKEN auf allen Steuer-Endpunkten (/shell,/screenshot,/type,/key,/open,/search), fail-closed (503) wenn kein Token gesetzt ist; /health bleibt offen für den Reachability-Check. CORS- Wildcard entfernt, Bind-Host konfigurierbar (HERMES_PC_HOST). mcp_pc.py sendet PC_EXECUTOR_TOKEN als Authorization-Bearer mit. Schließt die unauthentifizierte Remote-Code-Execution auf dem Windows-PC (host=0.0.0.0, kein Token) — Teil von Stufe 0 (Security) des Stack-Reviews. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+5
-2
@@ -14,6 +14,8 @@ import httpx
|
||||
from mcp.server.fastmcp import FastMCP
|
||||
|
||||
PC_URL = os.environ.get("PC_EXECUTOR_URL", "").rstrip("/")
|
||||
# Shared Secret — muss identisch zum HERMES_PC_TOKEN des Executors auf dem Windows-PC sein.
|
||||
PC_TOKEN = os.environ.get("PC_EXECUTOR_TOKEN", "").strip()
|
||||
|
||||
mcp = FastMCP("hermes-pc-control")
|
||||
|
||||
@@ -21,12 +23,13 @@ mcp = FastMCP("hermes-pc-control")
|
||||
def _pc(path: str, data: dict | None = None) -> dict:
|
||||
if not PC_URL:
|
||||
return {"error": "PC_EXECUTOR_URL nicht gesetzt. Setze die Env-Variable mit der IP des Windows PCs."}
|
||||
headers = {"Authorization": f"Bearer {PC_TOKEN}"} if PC_TOKEN else {}
|
||||
try:
|
||||
with httpx.Client(timeout=90) as c:
|
||||
if data is None:
|
||||
r = c.get(f"{PC_URL}{path}")
|
||||
r = c.get(f"{PC_URL}{path}", headers=headers)
|
||||
else:
|
||||
r = c.post(f"{PC_URL}{path}", json=data)
|
||||
r = c.post(f"{PC_URL}{path}", json=data, headers=headers)
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
except httpx.ConnectError:
|
||||
|
||||
Reference in New Issue
Block a user