nish:secret: the checker rules that keep a key in its Secret
The record for the nish:secret checker rules. It says what was checked, how,
what was found, and which test pins each answer. The file:line anchors in
Where (base) are at main b515c1b; the fix names functions rather than
lines, because it moves every line below them.
Scope
| File | What |
|---|---|
src/secret.ts |
SecretFlow (the ownership walk: move, name, collectFlow), checkSecretFlow, and the sole-reference rule this record adds: ReferenceScan, FreshJudge, checkSoleReferences, FreshResults |
src/compilation.ts |
Compilation.checkSecrets, which asks the whole-program questions |
src/program.ts |
SecretNeed and CheckedProgram.secretNeeds, the questions a body leaves for it |
Read here, audited for this rule by the field section below: src/attributes.ts
(PointerParamFacts.captured, the fact the sole-reference rule reads for "keeps
its parameter"; its markWipe is in the field section's Scope).
Threat model
nish:secret is a promise the compiler makes to the program's own author:
key material held in a Secret<T> leaves only through expose, and after
wipe nothing reads it. The rules run at compile time, so no input the program
reads can reach them; what they defend against is a program that, by mistake,
keeps a second road to the bytes. A rule the checker states and does not hold
is the failure: the program compiles, and its key is readable where the
language says it is not.
Method
-
Read
SecretFlow.moveand every place a local can be named in a body, and listed each way a second name for an array or record can be made beforesecret(x)movesx: aconstorlet, a field, an element, a callee's parameter, a callee's return value, a ternary or a??, aResultbuilt byOkorErrand read back throughorReturn,expectorunwrapOr, a constructor's argument or itsthis, a method'sthis, afor...ofbinding, a later declarator of the same statement, an assignment used as a value, an arrow's capture, and a task's argument (s.spawn(entry, raw, …)). The compound assignments (+=,??=,||=) take no array, so they are no road. -
Wrote a program for each one that reads the alias after
wipe, and ran it againstmain's compiler.
Findings
| Id | Severity | Where (base) | Description | Disposition |
|---|---|---|---|---|
| SECRET-1 | Medium | src/secret.ts:1078 (SecretFlow.move), src/secret.ts:1221 (checkSecretFlow) |
secret(x) marked the one local x moved, and NL2445 refused a later read of x, but nothing asked whether the value had another name. const alias = raw; const key = secret(raw); wipe(key); alias[0] compiled and read 0, and before the wipe the same name read the key with none of the Secret's rules. Every road listed under Method compiled: let, a field (h.buf = raw, { buf: raw }), an element ([raw], xs[0] = raw, xs.push(raw)), a callee that stores or returns its parameter, secret(id(raw)) with raw read after, a ternary (c ? raw : other as a value, and as the argument of secret, which moved neither arm), maybe ?? raw, Ok(raw) and Err(raw) (the Result holds raw as its payload or its error), a constructor that keeps its argument or hands this out, a method that keeps this or answers a field, rows.pop(), a let given another local's array, a for...of binding, a later declarator (const n = 1, alias = raw), an assignment to the local used as a value (alias = raw = [1, 2, 3], const alias = (raw = [...]), xs.push(raw = [...]), h.k = (raw = [...]), keep(h, raw = [...]), found in review round 3), and, once #609 let an arrow given to parallelMap, parallelFrom, parallelMapInto or parallelReduce read the function's const locals, a capture of raw by such an arrow, and, once #644 let a task spawned as an arrow capture them too, a capture by a task, and a task's argument, which the scope keeps until the task has run (s.spawn(first, raw, out, 0), s.spawn(sum, raw)). The ternary also let a parameter past NL2447: secret(c ? p : [1]). Medium: no input reaches the rule, so not High, but a program it accepts reads its key outside expose without a word, which is more than hardening |
Fixed. secret(v) takes only a value nothing else holds (docs/LANGUAGE.md, "Secrets"; NL2512). checkSoleReferences judges each argument over the body it is in (FreshJudge): a literal, null and a new are fresh, a ternary when both arms are, a call when its callee's answer is, and a local when it is no parameter, every value it is given is fresh and not another local, it is no for...of binding, and ReferenceScan finds no other occurrence that leaves a second name (one inside an arrow, resolved through sourceLocal to the local it captures, always does). What only the whole program knows is left as a SecretNeed, which Compilation.checkSecrets answers with FreshResults: a callee's answer, judged over its own body by the same rule as a greatest fixpoint over the calls between them, and whether a callee keeps a parameter, which PointerParamFacts.captured says. An assignment to the local is harmless only where its own value is dropped, by a statement or a for header (ReferenceScan.harmlessAt); anywhere else its value is judged as the local is. ReferenceScan.handsOn follows a value through every wrapper that answers it: parentheses, a ternary arm, ??, Ok and Err, and orReturn, expect and unwrapOr, so const r = Ok(raw) leaves a second name while a callee's return Ok(out) is its result. A Result method that answers the payload is judged by what the Result carries, so make().orReturn() is fresh when make returns Ok of a fresh array. At a secret(...) a local carried there (r.unwrapOr(d)) is refused, because the move does not reach it. SecretFlow.move moves the local in either arm of a ternary, so neither is read again, and refuses a parameter there. The secret golden positives and every std/ caller compile unchanged (see Tests) |
| SECRET-6 | Low | runtime/core/result.mjs (wipe, secureZero), the --emit-ts output |
A program written out with --emit-ts and run under Node keeps the nish:secret API, but its wipe is a loop of plain stores into a JavaScript array. Nothing stops the engine from having copied the bytes first (a collector that moved the array, a string or a typed array the value passed through, a JIT spill), and JavaScript has no way to reach those copies, so erasure is not guaranteed: the bytes the program still holds read 0, and nothing more is promised. The native build's volatile llvm.memset that opt -O2 keeps is the guarantee, and it has no TypeScript equivalent |
Open, recorded. No fix exists inside a JavaScript engine. A key that must be erased is held by the native build; the emitted TypeScript is for reading, diffing and running a program, not for holding a secret (docs/guide/using-nish/to-typescript.md) |
Properties verified
- Each road above is refused, with the reference named and its line, or the callee and the parameter that keeps it.
-
The copy the diagnostic suggests compiles:
const copy: u8[] = new Array<u8>(raw.length); copy.set(raw)andsecret(copy)(docs/guide/using-nish/standard-library.md). - A recursive function that only ever answers a literal is fresh, and one that answers its parameter through another function is not.
-
A
ResultwhoseOkpayload is fresh gives a fresh value throughorReturnandexpect. -
The rule refuses more than it must in three places, each a compile error
rather than a missed read, and each pinned: a data-parallel arrow that reads
the local before the move, where the read ends with the call
(
reject_secret_alias_capture_*), and an arrow given to an ordinary function parameter the same way (reject_secret_alias_capture_call); aResultlocal copied into another,const alias = r(reject_secret_alias_result_copy); and aletgiven another local after the move,raw = other(reject_secret_alias_reassigned_after). Aletgiven a fresh value after the move is accepted. -
The rule is what refuses each case: the same
src/with it taken out compiles every one of them.
Tests
The checks in tests/run.js that hold the above:
-
${name}: rejected with ${needles.map((n) =>"${n}").join(", ")}, forreject_secret_alias_const,reject_secret_alias_let,reject_secret_alias_reassigned,reject_secret_alias_assign_chain,reject_secret_alias_assign_init,reject_secret_alias_assign_push,reject_secret_alias_assign_field,reject_secret_alias_assign_kept,reject_secret_alias_assign_helper,reject_secret_alias_assign_parents,reject_secret_alias_assign_constructor,reject_secret_alias_assign_source,reject_secret_alias_declarators,reject_secret_alias_declarator_moved,reject_secret_alias_field,reject_secret_alias_element,reject_secret_alias_param,reject_secret_alias_return,reject_secret_alias_mutual,reject_secret_alias_ternary,reject_secret_alias_nullish,reject_secret_alias_ok,reject_secret_alias_err,reject_secret_alias_unwrap_or,reject_secret_alias_unwrap_helper,reject_secret_alias_unwrap_local,reject_secret_alias_result_copy,reject_secret_alias_reassigned_after,reject_secret_alias_constructor,reject_secret_alias_receiver,reject_secret_alias_pop,reject_secret_alias_for_of,reject_secret_alias_capture_map,reject_secret_alias_capture_from,reject_secret_alias_capture_map_into,reject_secret_alias_capture_reduce,reject_secret_alias_capture_spawn,reject_secret_alias_capture_call,reject_secret_alias_spawn_argandreject_secret_alias_spawn_with: one road each. -
nish:secret: reverting the sole-reference rule lets every reject_secret_alias_* case compile (${aliasCases.length} cases): a copy ofsrc/without the rule, built by the seed, compiles all of them butreject_secret_alias_declarator_moved, which the move refuses itself (NL2445). -
nish:secret: secret(v) still takes ${what}, for a recursive function that answers only a literal, a fresh payload throughOk,orReturnandexpect, and the copy the diagnostic suggests. -
nish:secret: every std/ caller of secret(v) compiles (${callers.length} modules):std/net/tls.ts,std/crypto/x509-random.ts,std/crypto/hkdf.ts,std/crypto/x25519.tsandstd/crypto/x509.ts. -
${name}: IR matches goldenand${name}: native output matches .out, forsecret_flow,secret_wipe,secret_wipe_o2,secret_wipe_o2_plain,secret_inferred,secret_wipe_o2_inferredandsecret_wipe_o2_inferred_plain: the positives, the last three binding theSecretunannotated (#613). -
${rel}:${s.line} is rejected with ${s.code}and${rel}:${s.line} compiles, fordocs/guide/using-nish/standard-library.md: the alias refused with NL2512, and the copy accepted.
The field rule: a Secret held by a class
NL2430 refused every Secret field. The field rule (#668) admits one shape,
and this part of the record says what that shape is held to and how. Its rows
name functions rather than lines: the rule is new code on main 461489b, so
no base line describes it.
Scope
| File | What |
|---|---|
src/secret.ts |
admitsSecretField and secretFieldOf (the declaration), checkHolderReleaser (the releaser's signature), SecretFlow.collectSlots, fieldRead, fieldStore and storedType (the walk over a holder's constructor, its wipe() and every other body) |
src/structs.ts |
where a field's type is admitted, and where checkHolderReleaser runs once a class's members are known |
src/members.ts |
the object literal of a holder (NL2545) |
src/interop-header.ts |
structDefinitions and structFieldTypes: a Secret (isSecretStruct) and a holder (secretFieldOf) are opaque in an --emit-header sidecar |
src/attributes.ts |
markWipe: a wipe marks what its argument reaches as written, for the region rule of a scope |
src/codes.ts |
the field rule's diagnostics, NL2540 to NL2548, with their fragments and advice |
src/types.ts |
TypeTable.holdsSecret, which does not look inside a struct: a holder travels as a value, since its own wipe() ends its field |
Threat model
As above: the rule is a promise to the program's author, and the failure is a program that compiles while the key stays readable, or unwiped, where the language says it is not. A field adds two roads a local does not have: the holder outlives the function that made the key, and every method of the class can name the field.
Method
-
Listed each way in: a field declared on an interface, on a generic class, without
readonly, asSecret<T> | null, inside an array, aResultor anotherSecret; a releaser missing, with a parameter or with another return type; awipe()that skips the field on one branch, in a loop, after an earlyreturn, or by calling a helper; a constructor that sets the field from a local, a parameter or a call, from an aliased array, twice, or in a loop; a store from a method, from outside the class, by a compound assignment, or throughthishanded out of the constructor; a read into a local, alet, a return value, a ternary, a??, an optional chain, a chained member, an index, a template,console.log, a condition andsecret(h.k); the holder as an object literal, a JSON encode or decode target, a data-parallel capture, a task's argument wiped in its scope, and ausingbinding.Review round 1 added: a function, an arrow or a generic
id<T>that returns theSecretit borrows;wipe(h.k)in a function, another method, a constructor, or throughthishanded out of one; a helper that wipes itsSecretparameter; a constructor reached bynewthat zeroes the key in place insidewipe(); a field read through a nested member,o.h.k; and the header, typings and N-API shim of an exported function that takes or returns a holder.Review round 2 added: a method that returns the
Secretit borrows; a ternary that picks between two borrowed keys; a helper that wipes its parameter, reached bynewand by a method call; a holder'swipe()that wipes a nested holder's field,wipe(this.h.k), or another holder's,wipe(o.k); the C layout of an exported holder; and an exported function that returns a bareSecret. -
Wrote a program for each and compiled it with the branch's
build/nish.
Findings
Found by review rounds 1 and 2 of #685, on the branch before it landed, so each row names functions rather than base lines.
| Id | Severity | Where | Description | Disposition |
|---|---|---|---|---|
| SECRET-2 | Medium | SecretFlow.name (src/secret.ts) |
Identity laundering: a function, an arrow, a generic id<T> or a method that returned the Secret it was passed handed its caller a second name for a holder's key, which outlived the holder's wipe() and read zeros, or read the key before it with no tie to the holder. A ternary between two borrowed keys was the same road. Medium on SECRET-1's reasoning: no input reaches it, but an accepted program holds the key under a name the rule does not see |
Fixed. A Secret parameter is borrowed: returning it is NL2546, for every Secret parameter (a break from 0.18.0, docs/LANGUAGE.md, "Secrets"). A ternary of two is refused by the copy rule |
| SECRET-3 | Low | SecretFlow.fieldRead (src/secret.ts) |
Wipe then read: wipe(h.k) in a function, another method, a constructor, through this handed out of one, or in a holder's wipe() aimed at a nested or another holder's field, zeroed a key its holder went on using. A wrong answer, not a leak |
Fixed. A field is wiped only by wipe(this.f) in its own holder's wipe() (NL2547) |
| SECRET-4 | Low | SecretFlow.name (src/secret.ts) |
A helper that wiped its Secret parameter, called directly, by new or by a method, zeroed a holder's key behind its back |
Fixed. Wiping a borrowed Secret is NL2548; the owner wipes it |
| SECRET-5 | Low | structDefinitions, structFieldTypes (src/interop-header.ts) |
The --emit-header sidecar gave a Secret's struct and an exported holder's layout, so a host could read the key's bytes by offset, or allocate a holder and skip the constructor that sets its key |
Fixed. A Secret (isSecretStruct) and a holder (secretFieldOf) are opaque: a typedef with no fields, reached only as a pointer, and a function that takes or returns one is not bridged to JS |
Properties verified
-
A
Secretfield isreadonly, typed exactlySecret<T>, on a non-generic class; any other declaration is NL2430, and aSecretinside an array, aResultor anotherSecretis NL2429. -
A class with such a field has
wipe(): voidwith no parameters (NL2540), and that method callswipe(this.f)for every field on every path out of it (NL2541): a branch, a loop body, an earlyreturnand a helper that wipes it are each refused. A field is wiped only there:wipe(h.f)anywhere else, a constructor included, is NL2547 (SecretFlow.fieldRead,src/secret.ts). -
A
Secretparameter is borrowed: returning it is NL2546 and wiping it NL2548 (SecretFlow.name), so no function, arrow or generic instantiation hands a caller a second name for a holder's key. -
The C header keeps a
Secretopaque, as it does aMap(isSecretStruct,src/interop-header.ts): an exported function'sSecretparameter or return is a pointer to an incomplete struct with no layout. A holder is opaque too (secretFieldOf): atypedefwith no fields, so a host cannot allocate one and skip the constructor that sets the key. The.d.tsand N-API shim bridge no such function. -
The field is set only in the constructor, only from
secret(...)(NL2542), and only once (NL2543);secret(...)there keeps the sole-reference rule (NL2512). A store anywhere else is NL2181, and the store is a statement of its own: its value bound to a local is NL2544. -
A scope's parent may not wipe a holder while a task of the scope may read
its key:
wipemarks what its argument reaches as written (markWipe,src/attributes.ts), soh.wipe(), a helper that wipesh.k, and a constructor reached bynewthat does are each the region rule's write before the join, aswipe(h.k)written in the block is. -
A read of the field is a loan: an argument of a call or of
new, or an operand of===or!==. Anything else is NL2544, and the existing rules (NL2428, NL2431 to NL2436, NL2439) still refuse what they refused of a local. - A holder made by an object literal is NL2545, and JSON encode and decode of one are NL2485.
-
The
wipe()of a holder is the same volatilellvm.memseta local's is, and it survivesopt -O2where a plainfill(0)of the twin's field is an ordinary one (on the arena,optkeeps both; the check pins the volatile flag). -
What the rule leaves out: nothing makes a program call
wipe(), so a holder that is never wiped leaves its key in memory, unzeroed; the rule does not follow a second reference to the holder itself, which is a loan of the whole object rather than of the key; a function that takes aSecretmay still zero its bytes throughexposeWithandfill(0), which is a write through a borrow like any other and leaves the holder reading zeros, a wrong answer and not a leak; and a key made per packet or per record is a local, held to NL2448 and NL2450, not a field.
Tests
-
${name}: rejected with ${needles.map((n) =>"${n}").join(", ")}, forreject_secret_field,reject_secret_field_interface,reject_secret_field_generic_class,reject_secret_field_not_readonly,reject_secret_field_nullable,reject_secret_field_array,reject_secret_field_array_literal,reject_secret_field_result,reject_secret_field_holder_payload,reject_secret_field_no_wipe,reject_secret_field_wipe_signature,reject_secret_field_wipe_missing,reject_secret_field_wipe_branch,reject_secret_field_wipe_loop,reject_secret_field_wipe_return,reject_secret_field_wipe_helper,reject_secret_field_local,reject_secret_field_param,reject_secret_field_call,reject_secret_field_alias_raw,reject_secret_field_twice,reject_secret_field_ctor_loop,reject_secret_field_store_method,reject_secret_field_store_outside,reject_secret_field_compound,reject_secret_field_this_escape,reject_secret_field_assign_local,reject_secret_field_bind,reject_secret_field_return,reject_secret_field_ternary,reject_secret_field_nullish,reject_secret_field_optional_chain,reject_secret_field_chain,reject_secret_field_index,reject_secret_field_member,reject_secret_field_template,reject_secret_field_console,reject_secret_field_condition,reject_secret_field_equality,reject_secret_field_secret_arg,reject_secret_field_new_arg,reject_secret_field_object_literal,reject_secret_field_json,reject_secret_field_json_decode,reject_secret_field_capture,reject_secret_field_task_wipe,reject_secret_field_scope_wipe,reject_secret_field_scope_helper,reject_secret_field_scope_new,reject_secret_field_store_value,reject_secret_field_using,reject_secret_field_launder_function,reject_secret_field_launder_arrow,reject_secret_field_launder_generic,reject_secret_field_wipe_outside,reject_secret_field_wipe_through,reject_secret_field_wipe_method,reject_secret_field_wipe_ctor,reject_secret_field_this_fin,reject_secret_field_this_store,reject_secret_field_wipe_param,reject_secret_field_wipe_new,reject_secret_field_nested,reject_secret_field_launder_method,reject_secret_field_launder_ternary,reject_secret_field_wipe_param_new,reject_secret_field_wipe_param_method,reject_secret_field_wipe_nested,reject_secret_field_wipe_other, and, for a caller's own local in place of a field,reject_secret_field_launder_localandreject_secret_field_wipe_param_local: one road each. nish:secret: --emit-header keeps a Secret and its holder opaque, and --emit-dts / --emit-napi bridge neither.-
${name}: IR matches goldenand${name}: native output matches .out, forsecret_field,secret_field_wipe_o2andsecret_field_wipe_o2_plain. nish:secret: a holder's wipe survives opt -O2 (a volatile memset of its key), where the twin's fill(0) is an ordinary one.-
codes: every registry code is provoked by a program, declared, or explained (${wordingsSummary}): NL2540 to NL2548 each have theirtests/wordings/program. -
${rel}:${s.line} is rejected with ${s.code}and${rel}:${s.line} compiles, fordocs/AI.mdanddocs/guide/using-nish/standard-library.md: a holder accepted, and a field copied into a local refused with NL2544.
A wipe inside a std/threads task
A task, or a parallel body, may make no write another thread can see
(NL2471). Until #873's threads stage every wipe counted as one, whatever it
zeroed, because its body is a call to llvm.memset and writesShared
(src/attributes.ts) counts a call to any function it has no body for. So a
task could not zero the scratch it allocated itself, and bcrypt could not run
on a worker. Anchors are at main 5d80b08.
Scope
| File | What |
|---|---|
src/attributes.ts |
writesShared, which no longer counts WIPE_MEMSET, and markWipe, which still records the wipe as a write through its argument; ownKeyOf, isWipedFreshSecret and isSecretMake, which admit a Secret made from a fresh value as the call's own object |
src/parallel.ts |
sharedWriteMessage, which reports the refusal at the spawn |
Threat model
A program that compiles while two threads race on a key: a task wipes memory
the parent or another task still reads, or the parent wipes what a task
reads. The wipe itself is out of scope here: it is the same volatile
llvm.memset as before, and nothing in its IR changes.
Method
-
Followed every path into
WIPE_MEMSET: it is added to a function's callees only bymarkWipe, the body of awipeinstance, sowritesSharedcan skip it without skipping any other foreign call. -
markWipestill marks the write through parameter 0 (writesThrough,writesReach,writesDeep) and keeps the instance'ssharedWrite, so a caller'swipe(x)is a write through its argument, judged by wherexcame from as any other write through a call is (composeArguments). -
Wrote a task for each road a wiped array can come from: an array the task allocates, one a helper it calls allocates and wipes while filling an array it is handed, a copy made inside
expose, the task's argument, a captured local, a field, the argument wiped by a helper the task calls, and an array a call answered. -
For the
secret(v)admission (#873, a later stage):isSecretMakematches only the stdsecrettemplate, by name, no owner and home program (isSecretSource), not a user function of the same name.ownKeyOfregisters theSecretas an own object only when it is held by aconst,vis syntacticallynew, an array literal or an object literal, and the body passes the local straight to awipe.What
vholds is recorded as dirt on.valuewithnoteStore, as a field store into an own object would be, so a constructor or literal that takes in a parameter or a captured array still makes the wipe a shared write. A moved local (secret(buf)) or a call's answer (secret(make(n))) is not syntactically fresh, so it stays foreign; a parameter or field is refused earlier by the sole-reference rule; aSecretparameter cannot be wiped by its callee; and a holder'swipe()writes its own field, which stays shared.
Findings
None. The fresh allocations compile and run on threads; every other road is
still NL2471, naming the wipe instance as the write.
A Secret a task makes with secret(v) and wipes was refused at first,
because secret keeps its value and the rule did not read through it. It is
now admitted when v is allocated in the call (see Method); the IR is
unchanged, and the program prints the same at 1, 2 and 8 threads
(tests/link/thread_task_wipe_secret).
What the rule does not admit, by design: a Secret held by a let; one made
from a moved local, a call's answer or a record whose constructor is handed an
object; one a call answers, whether the task wipes it or first hands it to a
helper that writes it; one kept in a holder's field; and an array a call
answered (const st = initState()), whose freshness the rule does not track
across a return. A helper may write the task's own Secret before the wipe
(cleared in tests/link/thread_task_wipe_secret).
A Secret of a literal holding a captured array, secret([buf]), cannot be
written at all: isSecretPayload takes only an array of integers or a record
of integer fields, so no negative test exists for it. The supported pattern for
a shared key is that the parent makes the Secret, each task exposes it
read-only, and the parent wipes it after the scope joins, which the region rule
above already orders.
Properties verified
-
A
wipeof an array the task, or a function it calls, allocated is not a shared write, and the program prints the same at 1, 2 and 8 threads and under Node. -
A
wipeof the task's argument, a capture, a field, the argument a helper wipes for it, or a call's answer is still NL2471. -
A
wipeof aconst k = secret(<new, array or object literal>)the task makes is not a shared write, nor is a helper's write through it before the wipe; alet,secretof a parameter, a field, a call's answer, a moved local or a record whose constructor is handed an object, aSecreta call answers (wiped, or written by a helper), a borrowedSecretparameter and a holder'swipe()are still refused (tests/cases/reject_thread_wipe_secret_param,_field,_call_result,_moved,_borrowed,_holder,_let,_call_secret,_call_secret_helper,_ctor_param).A helper that hands an inner record of shared memory to another that writes it stays refused (
reject_thread_wipe_region_past). A manualopt -O2oftests/link/thread_task_wipe_secretkeeps its four wipes as volatilellvm.memsets, one inlined into each task; no test runs that program underopt -O2; the volatile store itself is pinned by thenish:secretcheck below. -
The emitted IR is unchanged:
sharedWritefeeds no LLVM attribute, and every wipe underopt -O2is still a volatilellvm.memset.
Tests
-
link/${name}: exits with ${wantCode} and stdout matches expected.out,link/${name}: the same exit and stdout under NISH_NUM_THREADS=${threads},link/${name}: emitted IR contains every expected.ir lineandlink/${name}: ${m.file} matches golden, forthread_task_wipe: the volatilellvm.memsetof eachwipeinstance is in the IR; the same first two, forthread_task_wipe_secretandthread_bcrypt_batch(whose lanes agree withbcryptHashandbcryptVerify). -
${name}: rejected with ${needles.map((n) =>"${n}").join(", ")}, forreject_thread_wipe_param,_capture,_field,_helper,_elementand_call_result;reject_thread_wipe_secret_param,_field,_call_result,_moved,_borrowed,_holder,_let,_call_secret,_call_secret_helperand_ctor_param; andreject_thread_wipe_region_past. nish:secret: the wipe survives opt -O2 (a volatile zero for each of the 8 bytes nothing reads again), where the twin's fill(0) is deleted.
Capturing arrows and expose
2026-10-30. An arrow passed to a function-typed parameter of a top-level
function may now read the const locals and parameters of the function it is
written in (docs/LANGUAGE.md, "Function parameters"). The capture is handed
to the instance as an extra argument. Three roads this opens were checked.
-
What
exposeruns. Before, no arrow given to a function parameter captured anything, so the arrowexposeorexposeWithruns could reach only the value it is handed and its own parameters, and a copy of the key bytes could go only where its return value went. With the general rule lifted,expose(k, (b) => { leak.set(b, 0); return 0 })would copy the key intoleak, an array nowipereaches.The arrow
exposeruns still captures nothing: NL2335 refuses it when it is written at theexposecall (reject_secret_expose_capture), and NL2589 when it reachesexposethrough another function's parameter (reject_secret_expose_capture_forwarded,open(k, (b) => ...)withopencallingexpose(k, f)). The two programs are the before/after pair: the same arrow given to a function that is notexposecompiles and runs (tests/cases/fnarg_capture_local). -
A moved local read through a capture. An arrow run after
secret(raw)that readsrawis a read of the moved local, NL2445 (reject_fnarg_capture_secret_moved), as a data-parallel arrow's is (reject_par_capture_secret_moved). -
A capture before the move. An arrow that read
rawbeforesecret(raw)is a second reference, NL2512 (reject_secret_alias_capture_call), as for a data-parallel arrow. The read ended with the call, so this refuses more than it must; it is the conservative direction, and the sole-reference revert check counts it.
No std/ caller of secret, expose or exposeWith changed, and no
finding was opened.
Tests
-
${name}: rejected with ${needles.map((n) =>"${n}").join(", ")}, forreject_secret_expose_capture,reject_secret_expose_capture_forwarded,reject_fnarg_capture_secret_movedandreject_secret_alias_capture_call. -
nish:secret: reverting the sole-reference rule lets every reject_secret_alias_* case compile (${aliasCases.length} cases), which now includesreject_secret_alias_capture_call. -
${name}: IR matches goldenand${name}: native output matches .out, forfnarg_capture_local.

