Summary
A cross-workspace insecure direct object reference in Twenty's AI agent monitor allows authenticated users to access or act on agent turns belonging to other workspaces.
When an attacker knows another workspace's agentId or turnId, they can retrieve sensitive chat histories and submit evaluations against those foreign turns, bypassing workspace isolation.
Affected context
This vulnerability occurs in Twenty instances that use the AI agent monitor features and share infrastructure across multiple workspaces (tenants).
It is relevant when:
- The AgentTurnResolver and related services query agent turns using only agentId or turnId
- Workspace-level isolation is expected but not enforced in the data access layer
- Users can see non-guessable identifiers (UUIDs) for agents and turns in URLs or UI elements
Exploit preconditions
- Attack surface: HTTP API endpoints backing the AI agent monitor (e.g., agentTurns(agentId) query and evaluateAgentTurn(turnId) mutation).
- Required access: Authenticated user with the AI settings capability in any workspace on the affected instance.
- Trigger point: Calling the resolver or service methods with an agentId or turnId that belongs to a different workspace.
- Why exploitation is possible: The data access logic filters by agentId or id only and omits workspaceId in the WHERE clause. Class-level guards confirm the caller is authenticated in some workspace but do not verify that the targeted AgentTurnEntity belongs to that workspace, allowing cross-workspace access when identifiers are known.
Why this happens
The underlying bug is a classic insecure direct object reference mapped to CWE-639, where authorization is performed on the user or session but not on the specific object being accessed.
The AgentTurnResolver and agent-turn-grader service retrieve and manipulate AgentTurnEntity records using only agentId or turnId, even though those records are also scoped by workspaceId.
Because the workspaceId column is not included in the query filters and the guards only ensure that a user is logged into some workspace, the code assumes that possession of a valid identifier implies authorization, breaking tenant isolation and enabling cross-workspace data access and actions.
Potential impact
- Authenticated users may access full AI agent chat histories in other workspaces, including raw chat text, tool calls, and tool outputs.
- Attackers could submit evaluations (agentTurnEvaluation rows) tied to a victim's workspace, potentially polluting analytics or feedback signals.
- Sensitive business or customer information processed by AI agents could be exposed across tenants.
- Misattributed AI evaluation data can distort model performance metrics or monitoring dashboards.
General mitigation guidance
Effective mitigation focuses on enforcing object-level authorization and tenant scoping across all data access paths.
Common patterns include:
- Ensuring every query and mutation involving tenant-scoped entities includes workspaceId (or equivalent tenant key) in the WHERE clause derived from the caller's current context.
- Centralizing authorization checks so that services validate that an object belongs to the caller's workspace before returning or mutating it.
- Avoiding reliance on opaque identifiers (like UUIDs) as proof of authorization, treating them strictly as locators not access tokens.
- Designing APIs so that identifiers exposed in URLs or front-end configurations cannot cross tenant boundaries without additional verification.
- Applying least privilege principles to feature flags and role assignments, limiting cross-workspace features to clearly separated admin surfaces.
How teams detect issues like this
Detection typically involves a combination of code-level and behavioral analysis:
- Static analysis or manual code review to identify ORM or query builder usage that filters by primary key or foreign key without also filtering by tenant/workspace fields.
- Review of resolver and service layers to confirm that authorization logic checks record ownership (e.g., workspaceId) rather than just authentication status or feature flags.
- Application-level tests that attempt to access data across workspaces using valid identifiers from another tenant to validate isolation boundaries.
- Logging and monitoring for unusual patterns where users in one workspace repeatedly access agentIds or turnIds from different workspaces, indicating potential abuse.

