spawn drops an own `__proto__` environment entry
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 72/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- nodejs, typescript
- Bereich
- operating-systems
Rechercherichtung
Beginne mit der assign-Hilfsfunktion in src/utils.ts, die options.env mit einfacher Eigenschaftszuweisung in das Ziel kopiert. Dadurch trifft ein eigener __proto__-Schlüssel auf den Prototyp-Setter. Verfolge, wie spawn diese env an _parseEnv weitergibt. Führe die Reproduktion aus dem Issue aus und prüfe, ob das Child-Prozess true:selected-value ausgibt. Fertig ist es, wenn ein __proto__-Eintrag die Kopie unverändert übersteht, etwa mit defineProperty oder einer gleichwertigen Methode, und die Reproduktion erfolgreich läuft.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Environment details
- OS: macOS (arm64)
- OS version: 26.5.2
- node-pty version: 1.1.0 (Node.js 26.3.0)
Issue description
spawn copies options.env with assign (src/utils.ts):
sources.forEach(source => Object.keys(source).forEach(key => target[key] = source[key]));
When the source object has an own __proto__ key (for example one that came from JSON.parse), target["__proto__"] = value invokes the Object.prototype.__proto__ setter instead of creating a property. A string value is ignored, so the variable never reaches _parseEnv and the child starts without it. child_process passes the same object through.
const pty = require("node-pty");
const env = { ...process.env, ...JSON.parse('{"__proto__":"selected-value"}') };
console.log(Object.hasOwn(env, "__proto__")); // true
const child = "console.log(Object.hasOwn(process.env, '__proto__') + ':' + process.env['__proto__'])";
pty.spawn(process.execPath, ["-e", child], { env }).onData((d) => process.stdout.write(d));
// prints: false:[object Object]
With child_process.execFileSync(process.execPath, ["-e", child], { env }) the child prints true:selected-value, and launching through /usr/bin/env __proto__=selected-value node -e ... under node-pty does too, so the operating system and Node accept the name.
Copying with Object.defineProperty(target, key, { value: source[key], enumerable: true, writable: true, configurable: true }), or building the key=value pairs from the source keys directly, keeps the entry.
A downstream process-capture tool hit this in morluto/rea#3338.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 2.1k
- Forks
- 349
- Ø Merge
- 1 T. 1 Std.
- Gemergte PRs (30 T.)
- 13
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus microsoft/node-pty
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
ConPTY/TSFN exit callback aborts the process during environment teardown — fixable with NODE_API_SWALLOW_UNTHROWABLE_EXCEPTIONS (same root cause as #904)Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
microsoft/node-pty#951 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in microsoft/node-pty
Ähnliche Issues
-
b:minor bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
software-mansion/argent#1698 ·
Maintainer antworten meist innerhalb von 1 Tag
-
e2e-failure ready-to-code
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
redhat-developer/rhdh-plugin-export-overlays#4624 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
better-auth/better-auth#12132 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
automation missing-model model-sync provider:tinfoil
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
anomalyco/models.dev#12053 ·
Maintainer antworten meist innerhalb von 1 Tag
-
o8 next debug build aborts on Glass to Dark appearance switch (nil identifier messaged before check)Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
hurttlocker/o8#5112 ·