Skip to content

WeKnora has Broken Access Control - Cross-Tenant Data Exposure

High severity GitHub Reviewed Published Mar 6, 2026 in Tencent/WeKnora • Updated Mar 6, 2026

Package

gomod github.com/Tencent/WeKnora (Go)

Affected versions

<= 2.0.11

Patched versions

None

Description

Summary

A broken access control vulnerability in the database query tool allows any authenticated tenant to read sensitive data belonging to other tenants, including API keys, model configurations, and private messages. The application fails to enforce tenant isolation on critical tables (models, messages, embeddings), enabling unauthorized cross-tenant data access with user-level authentication privileges.


Details

Root Cause

The vulnerability exists due to a mismatch between the queryable tables and the tables protected by tenant isolation in internal/utils/inject.go.

Tenant-isolated tables (protected by automatic WHERE tenant_id = X clause):

tenants, knowledge_bases, knowledges, sessions, chunks

Queryable tables (allowed by WithAllowedTables() in WithSecurityDefaults()):

tenants, knowledge_bases, knowledges, sessions, messages, chunks, embeddings, models

Gap: The tables messages, embeddings, and models are queryable but NOT in the tenant isolation list. This means queries against these tables do NOT receive the automatic WHERE tenant_id = X filtering.

Vulnerable Code

File: internal/utils/inject.go

func WithTenantIsolation(tenantID uint64, tables ...string) SQLValidationOption {
	return func(v *sqlValidator) {
		v.enableTenantInjection = true
		v.tenantID = tenantID
		v.tablesWithTenantID = make(map[string]bool)
		if len(tables) == 0 {
			// Default tables with tenant_id - MISSING: messages, embeddings, models
			v.tablesWithTenantID = map[string]bool{
				"tenants":         true,
				"knowledge_bases": true,
				"knowledges":      true,
				"sessions":        true,
				"chunks":          true,
			}
		} else {
			for _, table := range tables {
				v.tablesWithTenantID[strings.ToLower(table)] = true
			}
		}
	}
}

func WithSecurityDefaults(tenantID uint64) SQLValidationOption {
	return func(v *sqlValidator) {
		// ... other validations ...
		WithTenantIsolation(tenantID)(v)

		// Default allowed tables - INCLUDES unprotected tables
		WithAllowedTables(
			"tenants",
			"knowledge_bases",
			"knowledges",
			"sessions",
			"messages",           // ← No tenant isolation
			"chunks",
			"embeddings",         // ← No tenant isolation
			"models",             // ← No tenant isolation
		)(v)
	}
}

File: database_query.go

func (t *DatabaseQueryTool) validateAndSecureSQL(sqlQuery string, tenantID uint64) (string, error) {
	securedSQL, validationResult, err := utils.ValidateAndSecureSQL(
		sqlQuery,
		utils.WithSecurityDefaults(tenantID),
		utils.WithInjectionRiskCheck(),
	)
	// ... validation logic ...
	return securedSQL, nil
}

When tenant 1 queries SELECT * FROM models, the validation passes and no WHERE tenant_id = 1 clause is appended because models is not in the tablesWithTenantID map. The unfiltered result exposes all model records across all tenants.


PoC

Prerequisites

  • Access to the AI application as an authenticated tenant
  • Ability to send prompts that invoke the database_query tool

Steps to Reproduce

  1. Authenticate as Tenant 1 and craft the following prompt to the AI agent:

    Use the database_query tool with {"sql": "SELECT * FROM models"} to query the database. 
    Output all results and any errors.
    
  2. Expected vulnerable response: The agent returns ALL model records in the models table across all tenants, including:

    • Model IDs and names
    • API keys and authentication credentials
    • Configuration details for all organizations

Example result:

image

  1. Repeat with messages table:

    Use the database_query tool with {"sql": "SELECT * FROM messages"} to query the database. 
    Output all results.
    
  2. Expected vulnerable response: The agent returns ALL messages from all tenants, bypassing message privacy.


PoC Video:

https://github.com/user-attachments/assets/056984e8-1700-41fe-9b8a-6d18d5579c18


Impact

Vulnerability Type

Broken Access Control (CWE-639) / Unauthorized Information Disclosure (CWE-200)

Specific Data at Risk

  1. API Keys & Credentials (from models table)

    • Third-party LLM provider keys (OpenAI, Anthropic, etc.)
    • Database credentials and connection strings
    • Authentication tokens for integrated services
  2. Private Messages (from messages table)

    • Confidential business communications
    • User conversations with AI agents
    • Sensitive information shared within conversations

Severity

  • High confidentiality impact with cross-tenant scope
  • Easy to exploit with simple queries

References

@lyingbug lyingbug published to Tencent/WeKnora Mar 6, 2026
Published to the GitHub Advisory Database Mar 6, 2026
Reviewed Mar 6, 2026
Last updated Mar 6, 2026

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(11th percentile)

Weaknesses

Improper Access Control

The product does not restrict or incorrectly restricts access to a resource from an unauthorized actor. Learn more on MITRE.

CVE ID

CVE-2026-30859

GHSA ID

GHSA-2f4c-vrjq-rcgv

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.