Repository navigation
A1c: shell-inert launch specification - #2047
Merged
neuromechanist merged 29 commits intoNov 5, 2026
Merged
neuromechanist merged 29 commits into
neuromechanist merged 29 commits into
Conversation
📦 Package PreviewYour package is ready to test! bun install -g nemar-cli@PR2047Version: 🤖 Updated on each push. |
neuromechanist
merged commit Nov 5, 2026
b54ab72
into
feature/issue-2005-epic-compute-core
17 of 19 checks passed
neuromechanist
deleted the
feature/issue-2043-a1c-shell-inert-launch-spec
branch
November 5, 2026 23:45
This was referenced Nov 5, 2026
This branch was previously deployed
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.
Summary
This is the nemar-cli half of the owner-approved contract follow-up A1c (part of #2043).
The launch specification now travels as the base64url encoding (Request for Comments (RFC) 4648 section 5, alphabet
A-Za-z0-9-_, no padding, no line breaks) of the bytes of the same canonical compact JSON text it was before, and that text is printable ASCII (every byte 0x20 to 0x7e).The JSON text, its digests (
spec_digest,launch_spec_digest) and its 64 KiB cap are unchanged, and the digests are still computed over the text, never over the encoded value.The variable name
NEMAR_LAUNCH_SPECis unchanged.nemar-process implements the same format in the launcher in parallel; the rules it must mirror are listed under "Wire rules".
Why
A security review read the scheduler as writing an environment value into a file that a shell sources on the compute node, and as quoting a value only conditionally; that reading is unverified.
On that reading compact JSON is not shell-inert: a value with no space is written bare, so the shell consumes the quotes of the JSON, and shell-active characters in a user's strings are expanded or break the quoting, outside the container.
Nothing is registered with a tenant and every compute switch is dark, so nothing was exposed.
A value made only of
A-Za-z0-9-_holds nothing a shell acts on and none of the characters such a quoter quotes for.Wire rules (the launcher must mirror these)
Text: every byte of the launch specification text is 0x20 to 0x7e. The encoder refuses anything else with a TypeError and a text over 64 KiB with a RangeError.
Value: the decoder returns
{ ok: true, text }or{ ok: false, reason }with exactly five words,empty,too_long,not_base64url,bad_lengthandnot_printable(the launcher dropshas_nul).The checks run in this order and the first to fail names the refusal: a string (an unset environment variable is not one, and is refused with
not_base64url); not empty; at most 87,382 characters; only the alphabet; a length that is not 1 modulo 4; the=padding added back to a multiple of four (one sign for a length of 3 modulo 4, two for 2 modulo 4) and the value decoded; printable ASCII once decoded; canonical, meaning that encoding the decoded text again gives the value back (QQis accepted,QRis refused withnot_base64url).The length is counted in characters of the value (UTF-16 code units in the reference), which for every accepted value equals its bytes because an accepted value is ASCII. For a value that contains a non-ASCII character,
too_longandnot_base64urlare both conforming answers, since neither can be accepted and languages count a length in different units; the conformance comparison checks accept or refuse for every value, and the word only for ASCII values.A raw JSON value is refused, because nothing is registered with a tenant and there is no earlier format.
API
encodeLaunchSpec(spec)is unchanged and returns the JSON text.encodeLaunchSpecEnv(text)is the wire step and returns a brandedLaunchSpecEnvValue; the brand stops the text being sent as the value, and works in that direction only (the reverse mistake, the value used where the text belongs, compiles and is caught at verification by the digest and verify tests);decodeLaunchSpecEnv(value)is the strict inverse.LAUNCH_SPEC_ENV_MAX_CHARS(87,382, which isceil(65536 * 4 / 3)) is declared once next to the JSON cap; the encoder checks the cap on the text only, because the bound follows from it by arithmetic, which a test pins.SHELL_INERT_ENV_ALPHABETis the one place the alphabet is written down, andisShellInertEnvValueis built from it.Changes
shared/contract/compute-launch.ts): the encoder, the strict canonical decoder, the bound, the alphabet and the predicate.decodeLaunchSpecEnvdoes;SubmitJobInput.launchSpecEnvis the branded type; the closed one-variable array andarchiveFilter.includeLaunchFiles: falseare unchanged.SubmitRequestRefused(reasonlaunch_spec_envorjob_field);submitLeasedends such a jobfailedwithtapis_submit_failedand detailinvalid_spec, the hold released through the never-started path (released, not refunded), instead of retrying it every tick. The owner (configuration) stays a plain RangeError and the job waits.test/compute-launch-env-shell.test.tsreproduces the scheduler's conditional quoting with a realsh(old value as the negative control, new value comes back exactly, no file made); its helper throws if the shell cannot run or does not exit.launchSecretForms).Shared schema file (nemar-process copies it byte for byte and re-pins to the merge commit)
SHA-256:
d25c7dcacd782f6e8baa6b550dcd5d193ff0f066aa3437ac794e8dc381c1e561Size: 21,600 bytes (the file on the epic branch was 21,025 bytes with SHA-256
6707bb26d653b6fc7521a2e05fe33758e533f57f3453ca5567e3698e00469ec2).Only two descriptions changed (the root, and the provenance document's
launch_spec_digest). The structure, meaning every key but the descriptions, is identical to the epic branch's file, and a test pins its hash (684334303372be174ae9b2fd60f36ad57dde5d7fa6f870979e093136c54947af).Golden vectors (unchanged)
The JSON golden text is 766 bytes with SHA-256
88fcf9a4d6e63ae7bbedc9be536989fd7f2c263bb2b1c2fb6cfd706f49efe857; its encoded value is 1,022 characters with SHA-256b20fae0dfbe428d0b8f37b52741abc52567b99674cd1b531ee53d9b6e8e36e26(constantGOLDEN_ENVintest/compute-contract.unit.test.ts).The second vector (holds
-and_, and arguments full of shell-active characters) is 631 bytes of JSON, SHA-256501b92700038336d2579133ce14f3664bca06827f120be07d079ace09722f91e, encoded to 842 characters, SHA-256073876511ad06a09f389b7207311fc906ca0c78e05397414bb2d32f31c85273e(URLSAFE_TEXTandURLSAFE_ENV). Both values are canonical and printable, and the strict decoder accepts them.Verification
Targeted suites only: 886 pass, 0 fail across 10 files in the last run (the contract and shell tests, the leak helper, the Tapis client, the lifecycle and submit suites, the admin-route and admin CLI tests, contract-schemas and the ADR index test); the wider compute set (45 files) passed 1,995 with 2 skips before the last two rounds of review fixes.
bun run typecheckis clean and biome reports no errors; its 10 warnings are on lines this PR did not touch.The shell test passes under macOS
sh(bash in POSIX mode),dashandbash;NEMAR_TEST_SHselects another shell.Every guard was proven by a single-line mutation (24 mutations, all killed), among them: the printable bound 0x7e to 0x7f, the canonical check removed, the schema refine removed, the typed-error mapping removed, and the alphabet constant edited. A partial leak (a log line carrying the last 100 characters of the value) is seen only by the alignment forms, not by a plain-token and whole-value list, and a slice of the token or of an aligned form of 16 characters or more is seen by the window check; the digest written before
submitJobis asserted on a job ended before submit.Not run: the full
bun testand CI (owner rule: targeted only); CI on Linux would show whethershthere behaves asdashdid locally.Still open
Unverified, as before: how the scheduler really quotes (the tests reproduce the rule the review read), and whether Tapis and the scheduler accept an environment value of up to 87,382 characters.
Registration with any tenant stays blocked until the launcher change and the owner items on nemar-process#9 are settled;
computeEnabledstays dark.