Repository navigation
fix(io): get_env rejects a name with an embedded NUL - #1450
Merged
Merged
Conversation
Node's environment proxy truncates a key at an embedded NUL, so
IO.get_env("HOME\0suffix") answered Done with HOME's value on the
Node lane while the C and Bun lanes failed ENOENT. get_env.c already
rejects such names with io_nul before asking the host; do the same in
get_env.js so every lane agrees.
Adds tests/io/get_env_nul.bend, which pins the failure on all lanes.
Co-authored-by: Claude Opus 4.5 <[email protected]>
This was referenced Oct 9, 2026
This was referenced Oct 10, 2026
Lorenzobattistela
approved these changes
Oct 10, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #1449.
IO.get_envon the emitted Node lane treated an embedded NUL as the end of an environment-variable name.get_env.calready rejects such a name withio_nulbefore asking the host environment, so the C and Bun lanes answerFail(ENOENT). Node's environment proxy instead truncates the key, so"HOME\0suffix"answeredDonewithHOME's value: the call read a variable the caller never named, on one lane only.Confirmed here against
mainat8578b7c, with the reproducer from the issue and the lanes run on Node and Bun:HOMEHOME\0suffix(before)HOME\0suffix(after)DoneDoneFail(ENOENT)DoneFail(ENOENT)Fail(ENOENT)Change
bend2/effs/get_env.js: reject a name containing\0with the sameio_fail(2)the unset path already returns, before askingprocess.env. This matchesget_env.c'sio_nul(name, n) ? NULL : getenv(name)guard, so the lanes agree.tests/io/get_env_nul.bend: a newiotest pinningHOME=setandnul=unset.Valid names, host FFI support, own-property semantics and the error-code policy are unchanged: the guard only fires on a name no lane can look up.
Verification
Reproduced the bug and confirmed the fix on this host, emitting the standalone JS program (
-o out.js, which carries the shared runtime and the registered effects) and running it under both runtimes, plus the native Bun lane:The unpatched build of the new test emits
nul=setunder Node and the patched build emitsnul=unset, so the test does discriminate the bug rather than passing vacuously. The siblingtests/io/get_env.bendandtests/io/get_env_own.bendstill pass on the JS lane. Also ran:bun run gates/repo.ts—PASS: 54 / 54(both paths match the allow list:bend2/effs/[a-z0-9_]+\.(c|js)andtests/[a-z]+/[A-Za-z0-9_]+\.bend).bend tests/io/get_env_nul.bend --check-only—ALL PROOFS CHECK.bend tests/io/get_env_nul.bend --verdict—ALL PROOFS CHECKunder the proven kernel.The C lane is unchanged by this PR (
get_env.calready had the guard) and is the first place the full three-lane gate will run this test, alongside Bun.