Skip to content

feat(sc.sh): opt-in install of branch-preview tarballs via SIMPLE_CONTAINER_ALLOW_PREVIEW#278

Open
Cre-eD wants to merge 1 commit into
mainfrom
fix/sc-sh-allow-preview-tarballs
Open

feat(sc.sh): opt-in install of branch-preview tarballs via SIMPLE_CONTAINER_ALLOW_PREVIEW#278
Cre-eD wants to merge 1 commit into
mainfrom
fix/sc-sh-allow-preview-tarballs

Conversation

@Cre-eD
Copy link
Copy Markdown
Contributor

@Cre-eD Cre-eD commented May 19, 2026

Why

Production users testing a feature-branch SC build via `sc.sh` are blocked by the Phase 2c failgate: the cert-identity regex passed to `cosign verify-blob` is hard-pinned to `push.yaml@refs/heads/main`, so every preview tarball trips signature verification — even though it's a legitimately signed Sigstore bundle. The only workarounds today are:

  1. Skip `sc.sh` entirely and `curl + tar -xz` the tarball — loses the signature check the failgate was built to provide.
  2. Locally patch the regex — fragile and undocumented.

Neither preserves the supply-chain integrity guarantee. This PR adds a documented opt-in env var that widens the regex without weakening the default strict mode.

