Summary
n8n's task runner used Buffer.allocUnsafe() and Buffer.allocUnsafeSlow() to allocate memory for untrusted code, potentially returning uninitialized buffers containing residual data from the same Node.js process.
When a workflow or task could influence or read these buffers, it might access sensitive information from prior requests or tasks, including secrets and tokens, leading to information disclosure.
Affected context
This vulnerability affects n8n deployments running versions 1.65.0 through 1.114.2 where:
- The task runner executes user-controlled or workspace-controlled workflow logic.
- Buffer allocation within the task runner relies on
Buffer.allocUnsafe()orBuffer.allocUnsafeSlow(). - Workflows, integrations, or custom code can read data from these buffers.
In such environments, different workflows or tasks may share the same Node.js process, enabling accidental leakage of residual in-process data between tasks.
Exploit preconditions
- Attack surface: Workflow tasks and custom code executed by the n8n task runner.
- Required access: Ability to create or run workflows or nodes that can interact with buffers allocated by the task runner (for example, tenant or project-level access to define automation logic).
- Trigger point: Execution of a workflow or task that causes buffer allocation through
Buffer.allocUnsafe()orBuffer.allocUnsafeSlow(), followed by reading from the buffer without fully initializing it. - Why exploitation is possible: Unsafe buffer allocation returns memory that may contain residual contents from previous operations in the same process. When untrusted workflow logic can inspect these buffers, it can infer or directly read data that was not intended to be exposed.
Why this happens
The underlying flaw arises from using Node.js APIs that intentionally skip memory initialization (Buffer.allocUnsafe() and Buffer.allocUnsafeSlow()) in contexts where buffer contents may be observable by untrusted or semi-trusted code.
These APIs can return memory segments containing remnants of prior operations within the same process, such as request payloads, access tokens, credentials, or intermediate workflow data. When such buffers are exposed to workflow logic without being overwritten first, this constitutes an information exposure through residual data condition, aligning primarily with CWE-200 (Exposure of Sensitive Information to an Unauthorized Actor) and related to CWE-668 (Exposure of Resource to Wrong Sphere), as internal process memory is made visible to a less-privileged execution sphere.
Potential impact
- Disclosure of secrets or tokens previously processed by other workflows or tasks.
- Exposure of sensitive business data, such as customer records, internal identifiers, or confidential payloads.
- Leakage of authentication or session data that could facilitate further compromise in connected systems.
- Cross-workflow or cross-tenant data exposure in multi-user or multi-tenant n8n deployments.
- Increased difficulty in achieving data minimization and regulatory compliance due to uncontrolled in-process data leakage.
General mitigation guidance
Effective mitigation focuses on treating all memory that may be observed by untrusted workflow logic as sensitive and ensuring it is fully initialized before use.
Recommended defensive patterns include:
- Prefer using safe allocation APIs (e.g.,
Buffer.alloc()in Node.js) for any buffer that can be read from or manipulated by workflow or plugin code. - Enforce a policy that no uninitialized memory is ever exposed to user-defined or tenant-defined logic, even if only indirectly.
- Introduce abstraction layers for buffer handling in the task runner so that low-level memory APIs are not called directly from workflow-related paths.
- Apply least-privilege principles to workflow execution: restrict what internal data and resources are accessible to tasks, assuming that any accessible buffer contents might be inspected.
- Implement secure coding guidelines for extensions and custom nodes, discouraging unsafe memory operations and requiring explicit initialization of all buffers.
How teams detect issues like this
Security teams can pursue several detection approaches to surface similar issues:
- Static analysis: Configure linters or SAST tools to flag usage of
Buffer.allocUnsafe()andBuffer.allocUnsafeSlow()in code paths reachable by untrusted or user-defined workflows. Enforce policies that require justification or remediation for such calls. - Code review patterns: During code review, treat any use of unsafe buffer allocation APIs as a security smell. Reviewers should verify that buffers are either fully overwritten before exposure or replaced with safe allocation functions.
- Centralized API enforcement: Wrap buffer allocation in internal utility functions and prohibit direct use of low-level allocation APIs. Automated checks can then focus on the wrapper usage.
- Runtime monitoring (where feasible): In high-assurance environments, instrument critical paths to log or trace unsafe memory API usage and correlate it with workflow execution contexts.
- Policy and CI integration: Integrate checks into CI pipelines that reject changes introducing new unsafe allocation patterns in workflow-related modules.

