Skip to content

A1c: shell-inert launch specification - #2047

Merged
neuromechanist merged 29 commits into
feature/issue-2005-epic-compute-corefrom
feature/issue-2043-a1c-shell-inert-launch-spec
Nov 5, 2026
Merged

neuromechanist merged 29 commits into
feature/issue-2005-epic-compute-corefrom
feature/issue-2043-a1c-shell-inert-launch-spec

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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_SPEC is 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_length and not_printable (the launcher drops has_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 (QQ is accepted, QR is refused with not_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_long and not_base64url are 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 branded LaunchSpecEnvValue; 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 is ceil(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_ALPHABET is the one place the alphabet is written down, and isShellInertEnvValue is built from it.

Changes

  • Contract (shared/contract/compute-launch.ts): the encoder, the strict canonical decoder, the bound, the alphabet and the predicate.
  • Tapis client: the request schema accepts the one environment value only when decodeLaunchSpecEnv does; SubmitJobInput.launchSpecEnv is the branded type; the closed one-variable array and archiveFilter.includeLaunchFiles: false are unchanged.
  • A request the client refuses for the job's own data is the typed SubmitRequestRefused (reason launch_spec_env or job_field); submitLeased ends such a job failed with tapis_submit_failed and detail invalid_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.
  • A5 builder: sends the encoded value and records the digest of the text.
  • test/compute-launch-env-shell.test.ts reproduces the scheduler's conditional quoting with a real sh (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.
  • Every leak check looks for the plain token, the whole encoded value and the token's three base64url alignments (launchSecretForms).
  • JSON Schema descriptions, ADR 0118 amendment and implementation notes.

Shared schema file (nemar-process copies it byte for byte and re-pins to the merge commit)

SHA-256: d25c7dcacd782f6e8baa6b550dcd5d193ff0f066aa3437ac794e8dc381c1e561

Size: 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-256 b20fae0dfbe428d0b8f37b52741abc52567b99674cd1b531ee53d9b6e8e36e26 (constant GOLDEN_ENV in test/compute-contract.unit.test.ts).

The second vector (holds - and _, and arguments full of shell-active characters) is 631 bytes of JSON, SHA-256 501b92700038336d2579133ce14f3664bca06827f120be07d079ace09722f91e, encoded to 842 characters, SHA-256 073876511ad06a09f389b7207311fc906ca0c78e05397414bb2d32f31c85273e (URLSAFE_TEXT and URLSAFE_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 typecheck is 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), dash and bash; NEMAR_TEST_SH selects 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 submitJob is asserted on a job ended before submit.

Not run: the full bun test and CI (owner rule: targeted only); CI on Linux would show whether sh there behaves as dash did 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; computeEnabled stays dark.

@github-actions

github-actions Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2047

Version: 0.10.28-PR2047.19cbe57
Commit: 19cbe57


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit b54ab72 into feature/issue-2005-epic-compute-core Nov 5, 2026
17 of 19 checks passed
@neuromechanist
neuromechanist deleted the feature/issue-2043-a1c-shell-inert-launch-spec branch November 5, 2026 23:45

This branch was previously deployed

1 inactive deployment
npm — 19cbe577 Deployed Nov 5, 2026 by neuromechanist via publish #4204
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.

1 participant