Discovered while validating the CloudTrail security alerts plugin (PR #277) against a preview build of that branch — `sc.sh` refused the v2026.5.26-pre.4cc1a03-preview.4cc1a03 tarball with no actionable error.

What

`sc.sh` — opt-in regex relaxation

`verify_sc_tarball` now branches on the new `SIMPLE_CONTAINER_ALLOW_PREVIEW` env var:

Signature, Rekor log entry, OIDC issuer, and SHA-256 sidecar are all still verified end-to-end. The opt-in only changes which signer-workflow identities the regex permits.

`sc.sh` — actionable error on preview-signed-but-strict-mode

When cosign reports a `branch-preview.yaml` signer and the env var is unset, the script now surfaces a copy-paste unblock:

```
The tarball was signed by branch-preview.yaml (a feature-branch
build), not by the production push.yaml@main workflow. To allow
preview builds explicitly, rerun with:

SIMPLE_CONTAINER_ALLOW_PREVIEW=1 SIMPLE_CONTAINER_VERSION= \
bash <(curl -Ls https://dist.simple-container.com/sc.sh)
```

instead of the generic "tampered in transit / CDN compromised" copy.

`docs/SECURITY.md` — documentation

  • New subsection under "Verifying tarballs" documenting the `SIMPLE_CONTAINER_ALLOW_PREVIEW=1` opt-in plus the manual cosign equivalent.
  • Corrected the stale comment claiming preview tarballs don't land at the CDN — they do (`branch-preview.yaml` publishes to the same bucket).

Security analysis

Why this is safe to relax behind an opt-in:

  1. Repo provenance preserved. The regex still anchors to `github.com/simple-container-com/api` workflows only. An attacker cannot publish a malicious tarball under a fork's workflow identity.
  2. Issuer pinned. OIDC issuer remains `token.actions.githubusercontent.com`.
  3. End-to-end Sigstore. Rekor log entry, cosign bundle, and tarball SHA-256 sidecar continue to be verified — only the allowed signer-workflow set is broader.
  4. Strict by default. Production users never set the env var and remain on the `push.yaml@main`-only path. Picking up a preview build requires explicit acknowledgement.

What this does NOT do:

  • It does not promote any feature-branch identity into the production trust set — production behavior is unchanged.
  • It does not change the cosign command-line shape (still no `--yes`, still uses `COSIGN_EXPERIMENTAL=1`).
  • It does not affect attestation verification commands documented elsewhere in SECURITY.md (those remain production-only and continue to require manual override if a preview install needs them).

Testing

Verified against the live preview build `v2026.5.26-pre.4cc1a03-preview.4cc1a03` (from the feat/cloudtrail-alerts-exclusions-and-new-detectors branch):

  • `SIMPLE_CONTAINER_VERSION=v2026.5.26-pre.4cc1a03-preview.4cc1a03 sc.sh` → fails with new helpful message ✅
  • `SIMPLE_CONTAINER_ALLOW_PREVIEW=1 SIMPLE_CONTAINER_VERSION=v2026.5.26-pre.4cc1a03-preview.4cc1a03 sc.sh` → installs cleanly, signature verified ✅
  • Without preview version pinned, default install path → unchanged ✅

Test plan

  • Manual run: preview install with opt-in succeeds
  • Manual run: preview install without opt-in fails with new precise message
  • Manual run: normal production install path unchanged
  • CI: branch-preview.yaml run on this fix branch — confirm the new sc.sh published to dist still works for production installs
  • Once merged + a push.yaml release fires, downstream consumers (integrail/devops install-sc, PAY-SPACE wrappers) gain the opt-in path automatically

Refs

…TAINER_ALLOW_PREVIEW

Why: production users testing a feature-branch SC build (e.g. before merging
an SC API PR that affects downstream consumers) currently can't use sc.sh —
the Phase 2c cert-identity regex is hard-pinned to push.yaml@refs/heads/main,
so every preview tarball trips cosign verification even though it's a
legitimately signed Sigstore bundle. Today the only workaround is to bypass
sc.sh entirely (`curl tarball + tar -xz`), which loses the signature check
the failgate was built to provide. The opt-in path documented here gives
preview testing back without weakening the production strict-mode default.

What:
- sc.sh: when SIMPLE_CONTAINER_ALLOW_PREVIEW=1 is set, widen the cert-identity
  regex passed to `cosign verify-blob` to also accept
  branch-preview.yaml@refs/heads/*. Default (env var unset / not "1") is
  unchanged — only the production push.yaml@main identity is accepted.
  Signature, Rekor log entry, and OIDC issuer are still verified end-to-end;
  the broader regex is the only thing that changes.
- sc.sh: on signature failure where cosign reports a branch-preview signer,
  surface a precise next-step ("rerun with SIMPLE_CONTAINER_ALLOW_PREVIEW=1
  SIMPLE_CONTAINER_VERSION=...") instead of the generic compromise message,
  so a user who knows they're installing a preview build gets a copy-paste
  unblock instead of having to read the script.
- docs/SECURITY.md: document the opt-in env var alongside the existing
  manual `cosign verify-blob` commands, and update the comment in
  Verifying tarballs that wrongly claimed preview tarballs don't land at
  the CDN (they do — branch-preview.yaml publishes them to the same bucket).

Why this is safe to relax:
1. The regex still anchors to simple-container-com/api workflows only; an
   attacker cannot publish a malicious tarball under a different repo's
   workflow identity.
2. The OIDC issuer is still pinned to GitHub's token endpoint.
3. Rekor log entry, Sigstore bundle, and tarball SHA-256 sidecar are all
   still verified.
4. Production users default to strict. Picking up a preview build requires
   explicit acknowledgement via env var — there's no implicit promotion of
   any feature-branch identity into the production trust set.

Testing:
- Without env var: preview tarball is rejected with the new helpful message
  pointing at SIMPLE_CONTAINER_ALLOW_PREVIEW=1 (verified against the
  v2026.5.26-pre.4cc1a03-preview.4cc1a03 tarball published 2026-05-19).
- With env var: same tarball verifies and installs cleanly.

Refs PR #277 (the trigger for this fix — needed to validate the new
CloudTrail security alerts plugin schema end-to-end against a preview SC).

Signed-off-by: Dmitrii Creed <creeed22@gmail.com>
@Cre-eD Cre-eD requested a review from smecsia as a code owner May 19, 2026 19:51
@github-actions
Copy link
Copy Markdown

Semgrep Scan Results

Repository: api | Commit: 46556dd

Check Status Details
🚨 Semgrep ERROR 1 error(s), 10 warning(s), 11 total

Scanned at 2026-05-19 19:52 UTC

@github-actions
Copy link
Copy Markdown

Security Scan Results

Repository: api | Commit: 46556dd

Check Status Details
✅ Secret Scan Pass No secrets detected
✅ Dependencies (Trivy) Pass 2 total (no critical/high)
✅ Dependencies (Grype) Pass 0 total (no critical/high)
📦 SBOM Generated 509 components (CycloneDX)

Scanned at 2026-05-19 19:54 UTC

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