fix(security): block refresh tokens as bearer and sandbox MCP uploads

Reject refresh JWTs in ValidateToken, revoke all user sessions on logout,
and restrict create_knowledge_from_file to allowed directories on network MCP transports.
This commit is contained in:
wizardchen
2026-07-02 15:26:43 +08:00
committed by lyingbug
parent cd65665894
commit 040504447e
7 changed files with 180 additions and 3 deletions
+3 -1
View File
@@ -23,6 +23,7 @@ import requests
from mcp.server import NotificationOptions, Server
from mcp.server.models import InitializationOptions
from requests.exceptions import RequestException
from upload_paths import resolve_upload_file_path
# Set up logging configuration for the MCP server
logging.basicConfig(level=logging.INFO)
@@ -260,7 +261,8 @@ class WeKnoraClient:
self, kb_id: str, file_path: str, enable_multimodel: bool = True
) -> Dict:
"""Create knowledge from a local file with optional multimodal processing"""
with open(file_path, "rb") as f:
safe_path = resolve_upload_file_path(file_path)
with open(safe_path, "rb") as f:
files = {"file": f}
data = {"enable_multimodel": str(enable_multimodel).lower()}
# Temporarily remove Content-Type header for multipart/form-data request