Skip to content

Do not write reserved names from Hyphen ENV to process.env - #7

Merged
jaredwray merged 2 commits into
mainfrom
cursor/env-load-reserved-names-37a7
Nov 18, 2026
Merged

jaredwray merged 2 commits into
mainfrom
cursor/env-load-reserved-names-37a7

Conversation

@jaredwray

Copy link
Copy Markdown
Contributor

Please check if the PR fulfills these requirements

  • Followed the Contributing guidelines and Code of Conduct
  • Tests for the changes have been added (for bug fixes/features) with 100% code coverage.

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

Bug fix in @hyphen/sdk.

Problem

Env.load wrote each remote name to process.env. The only check was for a NUL character. Some names control the Node.js runtime, OpenSSL, the dynamic loader, and the command shell. A person with write access to the ENV data could use these names to change the behavior of the application and of its child processes.

Change

Env.load does not write a reserved name to process.env. The comparison ignores the case of the name, because Windows ignores it.

These names are reserved:

  • NODE_OPTIONS, NODE_PATH, NODE_REPL_EXTERNAL_MODULE, and NODE_COMPILE_CACHE
  • NODE_EXTRA_CA_CERTS and NODE_TLS_REJECT_UNAUTHORIZED
  • OPENSSL_CONF, OPENSSL_ENGINES, OPENSSL_MODULES, SSL_CERT_DIR, and SSL_CERT_FILE
  • PATH, PATHEXT, COMSPEC, and BASH_ENV
  • Each name that starts with LD_ or DYLD_
  • HYPHEN_API_KEY

The service sends one warn event that lists the names that it did not write. The event does not contain the values. The returned object contains all the remote values, as before. A caller can read a reserved value from the returned object.

The README of the Node.js SDK describes the reserved names.

Decisions

  • The service does not throw an error for a reserved name. The hx CLI uses the same ENV data and sets the variables before the process starts. A name such as NODE_OPTIONS is correct there.
  • The list uses full names and not a NODE_ prefix. Applications use names such as NODE_ENV and NODE_CONFIG for their own settings.
  • ENV is not reserved. Only an interactive shell reads it, and an application can use this name.
  • The list contains only the names that Node.js, OpenSSL, the dynamic loader, and the command shell read. A different program can read a different name. The README tells the user about this limit.

Compatibility

An application that used load to set a reserved name must now set that name from the returned object.

Verification

  • pnpm build passed.
  • pnpm lint passed. Biome applied no fixes.
  • vitest run test/env-service.test.ts --coverage passed with 78 tests. The coverage of src/env-service.ts is 100% for statements, branches, functions, and lines.
  • A script loaded the built package with dummy data and no network. Before the fix, a remote NODE_OPTIONS value ran a preload file in a child process. After the fix, the preload file did not run, and NODE_ENV and DATABASE_URL were written.
  • pnpm test did not pass in the local environment. 52 tests of @hyphen/sdk and 5 tests of @hyphen/browser-sdk need the HYPHEN_* secrets, which the local environment does not have. The same tests fail on main. CI has the secrets.

Test audit gate

All tests are in packages/nodejs-sdk/test/env-service.test.ts. They use the public load method, the public warn event, and the public log property.

  • Kept: does not write the reserved name %s to process.env (21 rows). It protects the contract that load does not write a reserved name, with the default options and with override: false. Each row failed on the code before the fix, because process.env contained the remote value. No test examined a reserved name before.
  • Kept: reports each skipped name and no value. It protects the contract that the service reports the skipped names and does not put a value in the report. It failed on the code before the fix, because the service sent no warn event.
  • Kept: writes the name %s, which is not reserved (4 rows). It protects the names NODE_ENV, NODE_CONFIG, LDAP_URL, and PATHNAME. A change to a wider prefix rule makes it fail. It also fails if the service sends a warn event when it skipped no name. It is not a regression test for the defect, thus it passed before the fix.
  • No test was rewritten or deleted.
Open in Web Open in Cursor 

cursoragent and others added 2 commits November 17, 2026 23:38
`Env.load` wrote each remote name to `process.env`. Some names control
the Node.js runtime, OpenSSL, the dynamic loader, and the command shell.
A person with write access to the ENV data could use these names to
change the behavior of the application and of its child processes.

`Env.load` does not write these names now. It sends one `warn` event
that lists the names and not the values. The returned object contains
all the remote values, as before.

Co-authored-by: Jared Wray <me@jaredwray.com>
The ENV section lists the names that `Env.load` does not add to
`process.env`. It also tells the user about the `warn` event and the
limit of the list.

Co-authored-by: Jared Wray <me@jaredwray.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T23:40:43.487147Z a8bbcc7 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (90f4625) to head (a8bbcc7).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main        #7   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           14        14           
  Lines          824       837   +13     
  Branches       194       199    +5     
=========================================
+ Hits           824       837   +13     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jaredwray
jaredwray merged commit d52f44a into main Nov 18, 2026
10 checks passed
@jaredwray
jaredwray deleted the cursor/env-load-reserved-names-37a7 branch November 18, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants