Repository navigation
feat(control-plane): a subject's own gate record, trusted for its own templates; repositories per registry - #769
Conversation
… templates Trust is decided by who submits a gate record, never by anything inside it: the record is unsigned bytes, and its sha256 is its identity. - Profiles may carry selfAttest, selfAttestEgress and requireOfflineGate. The default policy gains benchmark-self (the benchmark rules, offline for benchmark integrity) and general-self (no X11; the KVM host's allowlisted egress allowed). benchmark stays curated. - On a selfAttest profile, X1.trusted also passes for the creating subject's own record. Another subject's create on the same sha256 is refused (X1.self.scope); commits are always refused (X12.self); egress only where the profile allows it (X1.self.egress). - X1.offline: on a profile that requires X1 (unless requireOfflineGate is false), a general-gate record needs gate.floor_checked_offline true, fail closed; a curated family record predates the field and passes. The general-gate schema is the setting SH_GATE_RECORD_SCHEMA (default moca-gate-record/1; a malformed value refuses to boot), and GET /v1/policy answers it as gateRecordSchema for a client's dry run. - The gate record names source self and its scope (the submitter). Builds and templates show attestation (deployment | self), recomputed on every read from the current policy, so a promotion or removal rewrites nothing. Builds show gateFloorCheckedOffline (and gateFloorMetOffline from a network_needed gate). - A self-attested template is private: self_attested (409) refuses deployment visibility at create and a self-attested build on a deployment-visible template. A trust removal narrows a visible template to private on read; PUT /v1/policy names the narrowed builds in its answer and its policy record. The same refusal on a visibility edit comes with the template edit route. - OpenAPI 1.6.0 and its changelog entry. Refs rossoctl#738 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…policy
allowedRegistries matches a registry host, so on its own opening Docker
Hub to a few named images opens all of it.
The policy gains an optional allowedRepositories:
{registry: [repository, ...]}. A create from a listed registry must name
one of its repositories (rule registry.repository): an exact path, or a
prefix/* entry, matched on whole path segments (library/python never
admits library/python-evil or library/python/x). A registry with no list
allows every repository, as before, so the default registry's creates are
unchanged. On Docker Hub an official name reads as library/<name>.
policyProblems refuses a list for a registry not in allowedRegistries, an
empty list, and a malformed entry.
An older control plane reading such a policy ignores the field: a
registry opened with it would then be open to every repository it
serves, so remove the registry from allowedRegistries before (or right
after) such a rollback.
OpenAPI 1.6.0's Policy and changelog entry gain the field.
Refs rossoctl#738
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
- A design, docs/specs/2026-11-08-subject-trust-gate-records-design.md: the problem, trust by submitter, the two self-attested profiles, the rules on a self-attested record, what is recorded and shown, visibility and a trust removal's narrowing, the decisions, as built, compatibility and limits. - GATING-RULES: the general gate's record schema among G's, and §2.3, self-attested gate records (X1.self.scope, X12.self, X1.self.egress, X1.offline) and the per-registry repository rule (registry.repository). - The template lifecycle design: the two profiles in §8's table, allowedRepositories in §8.1, and self-attestation in §8.3. - The configuration reference: SH_GATE_RECORD_SCHEMA. Refs rossoctl#738 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
… into pr/i15-own-gate-record One conflict, docs/reference/configuration.md's control-plane table: merged row by row; this PR's SH_GATE_RECORD_SCHEMA row kept beside main's rows. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…s rules are vm-tier An image builder's review of §2.3: X1.offline holds only a record of the named schema (SH_GATE_RECORD_SCHEMA, default moca-gate-record/1) fail-closed; a record of any other schema, such as a builder's family records, passes unless it says floor_checked_offline: false, so a deployment that takes another builder's general-gate records names that schema. All of §2.3's rules are tier vm, checked at create. §1.2's reference to the general gate record now points at §2.3, which this PR adds. Refs rossoctl#738 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
clawgenti
left a comment
There was a problem hiding this comment.
Summary
This PR lets a subject attest its own gate record for its own templates (benchmark-self, general-self; rules X1.self.scope, X12.self, X1.self.egress, X1.offline) and adds allowedRepositories per registry. The rules are fail-closed and well tested, and visibility is recomputed from the current policy on every read. No must-fix issues. Two suggestions, both shown with probes on head:
X1.self.scoperaces. The "first submitter" check reads the catalog before the per-idcat.update, and two subjects create two different template ids, so the per-id serialization never covers both. When alice and bob each send the same untrusted record in parallel (Promise.allSettled), both get202. When they go one after the other, bob is refusedX1.self.scope(the positive control). This goes with the known limit you raise in the PR body: binding a record to its submitter, as a write-once claim keyed by the record's sha256, would close the race as well.- A trust removal doesn't narrow every build.
attestationOftreats a build as self-attested only whenselfAttested === truewas stored at create. Abenchmark-selfbuild created while its record was trusted stays deployment-visible after the record is removed fromtrustedGateRecords, andnarrowedis empty. The same record and profile, created before promotion, narrows to private. So the result depends on the order of events, not on the current policy as §6 decision (i) says.
Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript (control plane: policy, handlers, catalog, config), Docs (design note, GATING-RULES, openapi/CHANGELOG), K8s overlay/shell (stacked from #766, skimmed)
Agent/IDE config (.claude/.vscode): none
Commits: 17 commits (stacked on #766; this PR's own change is the last 4 plus merges), all signed-off: yes
CI status: passing (17/17)
Verified by: vitest run on subject-trust, repository-allowlist and template-create (78 passed); tsc --noEmit (clean). Two throwaway probes, a parallel-create race with a sequential control and a trust-removal ordering check, were deleted after the run.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| // Self-attestation: who already self-attested this record (keyed by subject and sha256), from the | ||
| // catalog: a build's create names its gate record's sha256 and the template its owner. | ||
| const gateSha = gateRecordBytes ? `sha256:${sha256Hex(gateRecordBytes)}` : undefined; | ||
| const gateSelfSubmitters = |
There was a problem hiding this comment.
suggestion: gateSelfSubmitters is read from cat.list() here, outside the per-id cat.update lock. Two subjects creating two different ids with the same untrusted record both see [] and both pass X1.self.scope.
Probe on head: Promise.allSettled([create(alice, 't-a'), create(bob, 't-b')]) gives [202, 202]. Run one after the other, the second is refused X1.self.scope (control).
Suggested fix: record the claim atomically, keyed by the record's sha256. For example, write a write-once provenance blob such as gate-claim/<sha> naming the subject, and refuse the create if it names someone else. That is also the "bind a record to its submitter" follow-up you ask about in the PR body, so one change would fix both.
| trusted: ReadonlySet<string>, | ||
| ): 'deployment' | 'self' { | ||
| const g = b.request?.gateRecordSha256; | ||
| return b.selfAttested === true && g !== undefined && !trusted.has(g) ? 'self' : 'deployment'; |
There was a problem hiding this comment.
suggestion: this is 'self' only if selfAttested === true was stored at create, and that flag is set only when the record was untrusted at create. Take a benchmark-self build created while its record was in trustedGateRecords, with visibility: 'deployment'. After an admin removes the record, the build still reads as attestation: 'deployment', the template stays deployment-visible, and PUT /v1/policy returns no narrowed. Probe: {"narrowed":null,"visibility":"deployment"}. The same record, created before it was promoted, narrows to private.
Suggested fix: on a selfAttest profile, store the fact the profile gives (for example selfAttestProfile: true, or check pol.profiles[b.profile]?.selfAttest on read). Then derive self from that plus !trusted.has(g), so decision (i) holds whatever the order of events.
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Review: request changes
The self-attestation design holds the main trust boundary. Trust comes from the submitter and never from the record. Imported (owner null) templates are excluded, X12 is strict, selfAttestEgress is validated to need selfAttest, and the repository matcher works on whole segments. But the 'self-attested' state is derived from trust at create instead of from the profile, which causes two must-fix trust bugs. First, a trust removal fails to narrow deployment-visible templates other subjects built on the record while it was trusted. Second, X1.self.scope then counts those subjects as submitters and locks the real submitter out of its own record.
- Author: webchang (MEMBER — maintainer)
- Areas reviewed: control-plane template policy (
benchmark-self/general-selfprofiles, X1.self.scope, X12.self, X1.self.egress, X1.offline,allowedRepositories/registry.repository), template visibility and attestation in effect,PUT /v1/policynarrowing,SH_GATE_RECORD_SCHEMA, openapi/CHANGELOG/GATING-RULES/spec parity - Agent/IDE config: none
- Commits: 5 (own range 1507ce5, 6c2442f, 12ad889, merge c2cb61f, c78d08b), all signed-off: yes
- CI status: passing
Findings
- must-fix:
attestationOfonly treatsselfAttestedbuilds as self, so removing trust leaves other subjects' trusted-eraselfAttest-profile builds deployment-visible and unnamed innarrowed(sandbox-handlers.ts:247). - must-fix:
gateSelfSubmittersignoresx.selfAttestedand status, so after promote and removal the original submitter is refusedX1.self.scope(sandbox-handlers.ts:516). - suggestion: X1.self.scope is check-then-act across templates (per-id lock only), so concurrent submitters both win (sandbox-handlers.ts:506).
- suggestion: the image's repository path is not validated (
..,//, uppercase) before allowlist matching (template-policy.ts:321). - nit: gate
scope(the admin) and the catalog's submitter (the owner) can differ for admin-added builds (sandbox-handlers.ts:637).
Checked and fine: an owner-null (imported) template never counts as a submitter, and a self-attested build can't be added to one (its owner check refuses non-admins). Subject comparison is exact on the sub claim, which is already provider-prefixed (github:<id>/oidc:<sub>). A self profile can't loosen tier/envelope/X11, because policyProblems ties selfAttestEgress to selfAttest, and selfAttest to X1. Registry keys are exact (index.docker.io normalized to docker.io, a port kept in the host), so one registry's list never applies to another. The no-host <default> is not Docker-normalized. X1.offline in code matches c78d08b's §2.3 text (the named schema fails closed; another schema passes unless it says false). The merge c2cb61f only resolves the configuration.md table (the SH_GATE_RECORD_SCHEMA row kept).
| trusted: ReadonlySet<string>, | ||
| ): 'deployment' | 'self' { | ||
| const g = b.request?.gateRecordSha256; | ||
| return b.selfAttested === true && g !== undefined && !trusted.has(g) ? 'self' : 'deployment'; |
There was a problem hiding this comment.
must-fix: a trust removal does not narrow builds made on a selfAttest profile while the record was trusted.
attestationOf returns self only when b.selfAttested === true, and selfAttested is set only when the record was untrusted at create (selfAttestedCreate). The scenario: an admin promotes R (sha256 in trustedGateRecords). Bob then creates t-bob on benchmark-self with R. The record is trusted, so the build carries no selfAttested, and the template is stored with Bob's requested visibility (default deployment). The admin then removes R again. attestationOf(bob's build, after) is still deployment, so effectiveVisibility keeps t-bob deployment-visible, putPolicy's narrowed leaves it out, and every subject keeps using a template whose only gate evidence is an untrusted, unsigned record. This contradicts the JSDoc here ("a record the policy does not (or no longer) trust"), spec §6 decision (i), the CHANGELOG/openapi narrowed contract and GATING-RULES §2.3 ("until an admin adds the record's sha256"). The tests only cover the case where the template's creator first self-attested R (narrows a visible template to private on removal).
Fix: compute attestation from the profile at create rather than from trust at create. Store a fact on every build made with a gate record on a selfAttest profile (e.g. selfAttestProfile: true, or check pol.profiles[b.profile]?.selfAttest against the build's recorded profile), and return self whenever its sha256 is not trusted now. Add a test: promote, then another subject creates deployment-visible, then remove; expect narrowed to name that build and other subjects to get 404.
| d.owner !== null && | ||
| d.builds.some( | ||
| (x) => | ||
| x.request?.gateRecordSha256 === gateSha && |
There was a problem hiding this comment.
must-fix: X1.self.scope counts subjects who never self-attested, which can lock the real submitter out of its own record.
This filter counts every owner with a build naming the sha256 on a selfAttest profile, whether or not that build was self-attested (x.selfAttested), and whatever its status (rejected or failed builds count too). The scenario: Alice self-attests R on t-a. The admin trusts R, and Bob builds t-b on benchmark-self with R (trusted, so no scope check runs). The admin then removes R. Alice's next self-attested create with R (a new template, or a new build of t-a) now finds gateSelfSubmitters = [alice, bob] and fails X1.self.scope. That breaks the docs' "counts only for its first submitter" (GATING-RULES §2.3) and spec §4's (subject, sha256) key. A rejected X1.image or X12.self create also never reaches the catalog, but a later failed or rejected build still "claims" the record.
Fix: count only x.selfAttested === true builds (the actual self-attestations). Decide whether rejected or retired builds hold the claim and document it. Better still, key the claim on the gate provenance records with source: 'self' and their scope, which already name the submitter. Add the promote, other subject, remove, original submitter test.
| // Self-attestation: who already self-attested this record (keyed by subject and sha256), from the | ||
| // catalog: a build's create names its gate record's sha256 and the template its owner. | ||
| const gateSha = gateRecordBytes ? `sha256:${sha256Hex(gateRecordBytes)}` : undefined; | ||
| const gateSelfSubmitters = |
There was a problem hiding this comment.
suggestion: X1.self.scope is check-then-act across templates (TOCTOU).
gateSelfSubmitters is read from cat.list() before checkCreate, and the build is written later in cat.update(id, …), which serializes only per template id. Two subjects who POST the same untrusted record concurrently (different ids) both see [], both pass X1.self.scope, and both end up with self-attested builds of one sha256. The invariant "a record counts for one subject only" is then broken, and from then on each one's further creates are refused by the other. Fix: run the lookup and the write under one deployment-wide lock (or a per-sha256 claim, e.g. an atomic create of gate-claims/<sha256> naming the subject, checked inside the update). Or document the window.
| const reg = registryOf(input.image); | ||
| const list = policy.allowedRepositories?.[reg]; | ||
| if (list) { | ||
| const repo = repositoryOf(input.image); |
There was a problem hiding this comment.
suggestion: repositoryOf matches the raw path without validating it, so the allowlist is only as strict as the build host's reference parser.
repositoryOf takes the path verbatim. IMAGE_RE (^[^\s@]+@sha256:…) admits any non-space characters, so docker.io/library/../evil/x@sha256:… yields repo library/../evil/x and passes a library/* entry. docker.io/library//python@… and docker.io/Library/Python@… are similar cases. The policy entries are held to a strict lowercase grammar (REPOSITORY_ENTRY_RE), but the image side is not. Whether this is exploitable depends on how the build host's puller treats such a reference. The control plane should not rely on that: a reference the matcher and the puller read differently is how one registry's allowed repository ends up admitting another's. Fix: when a registry has an allowedRepositories list, require repo to match the same segment grammar (the regex without the /* suffix, so no empty, . or .. segments and no uppercase), and refuse otherwise with registry.repository. Add tests for .., // and uppercase.
| // create, after any later change. | ||
| source: | ||
| result.gateTrust === 'trusted' ? 'trusted' : selfAttestedCreate ? 'self' : 'client', | ||
| ...(selfAttestedCreate ? { scope: p.sub } : {}), |
There was a problem hiding this comment.
nit: the gate record's scope and the X1.self.scope key can name different subjects.
When an admin adds a self-attested build to another subject's template (existing && isAdmin(p) is allowed above), scope records the admin (p.sub). gateSelfSubmitters derives the submitter from the template's owner, so the catalog treats the owner as the attester and the provenance treats the admin as the attester. Pick one, preferably the template owner since trust is scoped to the owner's templates (or refuse admin self-attested builds on others' templates), and record it consistently.
…fAttest profile The review asked that attestation follow the profile a build was made on, not the record's trust at create. A build made on a selfAttest profile while its record was trusted carried no selfAttested, so removing the record from trustedGateRecords left its template deployment-visible and out of PUT /v1/policy's narrowed, contrary to decision (i). Every build made on a selfAttest profile with a gate record now stores selfAttestProfile: true, and attestationOf reads it as self whenever its record is not trusted now, whatever the order of events. The new test promotes a record, lets another subject create a deployment-visible template with it, removes the record, and expects narrowed to name that build and other subjects to get 404 while its owner keeps using it. The subject trust spec (§5, §6), GATING-RULES §2.3, the OpenAPI attestation description and the changelog say so. Refs rossoctl#738 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…d on the template owner, one create per record at a time The review asked for three changes to X1.self.scope's claim. - Only a self-attestation claims a record: the lookup counts builds stored with selfAttested (untrusted at create), no longer every build naming the sha256 on a selfAttest profile. A build made while the record was trusted claims nothing, so after a promotion and a removal the first submitter keeps its record. A claim is made by an admitted self-attested create and held whatever its build becomes (failed, rejected or retired); a refused create claims nothing. - The subject a record counts for is the template's owner, in the check and in the gate record's scope alike. An admin's build on another subject's template attests for that owner; an imported template has none, so a self-attested record is refused there. - The lookup and the create's write run as one step per gate record sha256 (a per-catalog queue in the control plane's process, as the catalog serializes its own writes per id), so two subjects sending one untrusted record at once can't both claim it. Tests: two concurrent creates, one claims; promote, another subject builds, remove, the first submitter is admitted and the other refused; a failed build still claims; an admin's build is scoped to the owner. The subject trust spec (§4, §5, §9), GATING-RULES §2.3 and the changelog say so. Refs rossoctl#738 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
… entries' grammar The review asked that the image side of the repository allowlist be as strict as the policy side. IMAGE_RE admits any non-space path, so a reference such as docker.io/library/../evil/x passed a library/* entry, and empty segments or uppercase reached the matcher as given: the allowlist was only as strict as the build host's reference parser. From a registry with allowedRepositories, the image's repository path must now match the entries' grammar without the /* suffix (lowercase segments of letters and digits separated by '.', '_' or '-'; no empty, '.' or '..' segment), or the create is refused under registry.repository with a message that says the path is malformed. Both regexes share one pattern. A registry with no list is unchanged. Tests for '..', '.', '//', uppercase and a trailing slash. GATING-RULES §2.3, the lifecycle design §8.1, the OpenAPI Policy description and the changelog say so. Refs rossoctl#738 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…fails The review asked whether failed, rejected or retired builds hold the X1.self.scope claim. Holding it whatever the build becomes let any subject keep a published record for good with a build that fails. A claim now counts a build only while it is selfAttested, names the record's sha256, and has not ended failed: queued, building, probing, built, registered, rejected and retired builds keep it (a real use, or an admin's decision); a failed build never admitted a template and releases it. This catalog has no cancelled status. Tests: a failed claim lets another subject self-attest the record (and then refuses the first); a retired or rejected claim still refuses the other subject. The subject trust spec (§4, §6), GATING-RULES §2.3 and the changelog say so. Refs rossoctl#738 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
|
Thanks for the review. All seven threads are addressed on the new head (41a4afb), in four commits. In short:
Thread by thread: 1.
|
clawgenti
left a comment
There was a problem hiding this comment.
Summary
The four new commits address every finding from both earlier reviews. A trust removal now narrows any build made on a selfAttest profile (selfAttestProfile), whatever its trust at create. X1.self.scope counts only real self-attestations, keyed on the template owner, and releases a claim when its build fails. The scope lookup and the write now run in one per-sha256 queue, so concurrent submitters can't both claim a record within one process. The image path is checked against the entries' grammar before matching, and the gate scope names the template owner. No must-fix issues. One suggestion and one nit are new: the repository grammar refuses valid OCI names such as foo--bar and foo__bar, and a doc comment is misplaced.
Author: webchang (MEMBER — maintainer)
Areas reviewed: TypeScript (control plane: sandbox-handlers create path and attestation, template-policy repository grammar, template-catalog), tests (subject-trust, repository-allowlist), Docs (GATING-RULES §2.3, subject-trust spec §4–§6, lifecycle spec, openapi, CHANGELOG)
Agent/IDE config (.claude/.vscode): none
Commits: 21 commits, all signed-off: yes
CI status: passing
Verified on head with vitest run on subject-trust, repository-allowlist and template-create (90 passed) and tsc --noEmit (clean). The rest of the control-plane suite also passes, except for the Redis-backed tests, which need a local Redis. A throwaway probe confirmed that docker.io/myorg/foo--bar and docker.io/myorg/foo__bar are refused registry.repository under myorg/*. It was deleted after the run.
Generated by RepoMan github-pr-review@235a7f7 (https://github.com/rossoctl/agent-skills/blob/235a7f7620139ee3e4ab0872b8439591fe52e8c1/skills/github-pr-review/SKILL.md).
| } | ||
|
|
||
| /** A repository path: lowercase segments, each letters and digits separated by `.`, `_` or `-`. */ | ||
| const REPOSITORY_PATH = '[a-z0-9]+(?:[._-][a-z0-9]+)*(?:\\/[a-z0-9]+(?:[._-][a-z0-9]+)*)*'; |
There was a problem hiding this comment.
suggestion: this grammar is stricter than the OCI distribution spec, so it refuses valid repository names.
The spec's path component is [a-z0-9]+((\.|_|__|-+)[a-z0-9]+)*, which allows a double underscore and any run of dashes. Here a single ., _ or - must sit between alphanumerics. Probe on head: with allowedRepositories: { 'docker.io': ['myorg/*'] }, docker.io/myorg/foo--bar@sha256:… and docker.io/myorg/foo__bar@sha256:… are both refused registry.repository as "malformed". myorg/foo-bar is admitted. An admin also can't list such a repository as an entry, because REPOSITORY_ENTRY_RE shares the pattern.
Suggested fix: use the spec's separator, (?:[._]|__|-+), in REPOSITORY_PATH. It still rules out empty, . and .. segments and uppercase. Add foo--bar and foo__bar to the admitted cases. If the stricter grammar is intended, say in GATING-RULES §2.3 and openapi that it is narrower than OCI.
| return { templates, buildsQueued }; | ||
| } | ||
|
|
||
| /** |
There was a problem hiding this comment.
nit: this doc comment describes gateClaimQueue, but the CLAIM_RELEASED comment now sits between the two. Editors and TSDoc attach only the nearer block, so CLAIM_RELEASED gets two stacked comments and gateClaimQueues/gateClaimQueue get none. Move this block down to just above const gateClaimQueues.
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Follow-up review at 41a4afb: approve
I checked the four new commits (fed8c5a, fb22078, 76d6008, 41a4afb) against every item from our review at c78d08b and both of clawgenti's. All are fixed:
- must-fix: trust removal narrows trusted-era builds. Fixed.
selfAttestProfileis stored on every gate-record build on aselfAttestprofile (sandbox-handlers.ts:711), andattestationOfderivesselffrom it plus current trust (:249). The new test covers promote, another subject's create, then removal:narrowednames the build, other subjects get 404, and the owner keeps using it. - must-fix: X1.self.scope counted non-self-attesters. Fixed. Only
selfAttestedbuilds that have notfailedclaim the record (:561). The claim rules are documented in spec §4, GATING-RULES §2.3 and the CHANGELOG, and tested. - suggestion: TOCTOU (also clawgenti). Fixed within one process. The lookup, checks and write run under a per-sha256
SubjectQueue(:522). Spec §9 states the single-control-plane limit, and a concurrent-create test covers it. - suggestion: repository path grammar. Fixed. The image path must match the entry grammar before matching (template-policy.ts:327), with tests for
..,.,//, uppercase and a trailing/. - nit: scope vs key. Fixed. Both are the template owner (
attester), and a guard refuses the write if the owner changed during the create.
I found no regressions in the fix. One optional nit is inline. +1 to clawgenti's nit on the misplaced gateClaimQueue doc comment (:481), which we had drafted too, and to their foo--bar/foo__bar repository-grammar suggestion.
One note, no change needed: after a removal, a trusted-era build reads as self-attested but holds no claim, so a third subject can still claim the record. Spec §4 says so, and visibility still narrows to the owner.
- Commits: 4 new, all signed-off: yes
- Agent/IDE config: none
- CI status: passing
Assisted-By: Claude Code
| * its own writes per id the same way, in this process; a deployment runs one control plane. | ||
| */ | ||
| /** The build statuses that release a self-attested claim (X1.self.scope): ended without a template. */ | ||
| const CLAIM_RELEASED = new Set<TemplateBuild['status']>(['failed']); |
There was a problem hiding this comment.
nit: releasing the claim on failed lets another holder of the same record bytes take it over. A host-side build failure (not the submitter's choice) releases the claim. Any other subject with the record's bytes can then self-attest it first, after which the original submitter is refused X1.self.scope for its own record, including a rebuild of its own template. This is documented as intended, but consider releasing only on the owner's own cancel, or letting the original submitter re-claim after a release. Optional.
Main now holds the self-serve create this branch was built on, in its reviewed form (owned quota, the per-subject quota lock, the guest size alias, the image reference grammar, X10 and X12 whatever the profile). Main's form is kept throughout, with this branch's self-attestation and repository allowlist on top. The API stays at 1.6.0 (main 1.5.0). Conflicts and resolutions: - docs/api/openapi.yaml, Profile: main's requires (the rule id enum), then this branch's selfAttest, selfAttestEgress and requireOfflineGate. - docs/specs/2026-11-03-template-lifecycle-and-provenance-design.md §8.1: main's paragraph, with this branch's allowedRepositories clause (rule registry.repository) after the allowed registry. - packages/control-plane/src/index.ts: exports both DEFAULT_GATE_RECORD_SCHEMA and DEFAULT_OWNED. - packages/control-plane/src/sandbox-handlers.ts: the imports take DEFAULT_GATE_RECORD_SCHEMA, normalizeSpec and ownedLimit. admitBuild keeps main's body (the quota lock around the catalog update, the owner's quota, the template slot and owned checks, the normalized spec) and adds this branch's: the two self_attested refusals after the owner check, the gate record's source from gateTrust (self, with scope), the build's selfAttested, selfAttestProfile and gateFloor, and a private template for a self-attested create. The gate record claim queue stays outside the quota lock, which stays outside the catalog's id lock. - packages/control-plane/src/template-policy.ts: registryOf is main's (case-insensitive hosts); the registry.repository rule runs when the image is pinned (main's isPinnedImage, in place of IMAGE_RE); the guest size is main's (one key or its alias, never both); X1 keeps this branch's selfAttested and main's checkGate; this branch's self-attested rules come before main's X12 whatever the profile; policyProblems keeps main's envelope.exact check, then this branch's profile flags. Follow-ups in the merge (no conflict marker; the tests found them): - allowedRepositories' keys now compare case-insensitively, as main's allowedRegistries do: registryOf lowercases the host, so a key in another case would have left its registry open. The check that a key is in allowedRegistries compares the same way. Test: "reads a registry key in any case, as allowedRegistries does". CHANGELOG 1.6.0 says so. - test/repository-allowlist.test.ts: an image path with `..`, `.`, an empty segment, uppercase or a trailing slash is now refused by M1 (main's reference grammar) before the repository rule; the cases expect M1. - test/subject-trust.test.ts and test/repository-allowlist.test.ts: the sample spec no longer adds guest_mb beside guest_ram_mb, which main refuses (M7.guest). Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
|
Merged main (d4babb8). Tests ran locally on the existing node_modules, since a fresh install is held by the new hono pin's release-age window; CI is the full check. A security-relevant merge fix. Main now lowercases registry hosts, so an Assisted-By: Claude Code |
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
Follow-up at 522b79e (41a4afb..522b79e). This push has no commits of this PR's own. It brings in main d4babb8 (#757 microVM fixes, #767 the sbx templates authoring client, #803 the hono 4.13.18 bump), through a merge of upstream/main. I checked the hand resolutions with git show --remerge-diff, compared them against both parents, and grepped the merged tree for conflict markers and duplicate definitions.
The resolution is correct. The self-attest work (selfAttestedCreate, X1.self.*, X12.self, the selfAttest/selfAttestEgress/requireOfflineGate checks, forced-private visibility) now sits inside main's quotaLock(cat).run(...), with main's checkGate, unconditional X12, ownedLimit, normalizeSpec, stricter isPinnedImage and lowercasing registryOf. Each block appears once, and the dropped gateTrusted is gone everywhere.
The security-relevant follow-on is correct. Main now lowercases the registry host, so a mis-cased allowedRepositories key (GHCR.io) would have matched nothing and left that registry unrestricted. checkCreate now unions the lists of every key that matches case-insensitively (template-policy.ts), and policyProblems checks the key against allowedRegistries case-insensitively. So a key in another case can only add entries, never drop the restriction. A test and a CHANGELOG line cover it. The test edits (dropping guest_mb beside guest_ram_mb, and M1 for the malformed path) follow from main's stricter checks.
Coordination note: #759 and #762 also claim API 1.6.0 off main.
Our two open suggestions from 41a4afb are unchanged.
Author: webchang (MEMBER — maintainer)
Agent/IDE config (.claude/.vscode): none
Commits: no new own commits except where noted; signed off: yes (DCO pass)
CI status: nearly done: 15 pass, proto and deploy-scripts still running.
AI-assisted review, approved by a maintainer before posting.
Upstream main (634781a) adds the sandbox lease wire (rossoctl#802) as API 1.6.0, which this branch also claimed; its section moves to 1.7.0. Conflicted: - docs/api/CHANGELOG.md: main's 1.6.0 (sandbox modes) kept as main has it; this branch's section is now 1.7.0, above it. - docs/api/openapi.yaml: error codes are the union (main's mode_not_allowed, then self_attested); info.version 1.7.0. - packages/control-plane/src/errors.ts: both codes and both status entries kept (mode_not_allowed 403, self_attested 409). - packages/control-plane/src/sandbox-config.ts: main's SH_SANDBOX_IDLE_CEILING_S check kept, then this branch's SH_GATE_RECORD_SCHEMA check; the config carries both. - packages/control-plane/test/errors.test.ts: the expected table holds both codes. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Upstream main (f60db30) adds session grants (rossoctl#807) as API 1.7.0, so this branch's section moves to 1.8.0. Conflicted: - docs/api/CHANGELOG.md: main's 1.7.0 (grants) and 1.6.0 kept as main has them; this branch's section is now 1.8.0, above them. - docs/reference/configuration.md: main's control-plane table (with the grant variables) kept; this branch's SH_GATE_RECORD_SCHEMA row added back into it. Also changed in the merge: - docs/api/openapi.yaml: info.version 1.8.0. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Refs rossoctl#738 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…fAttest profile A build was read as self-attested only if `selfAttested: true` was stored at create, which a create sets only when the record was untrusted then. A build made on a selfAttest profile while its record was trusted therefore stayed deployment-visible after an admin removed the record from trustedGateRecords, against decision (i). Every build made on a selfAttest profile with a gate record now stores `selfAttestProfile: true`, trusted or not at create, and attestationOf reads it as self whenever its sha256 is not in trustedGateRecords now, so the narrowing holds whatever the order of events. The subject trust spec, GATING-RULES §2.3, openapi's `attestation` and the API changelog say so. Test (fails with the fix reverted): narrows on removal another subject's build made on a selfAttest profile while the record was trusted (promote, another subject creates a deployment-visible template, remove: `narrowed` names that build, other subjects get 404, its owner keeps using it). (cherry picked from commit fed8c5a) Ports rossoctl#769 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…d on the template owner, one create per record at a time - The lookup counted every build that sent the record on a selfAttest profile, including builds made while the record was trusted, so a subject that never self-attested could lock the real submitter out of its own record. It now counts only builds stored with `selfAttested: true` (the record untrusted at create). - A claim is made by an admitted self-attested create and held while its build is queued, building, probing, built, registered, rejected or retired; a failed build never admitted a template and releases it, so no one holds a published record with a build that fails. - The lookup, the checks and the catalog write ran as separate steps (check-then-act across templates): two subjects sending the same untrusted record at once could both claim it. A create that sends a gate record now runs them as one step under a per-sha256 queue per catalog, in this process; the spec's limits name it. - The subject a self-attested record counts for is the template's owner, in the check (X1.trusted, X1.self.scope) and the gate record's `scope` alike: an admin's build on another subject's template attests for that owner; an imported template has no owner, so a self-attested record is refused there; a guard refuses the write if the template's owner changed between the check and the write. The subject trust spec, GATING-RULES §2.3 and the API changelog say so. Tests (each fails with the fix reverted): counts only self-attestations: a build made while the record was trusted claims nothing; lets one of two concurrent subjects claim a record, never both; releases a claim whose build failed: another subject then self-attests the record; attests an admin's build on another subject's template for that template's owner. (cherry picked from commit fb22078) (cherry picked from commit 41a4afb) Ports rossoctl#769 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…gister id The previous port re-indented createBuild's body into the gate record's claim step; one comment it moved still named an internal tracking id. It states the behaviour alone now. Comment only. Ports rossoctl#769 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
… entries' grammar, and reads a registry key in any case - repositoryOf matched the raw path without validating it, so the repository allowlist was only as strict as the build host's reference parser. From a registry with allowedRepositories, the image's repository path must now match the entries' grammar (lowercase segments of letters and digits separated by `.`, `_` or `-`; no empty, `.` or `..` segment), or the create is refused under registry.repository with a message saying the path is malformed. Both regexes share one pattern. With M1's reference grammar in place, such a path is refused by M1 first, so this check is a second line. - registryOf lowercases the image's host (the ported M1 fix), but allowedRepositories was looked up by the key as written: a key in another case (`Docker.IO`) found no list, which left that registry open to every repository. Every key naming the registry in any case now contributes its list, and the check that a key is in allowedRegistries compares the same way (the upstream branch's merge follow-up). openapi's Policy, the lifecycle spec §8.1 and the API changelog say so. Tests: reads a registry key in any case, as allowedRegistries does (fails with the fix reverted); an image path with `..`, `.`, an empty segment, uppercase or a trailing slash is refused, by M1, before the repository rule is reached. (cherry picked from commit 76d6008) (cherry picked from commit 522b79e) Ports rossoctl#769 review fixes Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Upstream main (949dc5f) adds template tags, edits and owner transfer (rossoctl#774) as API 1.8.0, so this branch's section moves to 1.9.0. Conflicted: - docs/api/CHANGELOG.md: main's 1.8.0, 1.7.0 and 1.6.0 kept as main has them; this branch's subject-trust section is now 1.9.0, above them. - docs/reference/change-policy.md: main's list kept, with this branch's "then subject trust for gate records" after it; both version mentions say 1.9.0. - packages/control-plane/src/sandbox-handlers.ts (admitBuild): main's retry when an owner transfer moves the template between the read and the write kept; this branch's self-attested refusals (a deployment-visible template, an owner other than the attester), its gate record body (source self, scope) and its build fields (selfAttested, selfAttestProfile, gateFloor, private visibility) put into it. The comment that a template's owner never changes is gone. Also changed in the merge: - docs/api/openapi.yaml: info.version 1.9.0; PATCH /v1/templates/{id} declares 409 self_attested. - sandbox-handlers.ts: the owner's check on main's tag, edit and transfer routes reads the effective visibility (canSee with the trusted set), as every other read does on this branch. PATCH /v1/templates/{id} refuses `visibility: deployment` with 409 self_attested while a build is self-attested (registered, or on its way there), the refusal this branch's spec deferred until the edit route was in. - The CHANGELOG's 1.9.0 section and the subject-trust spec (§6, §8) say so; subject-trust.test.ts tests it. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
…refused until its record is trusted
A subject's own gate record counts for that subject's own templates only
(subject-trust spec §6). The owner transfer that came with the template
admin routes could hand a template whose builds are self-attested to
another subject. That subject could then use builds trusted only on a
record they never submitted.
PUT /v1/templates/{id}/owner now answers 409 self_attested while any
build is self-attested and registered or on its way there, as the
visibility edit to deployment does. Once an admin trusts the record, the
transfer goes through. A transfer to the current owner is still answered
with no change. openapi, the changelog's 1.9.0 section and the spec §6
name the refusal.
Refs rossoctl#738
Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Rong Chang <[email protected]>
No conflicts: main adds setup.sh's Redis guard, its tests and the image's Dockerfile. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
|
Main (ab8d10e) merged in. Besides resolving the conflicts with #774, the merge makes three changes that this PR's own diff doesn't show:
The openapi version moves to 1.9.0, above #774's 1.8.0. Assisted-By: Claude Code |
Brings upstream main 01528b6 (rossoctl#769, rossoctl#782, rossoctl#771, rossoctl#773) through pr/i18-host-agent. Main took API 1.9.0, and the host agents moved to 1.10.0, so this branch's activation section moves to 1.11.0. Conflicts: - docs/api/CHANGELOG.md: ## 1.11.0 activation, above ## 1.10.0 host agents and main's ## 1.9.0, which are unchanged. - docs/api/openapi.yaml: main's 409 self_attested on the owner transfer, then this branch's activate and deactivate paths. info.version is 1.11.0. - docs/reference/change-policy.md: main's list, then "the template host agents, then activation leases". Both version numbers are 1.11.0. - docs/reference/http-api.md: the host agents row (API 1.10.0), then the Activation row (API 1.11.0). "Activation came with API 1.11.0." - packages/control-plane/src/sandbox-handlers.ts: ReadinessFacts carries both this branch's placement and nowS and main's trusted set. Its docs argument and both returns carry all three. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
Closes #738. On main (ab8d10e): #766, which this branch used to stack on, is merged. Its own change is the commits on top of main (subject trust for gate records, repositories per registry, their review fixes, and merges of main).
What it does: a builder can attest its own gate record for its own templates, and the policy can limit repositories per registry. Four signed-off commits:
benchmark-selfandgeneral-self;X1.self.scope,X12.self,X1.self.egressandX1.offline;SH_GATE_RECORD_SCHEMA(defaultmoca-gate-record/1), shown asgateRecordSchemaonGET /v1/policy;allowedRepositoriesper registry.GATING-RULES.md§2.3 says howX1.offlinetreats other schemas, and that its rules apply to the vm tier.Notes for review:
PUT /v1/policy.X1.self.scopegives a record to the first subject that self-attests it. A gate record is published, so another subject could submit someone else's record first, and the builder's own create would then be refused until an admin trusts the record. Today the remedy is that admin trust. A possible follow-up binds a record to its submitter. Which would you prefer?Tests on the tip:
deploy/sbx/template-onboarding/tests/examples.test.shpasses.17 files, +1,394 / -44, counted against #766's tip.
Assisted-By: Claude Code