CVE

CVE-2026-42227: n8n Public API Variables IDOR Allows Cross-Project Secret Disclosure

Gecko Security ResearchArtemiy Malyshau2 minute readMedium 5.9

An IDOR vulnerability in n8n's public variables API allows authenticated users to read project variables outside their authorized scope, exposing secrets across project boundaries.


Advisory


Description

An IDOR in the public variables API allows authenticated users to read project variables outside their authorized project scope.

The vulnerable handler (variables.handler.ts) directly queries VariablesRepository with a user-controlled projectId, instead of enforcing membership checks through VariablesService.

In enterprise/team setups with multiple projects, a regular member with variable:list scope can read variables from projects they do not belong to, including sensitive values.

This issue only affects licensed enterprise or team deployments with multiple projects and the variables feature enabled.

Source - Sink Analysis

The vulnerable code path is the public API list endpoint in packages/cli/src/public-api/v1/handlers/variables/variables.handler.ts:

typescript
const [variables, count] = await Container.get(VariablesRepository).findAndCount({
  skip: offset,
  take: limit,
  where: {
    project: projectId === 'null' ? IsNull() : { id: projectId },
    value: state === 'empty' ? '' : undefined,
  },
  relations: ['project'],
});

This path does not validate whether req.user has access to the requested project.

The internal enterprise controller uses the authorization-aware service path instead (variables.controller.ee.tsvariables.service.ee.ts), which filters by project membership (projectVariable:list scope).

The feature is license-gated via isLicensed('feat:variables'), so exploitability is limited to licensed editions.

The response model includes variable value (variable.yml), making this a confidentiality issue.

Proof of Concept

  1. Set up an enterprise/team n8n instance with at least two projects:

    • Project A (attacker is a member)
    • Project B (attacker is not a member)
    • Add one or more variables to Project B
  2. Create an API key for the attacker account with variable:list scope.

  3. Query variables for the unauthorized project:

bash
curl -X GET 'http://target:5678/api/v1/variables?projectId=PROJECT_B_ID' \
  -H 'X-N8N-API-KEY: ATTACKER_MEMBER_API_KEY'
  1. Observe that variables from Project B are returned even though the attacker is not a member.

  2. Optional: iterate project IDs to enumerate and exfiltrate variables across projects.

Impact

This is a cross-project authorization bypass in the public API that leaks secrets across project boundaries.

Any authenticated low-privilege member with variable:list scope can read unauthorized project variables, including API keys, tokens, internal endpoints, and environment secrets stored in variables.

Exploitability conditions:

  • Multi-project enterprise/team deployment
  • At least one project the attacker is not a member of
  • Valid API key with variable:list scope

If variables were misused to store sensitive information such as credentials or tokens, they should be rotated immediately.

n8n (verified in: 2.7.4 and 2.9.2) CWE-639: Authorization Bypass Through User-Controlled Key (IDOR)

Product

n8n

Vendor

n8n-io

Version

< 1.123.32, < 2.17.4, < 2.18.1

CVSS

5.9

Summarize with AI
ChatGPTPerplexityGeminiGrokClaude