New MCP server — Bring vulnerability intelligence into your AI
Back to feed

CVE-2026-22688

ExploitedNVDCIRCLENISA

EUVD-2026-1695 · Published Jan 9, 2026

WeKnora has Command Injection in MCP stdio test

Vulnerability Description

Vulnerability Overview

This issue is a command injection vulnerability (CWE-78) that allows authenticated users to inject stdio_config.command/args into MCP stdio settings, causing the server to execute subprocesses using these injected values.

The root causes are as follows:

  • Missing Security Filtering: When transport_type=stdio, there is no validation on stdio_config.command/args, such as allowlisting, enforcing fixed paths/binaries, or blocking dangerous options.
  • Functional Flaw (Trust Boundary Violation): The command/args stored as "service configuration data" are directly used in the /test execution flow and connected to execution sinks without validation.
  • Lack of Authorization Control: This functionality effectively allows "process execution on the server" (an administrative operation), yet no administrator-only permission checks are implemented in the code (accessible with Bearer authentication only).

Vulnerable Code

  1. API Route Registration (path where endpoints are created)
    ****https://github.com/Tencent/WeKnora/blob/6b7558c5592828380939af18240a4cef67a2cbfc/internal/router/router.go#L85-L110
    https://github.com/Tencent/WeKnora/blob/6b7558c5592828380939af18240a4cef67a2cbfc/internal/router/router.go#L371-L390

     // 认证中间件
    	r.Use(middleware.Auth(params.TenantService, params.UserService, params.Config))
    
    	// 添加OpenTelemetry追踪中间件
    	r.Use(middleware.TracingMiddleware())
    
    	// 需要认证的API路由
    	v1 := r.Group("/api/v1")
    	{
    		RegisterAuthRoutes(v1, params.AuthHandler)
    		RegisterTenantRoutes(v1, params.TenantHandler)
    		RegisterKnowledgeBaseRoutes(v1, params.KBHandler)
    		RegisterKnowledgeTagRoutes(v1, params.TagHandler)
    		RegisterKnowledgeRoutes(v1, params.KnowledgeHandler)
    		RegisterFAQRoutes(v1, params.FAQHandler)
    		RegisterChunkRoutes(v1, params.ChunkHandler)
    		RegisterSessionRoutes(v1, params.SessionHandler)
    		RegisterChatRoutes(v1, params.SessionHandler)
    		RegisterMessageRoutes(v1, params.MessageHandler)
    		RegisterModelRoutes(v1, params.ModelHandler)
    		RegisterEvaluationRoutes(v1, params.EvaluationHandler)
    		RegisterInitializationRoutes(v1, params.InitializationHandler)
    		RegisterSystemRoutes(v1, params.SystemHandler)
    		RegisterMCPServiceRoutes(v1, params.MCPServiceHandler)
    		RegisterWebSearchRoutes(v1, params.WebSearchHandler)
    	}
    
    func RegisterMCPServiceRoutes(r *gin.RouterGroup, handler *handler.MCPServiceHandler) {
    	mcpServices := r.Group("/mcp-services")
    	{
    		// Create MCP service
    		mcpServices.POST("", handler.CreateMCPService)
    		// List MCP services
    		mcpServices.GET("", handler.ListMCPServices)
    		// Get MCP service by ID
    		mcpServices.GET("/:id", handler.GetMCPService)
    		// Update MCP service
    		mcpServices.PUT("/:id", handler.UpdateMCPService)
    		// Delete MCP service
    		mcpServices.DELETE("/:id", handler.DeleteMCPService)
    		// Test MCP service connection
    		mcpServices.POST("/:id/test", handler.TestMCPService)
    		// Get MCP service tools
    		mcpServices.GET("/:id/tools", handler.GetMCPServiceTools)
    		// Get MCP service resources
    		mcpServices.GET("/:id/resources", handler.GetMCPServiceResources)
    	}
    
  2. User input (JSON) → types.MCPService binding (POST /api/v1/mcp-services)
    ****https://github.com/Tencent/WeKnora/blob/6b7558c5592828380939af18240a4cef67a2cbfc/internal/handler/mcp_service.go#L40-L55

    	var service types.MCPService
    	if err := c.ShouldBindJSON(&service); err != nil {
    		logger.Error(ctx, "Failed to parse MCP service request", err)
    		c.Error(errors.NewBadRequestError(err.Error()))
    		return
    	}
    
    	tenantID := c.GetUint64(types.TenantIDContextKey.String())
    	if tenantID == 0 {
    		logger.Error(ctx, "Tenant ID is empty")
    		c.Error(errors.NewBadRequestError("Tenant ID cannot be empty"))
    		return
    	}
    	service.TenantID = tenantID
    
    	if err := h.mcpServiceService.CreateMCPService(ctx, &service); err != nil {
    
  3. Taint propagation (storage): The bound service object is stored directly in the database without sanitization.
    ****https://github.com/Tencent/WeKnora/blob/6b7558c5592828380939af18240a4cef67a2cbfc/internal/application/repository/mcp_service.go#L23-L25

    func (r *mcpServiceRepository) Create(ctx context.Context, service *types.MCPService) error {
    	return r.db.WithContext(ctx).Create(service).Error
    }
    
  4. Sink execution: /test endpoint loads the service from the database → executes TestMCPService

    https://github.com/Tencent/WeKnora/blob/6b7558c5592828380939af18240a4cef67a2cbfc/internal/handler/mcp_service.go#L323-L325
    https://github.com/Tencent/WeKnora/blob/6b7558c5592828380939af18240a4cef67a2cbfc/internal/application/service/mcp_service.go#L238-L264

    	logger.Infof(ctx, "Testing MCP service: %s", secutils.SanitizeForLog(serviceID))
    
    	result, err := h.mcpServiceService.TestMCPService(ctx, tenantID, serviceID)
    
    	service, err := s.mcpServiceRepo.GetByID(ctx, tenantID, id)
    	if err != nil {
    		return nil, fmt.Errorf("failed to get MCP service: %w", err)
    	}
    	if service == nil {
    		return nil, fmt.Errorf("MCP service not found")
    	}
    
    	// Create temporary client for testing
    	config := &mcp.ClientConfig{
    		Service: service,
    	}
    
    	client, err := mcp.NewMCPClient(config)
    	if err != nil {
    		return &types.MCPTestResult{
    			Success: false,
    			Message: fmt.Sprintf("Failed to create client: %v", err),
    		}, nil
    	}
    
    	// Connect
    	testCtx, cancel := context.WithTimeout(ctx, 30*time.Second)
    	defer cancel()
    
    	if err := client.Connect(testCtx); err != nil {
    		return &types.MCPTestResult{
    
  5. Ultimate sink (subprocess execution): The command/args values from stdio configuration are directly used in the subprocess execution path.
    ****https://github.com/Tencent/WeKnora/blob/6b7558c5592828380939af18240a4cef67a2cbfc/internal/mcp/client.go#L120-L137
    https://github.com/Tencent/WeKnora/blob/6b7558c5592828380939af18240a4cef67a2cbfc/internal/mcp/client.go#L158-L160

    	case types.MCPTransportStdio:
    		if config.Service.StdioConfig == nil {
    			return nil, fmt.Errorf("stdio_config is required for stdio transport")
    		}
    
    		// Convert env vars map to []string format (KEY=value)
    		envVars := make([]string, 0, len(config.Service.EnvVars))
    		for key, value := range config.Service.EnvVars {
    			envVars = append(envVars, fmt.Sprintf("%s=%s", key, value))
    		}
    
    		// Create stdio client with options
    		// NewStdioMCPClientWithOptions(command string, env []string, args []string, opts ...transport.StdioOption)
    		mcpClient, err = client.NewStdioMCPClientWithOptions(
    			config.Service.StdioConfig.Command,
    			envVars,
    			config.Service.StdioConfig.Args,
    		)
    
    	if err := c.client.Start(ctx); err != nil {
    		return fmt.Errorf("failed to start client: %w", err)
    	}
    
PoC

PoC Description

  • Obtain an authentication token.
  • Create an MCP service with transport_type=stdio, injecting the command to execute into stdio_config.command/args.
  • Call the /test endpoint to trigger the Connect() → Start() execution flow, confirming command execution on the server via side effects (e.g., file creation).

PoC

Impact

  • Remote Code Execution (RCE): Arbitrary command execution enables file creation/modification, execution of additional payloads, and service disruption
  • Information Disclosure: Sensitive data exfiltration through reading environment variables, configuration files, keys, tokens, and local files
  • Privilege Escalation/Lateral Movement (Environment-Dependent): Impact may escalate based on container mounts, network policies, and internal service access permissions
  • Cross-Tenant Boundary Impact: Execution occurs in a shared backend runtime; depending on deployment configuration, impact may extend beyond tenant boundaries (exact scope is uncertain and varies by deployment setup)

Technologies

Tencent Weknora

Weaknesses

CWE-77

CVSS scores

  • v3.19.9CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H

MITRE ATT&CK

Inferred

Where this vulnerability fits in an attack

Initial Access

References

Potentially impacted assets

See if this affects your attack surface

Latest trending attack

Criticalyesterday

Google Brotli decoder - Remote Code Execution via compressed requests (Exploitation Check)

This control is the second step of the Patrowl response to CVE-2026-111497 (Node2Shell). It complements the first control of 22 October 2026, which focused on the Node.js runtime, and does not replace it. Why a second control CVE-2026-111497 is an out-of-bounds write in the Google Brotli decoder, the library that decompresses Brotli ("br") data. It was first published as a Node.js vulnerability, because Node.js bundles this decoder. Later publications showed that the flaw is in the library itself. Every product that embeds an affected version of the decoder is concerned, whatever its language or vendor. A public proof of concept demonstrates code execution. Any server that decompresses request bodies sent with "Content-Encoding: br" exposes the decoder to unauthenticated attackers. Known cases include Express 5 and NestJS 11 on Node.js, Koa and Fastify setups, Bun, Envoy and Istio with request decompression enabled, and any application or reverse proxy that decodes Brotli request bodies with an affected library. The flaw also works in the other direction. A malicious server can compromise an unpatched client that decodes a Brotli response, for example Node.js fetch(), Python clients (requests, httpx, aiohttp, Scrapy) with the Brotli or brotlicffi package, or libcurl builds with Brotli support. What this control checks Patrowl sends small, valid Brotli-compressed requests to each asset and observes whether the server decodes them. The check does not depend on the technology: it detects the behaviour, whatever the stack behind it. These requests are what any legitimate client could send. They never reach the vulnerable code path and cannot affect the availability of the service. How to read the result Potentially impacted means the asset decodes Brotli request bodies: the attack surface is exposed. It does not confirm that the asset is vulnerable. The version of the Brotli decoder in use is not visible from the outside. This check covers applications that parse request bodies on their root path. A Not impacted result does not rule out exposure on other routes, nor on the client side. Checking the versions on the servers remains the only exhaustive verification. Affected and fixed versions Google Brotli 1.0.3 to 1.2.0 are affected, fixed in 1.0.10, 1.1.1 and 1.2.1. Fixed releases of the main products embedding it: Node.js 22.23.4, 24.22.1 and 26.12.1 (end-of-life lines 20.x and older and 25.x receive no fix), Bun 1.4.4, Envoy 1.37.8, 1.38.6, 1.39.3 and 1.40.0, Istio 1.29.9, 1.30.6 and 1.31.2, Python Brotli 1.2.1 and brotlicffi 1.2.1.0. Products that link against the system library depend on the Brotli package of the Linux distribution. Recommendations Update every component that embeds the Brotli decoder (only real fix). Start with the assets flagged by this control. Restart the processes after the update. Rebuild containers, single-executable applications and appliances that bundle an affected runtime or library. Reduce the exposure until the update is deployed. Reject requests with "Content-Encoding: br" at the reverse proxy, load balancer or WAF, case-insensitively and including lists such as "gzip, br". On Envoy and Istio, disable request decompression for Brotli. Review outbound calls. List the features that fetch content from servers you do not control, and patch the services that host them first.

Take 15 minutes to discover our platform with our experts

Patrowl Intel platform screenshot