Any workflow user can exfiltrate OS environment variables via Send Email node

Hi n8n team,
I would like to report a security issue related to environment variables being accessible from workflows.
Any user who can create a workflow can exfiltrate OS environment variables by using the Send Email node. For example, as shown in the attached screenshot, using the following expression in the email body:
{{ $env.DB_POSTGRESDB_PASSWORD }}
will send out the actual database password via email.
Steps to reproduce:

  1. Log into n8n with a regular user account (non-admin is enough).
  2. Create a new workflow.
  3. Add a “Send Email” node.
  4. In the HTML or text body field, enable expressions and insert: {{ $env.DB_POSTGRESDB_PASSWORD }}
  5. Execute the workflow.
  6. Check the received email – it contains the real value of the environment variable.
Actual behavior:
	Any user who can create workflows can read and send out sensitive OS-level environment variables (such as database passwords) via email or other nodes.
	This effectively allows users to exfiltrate credentials and other secrets from the host system.
Expected behavior:
	Regular users should not be able to directly read OS environment variables, especially sensitive ones like passwords, API keys, tokens, etc.
	Ideally, n8n should:
		Allow admins to disable or restrict access to $env.* in workflows, or
		Limit $env access to admins / privileged roles only, or
		Provide a whitelist of environment variables that can be accessed from workflows.
Impact:
	Any compromised or malicious user account with workflow-creation permissions can very easily leak all environment variables (including database credentials and other secrets) by sending them via email or other integrations.
	This is a serious security risk for production deployments.
Please let me know if you need more details, logs, or a minimal workflow example to reproduce this issue.
Thank you.

Hey @sun873087 hope all is good.

Feel free to set the N8N_BLOCK_ENV_ACCESS_IN_NODE variable to true to prevent this from happening.

More here:

3 Likes

Thank you for your assistance. Your response has successfully resolved my issue.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.