Summary
SQLBot versions prior to 1.8.0 contain a Cross-Workspace Insecure Direct Object Reference (IDOR) issue in the /api/v1/datasource/exportDsSchema and /api/v1/datasource/uploadDsSchema endpoints.
Under certain conditions, an attacker can access or modify database schemas and data sources belonging to other tenants or workspaces, effectively bypassing tenant isolation and authorization boundaries.
Affected context
This vulnerability arises in multi-tenant SQLBot deployments using the affected REST endpoints:
- /api/v1/datasource/exportDsSchema
- /api/v1/datasource/uploadDsSchema
The issue is most relevant where:
- Multiple tenants or workspaces share the same SQLBot instance
- Tenant isolation relies on server-side access control checks rather than physically separate infrastructure
- Clients can supply identifiers (e.g., datasource IDs, workspace IDs, schema handles) to reference resources
In such environments, missing or insufficient checks to ensure that a requested data source or schema belongs to the caller's workspace can expose other tenants' resources.
Exploit preconditions
- Attack surface: HTTP API endpoints /api/v1/datasource/exportDsSchema and /api/v1/datasource/uploadDsSchema.
- Required access: Ability to authenticate or otherwise reach these endpoints with any valid account or session in the shared SQLBot deployment.
- Trigger point: Supplying identifiers for data sources or schemas that belong to a different tenant/workspace than the attacker's own.
- Why exploitation is possible: The backend logic associates operations with resources using client-supplied identifiers but does not consistently verify that the resource is owned by or linked to the caller's workspace, resulting in an IDOR-style authorization bypass.
Why this happens
The underlying bug fits the pattern described by CWE-639: Authorization Bypass Through User-Controlled Key.
The API trusts client-supplied identifiers (such as data source or workspace IDs) to select backend resources, but it does not reliably enforce that those resources belong to the authenticated principal's tenant or workspace.
Without a strict ownership or tenancy check on every request, users can manipulate identifiers to point to objects outside their scope, breaking isolation between workspaces.
This represents a broader class of insecure object reference and multi-tenant authorization design flaws, where access control decisions are either missing or performed only partially.
Potential impact
- Exposure of database schema information belonging to other tenants or workspaces.
- Unauthorized modification or replacement of data source configurations across tenants.
- Indirect access to underlying databases if altered schemas or data sources are used by SQLBot for queries.
- Disruption of other tenants' operations by corrupting or misconfiguring their data sources.
- Facilitation of further attacks, such as data exfiltration or integrity violations, if compromised schemas are used in Text-to-SQL workflows.
General mitigation guidance
Effective mitigation centers on tightening object-level authorization and enforcing tenant isolation consistently.
Common defensive patterns include:
- Implementing strict ownership checks for every operation that references a data source, schema, or workspace by ID, ensuring it belongs to the caller's tenant or workspace.
- Deriving workspace or tenant context from the authenticated session or token, not from client-controllable parameters, and using that context when querying backend resources.
- Applying a consistent access control layer that mediates all CRUD operations on multi-tenant resources rather than ad hoc checks in individual handlers.
- Minimizing the use of raw identifiers in APIs where possible or using opaque, tenant-scoped identifiers that cannot be meaningfully reused across workspaces.
- Adopting least-privilege principles so that accounts and tokens only have the minimum necessary permissions for their own workspace.
These patterns reduce the chances that a crafted identifier alone can bypass access control boundaries.
How teams detect issues like this
Detecting similar issues often involves both code-focused and behavior-focused techniques:
- Static analysis and code review:
- Look for controller or handler logic where user-supplied IDs (e.g., datasourceId, workspaceId) drive database lookups without a subsequent ownership or tenancy check.
- Flag any queries that select resources by ID alone, rather than by (tenantId, resourceId) pairs or equivalent scoped constraints.
- Review middleware and access control layers to ensure they are invoked for the relevant endpoints and enforce per-tenant scoping.
- Automated policy checks:
- Introduce architectural linting rules that require all multi-tenant resources to be accessed via tenant-scoped queries.
- Enforce coding patterns in CI/CD (e.g., require use of a specific repository method that automatically scopes by workspace).
- Runtime monitoring and testing:
- Add multi-tenant security tests that attempt cross-workspace access using altered IDs.
- Monitor logs for unusual access patterns, such as a single account touching resources associated with many different tenants or workspaces.
When combined, these approaches can highlight authorization gaps before they reach production or quickly surface abnormal cross-tenant access patterns in live systems.

