Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

spawn drops an own `__proto__` environment entry

Offen Anfängerfreundlich
#993 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@nikolay-dementiev arbeitet bereits daran.

Seit 15.10.2026.

  • #994 von @nikolay-dementiev — offen

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

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

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microsoft/node-pty

Alle Issues in microsoft/node-pty

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.