WeKnora has Broken Access Control - Cross-Tenant Data Exposure
High7.5CVE-2026-30859 · Published Mar 6, 2026 · updated Mar 23, 2026
Affected versions
| Package | Affected | Fixed in |
|---|---|---|
| github.com/Tencent/WeKnora Go | < 0.2.12 | 0.2.12 |
Details and references
## 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`** ```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`** ```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: <img width="864" height="1150" alt="image" src="https://github.com/user-attachments/assets/01e3d0ba-0f2a-43ab-ab51-8778fb8a79b1" /> 3. **Repeat with messages table**: ``` Use the database_query tool with {"sql": "SELECT * FROM messages"} to query the database. Output all results. ``` 4. **Expected vulnerable response**: The agent returns ALL messages from all tenants, bypassing message privacy
- CVSS 3.1
- CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
- Severity from
- GitHub (reviewed advisory)
- Weakness
- CWE-284
- Also known as
- CVE-2026-30859, GO-2026-4637
More weknora advisories
All| Date | Advisory | Severity | Fixed in |
|---|---|---|---|
| Mar 5 | WeKnora is Vulnerable to SSRF via Redirection CVE-2026-30247Medium5.9fixed in 0.2.12 | Medium5.9 | 0.2.12 |
| Mar 6 | WeKnora Vulnerable to Broken Access Control in Tenant Management CVE-2026-30855Critical9.8fixed in 0.3.2 | Critical9.8 | 0.3.2 |
| Mar 6 | WeKnora Vulnerable to Tool Execution Hijacking via Ambigous Naming Convention In MCP client and Indirect Prompt Injection CVE-2026-30856Medium5.4fixed in 0.3.0 | Medium5.4 | 0.3.0 |
| Mar 6 | WeKnora has Unauthorized Cross‑Tenant Knowledge Base Cloning CVE-2026-30857Medium5.9fixed in 0.3.0 | Medium5.9 | 0.3.0 |
| Mar 6 | WeKnora has DNS Rebinding Vulnerability in web_fetch Tool that Allows SSRF to Internal Resources CVE-2026-30858High7.5fixed in 0.3.0 | High7.5 | 0.3.0 |
| Mar 6 | WeKnora Vulnerable to Remote Code Execution via SQL Injection Bypass in AI Database Query Tool CVE-2026-30860Critical10.0fixed in 0.2.12 | Critical10.0 | 0.2.12 |