{"id":1663,"cve":"CVE-2026-29787","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-29787\/","cwe":"CWE-200","cwe_number":200,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/200","cvss_score":5.3,"published":"2026-03-07","owasp":"A01 Broken Access Control","odc":"Checking","cdc":"Missing Check","category":"Information Leakage","subcategory":"Information Disclosure","scope":"Remote","impact":"Information Disclosure","summary":"mcp-memory-service exposes system info via unauthenticated health endpoint.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-29787\/","description":"mcp-memory-service is an open-source memory backend for multi-agent systems. Prior to version 10.21.0, the \/api\/health\/detailed endpoint returns detailed system information including OS version, Python version, CPU count, memory totals, disk usage, and the full database filesystem path. When MCP_ALLOW_ANONYMOUS_ACCESS=true is set (required for the HTTP server to function without OAuth\/API key), this endpoint is accessible without authentication. Combined with the default 0.0.0.0 binding, this exposes sensitive reconnaissance data to the entire network. This issue has been patched in version 10.21.0.","solution":"Upgrade mcp-memory-service to version 10.21.0 or later.","affected_component":"mcp-memory-service","fixed_by_upgrading":true,"vulnerable_code":"import os\nimport sys\nimport platform\nimport psutil\nfrom flask import Flask, jsonify\n\n# --- Vulnerable Code Simulation ---\n# This code represents the state of the application BEFORE the patch for CVE-2026-29787.\n# The vulnerability lies in the unauthenticated exposure of the \/api\/health\/detailed endpoint\n# when the application is configured to allow anonymous access.\n\n# Assume MCP_ALLOW_ANONYMOUS_ACCESS is set to \"true\" via an environment variable.\n# For this demonstration, we'll proceed as if this condition is met.\n\napp = Flask(__name__)\n\n# This would typically be loaded from a configuration file or environment.\n# Exposing this is a key part of the vulnerability.\nDATABASE_FILESYSTEM_PATH = \"\/var\/lib\/mcp\/data\/memory_database.db\"\n\n@app.route('\/api\/health\/detailed', methods=['GET'])\ndef get_detailed_health():\n    \"\"\"\n    VULNERABLE ENDPOINT: Exposes detailed system and application information\n    without any authentication or authorization checks.\n    \"\"\"\n    try:\n        # Gather sensitive system information\n        os_version = platform.platform()\n        python_version = sys.version\n        cpu_count = os.cpu_count()\n        \n        # Memory usage\n        memory = psutil.virtual_memory()\n        memory_total_gb = round(memory.total \/ (1024 ** 3), 2)\n        memory_used_gb = round(memory.used \/ (1024 ** 3), 2)\n        memory_percent = memory.percent\n\n        # Disk usage for the root partition\n        disk = psutil.disk_usage('\/')\n        disk_total_gb = round(disk.total \/ (1024 ** 3), 2)\n        disk_used_gb = round(disk.used \/ (1024 ** 3), 2)\n        disk_percent = disk.percent\n\n        # Construct the detailed response payload\n        detailed_info = {\n            \"status\": \"ok\",\n            \"system_details\": {\n                \"os_version\": os_version,\n                \"python_version\": python_version,\n                \"cpu_count\": cpu_count,\n                \"memory\": {\n                    \"total_gb\": memory_total_gb,\n                    \"used_gb\": memory_used_gb,\n                    \"usage_percent\": memory_percent\n                },\n                \"disk\": {\n                    \"total_gb\": disk_total_gb,\n                    \"used_gb\": disk_used_gb,\n                    \"usage_percent\": disk_percent\n                }\n            },\n            \"database\": {\n                \"path\": DATABASE_FILESYSTEM_PATH  # Leaking the full filesystem path\n            }\n        }\n        return jsonify(detailed_info), 200\n\n    except Exception as e:\n        return jsonify({\"status\": \"error\", \"message\": str(e)}), 500\n\nif __name__ == '__main__':\n    # The default binding to '0.0.0.0' makes the server accessible from the entire network.\n    # Combined with the lack of authentication on the detailed health endpoint, this\n    # exposes sensitive reconnaissance data.\n    print(\"Starting vulnerable mcp-memory-service...\")\n    print(\"WARNING: MCP_ALLOW_ANONYMOUS_ACCESS is enabled.\")\n    print(\"WARNING: The \/api\/health\/detailed endpoint is exposed without authentication.\")\n    app.run(host='0.0.0.0', port=8000)","patched_code":"import os\nimport sys\nimport psutil\nimport shutil\nfrom typing import Optional\n\nfrom fastapi import FastAPI, Depends, Header, HTTPException, status\nfrom pydantic import BaseModel, Field\n\n# --- Configuration ---\n# In a real application, this would be loaded from environment variables.\nADMIN_API_KEY = \"fixed-secret-api-key-required-for-details\"\nDB_FILESYSTEM_PATH = \"\/var\/data\/mcp\/memory.db\"\n\n# This represents the vulnerable setting. Even if true, the fix ensures the\n# sensitive endpoint remains protected.\nMCP_ALLOW_ANONYMOUS_ACCESS = True\n\n\n# --- FastAPI Application Setup ---\n# This code represents the patched version (e.g., 10.21.0 or later).\napp = FastAPI(\n    title=\"MCP Memory Service (Patched)\",\n    version=\"10.21.0\",\n)\n\n\n# --- Pydantic Models for Response Payloads ---\nclass BasicHealthResponse(BaseModel):\n    status: str = \"ok\"\n\nclass DetailedHealthResponse(BaseModel):\n    os_version: str\n    python_version: str\n    cpu_count: int\n    memory_total_gb: float\n    disk_total_gb: float\n    disk_free_gb: float\n    database_path: str\n\n\n# --- Authentication Dependency (THE FIX) ---\n# This dependency function is the core of the fix. It is applied to any\n# endpoint that must be protected, ensuring an authorization check occurs\n# before the endpoint's logic is executed.\nasync def require_admin_authentication(x_admin_api_key: Optional[str] = Header(None)):\n    \"\"\"\n    Checks for a valid admin API key in the request headers.\n    If the key is missing or incorrect, it raises an HTTP 401 Unauthorized error.\n    \"\"\"\n    if not x_admin_api_key or x_admin_api_key != ADMIN_API_KEY:\n        raise HTTPException(\n            status_code=status.HTTP_401_UNAUTHORIZED,\n            detail=\"A valid X-Admin-API-Key header is required for this endpoint\",\n        )\n\n\n# --- API Endpoints ---\n\n@app.get(\n    \"\/api\/health\",\n    tags=[\"Health\"],\n    summary=\"Public Basic Health Check\",\n    response_model=BasicHealthResponse\n)\nasync def get_basic_health():\n    \"\"\"\n    A basic, non-sensitive health check that can remain public.\n    This endpoint does not have the authentication dependency.\n    \"\"\"\n    return {\"status\": \"ok\"}\n\n\n@app.get(\n    \"\/api\/health\/detailed\",\n    tags=[\"Health\"],\n    summary=\"Protected Detailed System Health Information\",\n    response_model=DetailedHealthResponse,\n    # VULNERABILITY FIX: The `dependencies` list now includes the\n    # `require_admin_authentication` check. This prevents unauthenticated\n    # access to the sensitive information returned by this endpoint.\n    dependencies=[Depends(require_admin_authentication)],\n)\nasync def get_detailed_health():\n    \"\"\"\n    Returns detailed and sensitive system information. Access is now restricted\n    to authenticated users only, resolving the information disclosure vulnerability.\n    \"\"\"\n    mem = psutil.virtual_memory()\n    disk = shutil.disk_usage(\"\/\")\n    try:\n        # os.uname() is not available on Windows\n        os_info = f\"{sys.platform} {os.uname().release}\"\n    except AttributeError:\n        os_info = f\"{sys.platform} {sys.getwindowsversion().major}.{sys.getwindowsversion().minor}\"\n\n    return DetailedHealthResponse(\n        os_version=os_info,\n        python_version=sys.version,\n        cpu_count=os.cpu_count() or 0,\n        memory_total_gb=round(mem.total \/ (1024 ** 3), 2),\n        disk_total_gb=round(disk.total \/ (1024 ** 3), 2),\n        disk_free_gb=round(disk.free \/ (1024 ** 3), 2),\n        database_path=DB_FILESYSTEM_PATH,\n    )","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[{"repository":"doobidoo\/mcp-memory-service","commit_url":"https:\/\/github.com\/doobidoo\/mcp-memory-service\/commit\/18f4323ca92763196aa2922f691dfbeb6bd84e48","commit_subject":"fix(security): harden health endpoints against info disclosure \u2014 v10.21.0 (GHSA-73hc-m4hx-79pj) (#540)","units":[{"file":"src\/mcp_memory_service\/config.py","function":null},{"file":"src\/mcp_memory_service\/mcp_server.py","function":null},{"file":"src\/mcp_memory_service\/mcp_server.py","function":"main"},{"file":"src\/mcp_memory_service\/web\/api\/configuration.py","function":null},{"file":"src\/mcp_memory_service\/web\/api\/health.py","function":null},{"file":"src\/mcp_memory_service\/web\/api\/health.py","function":"clear_caches"},{"file":"src\/mcp_memory_service\/web\/api\/health.py","function":"detailed_health_check"},{"file":"src\/mcp_memory_service\/web\/api\/health.py","function":"get_memory_stats"},{"file":"src\/mcp_memory_service\/web\/api\/health.py","function":"health_check"},{"file":"src\/mcp_memory_service\/_version.py","function":null}]}],"references":null}