Skip to content

ci: publish to the CDN only what the release job built (SECOPS-1259) - #576

Merged
somanshreddy merged 3 commits into
mainfrom
11-16-ci_bind_cdn_publish_to_the_built_release
Nov 16, 2026
Merged

somanshreddy merged 3 commits into
mainfrom
11-16-ci_bind_cdn_publish_to_the_built_release

Conversation

@somanshreddy

@somanshreddy somanshreddy commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Scope

Surfaces: CI (release workflow), CDN installer | Module: Release

Summary

The CDN publish step now publishes only what the same run's release job built, and it never moves the CDN to an older version. Live on merge, with no change to a normal release.

How it works

  • The release job records the commit, the release ID and a hash of checksums.txt. The CDN job checks out that commit, downloads that release, and verifies the files against the recorded hash before uploading anything.
  • Before uploading, the CDN job refuses a version older than the one the CDN serves, and refuses to replace a version that is already published with different files. Re-running the job for the live version still works, so a failed upload can be retried.
  • RELEASE.md explains what each refusal means.

Details are in the linked SecOps issue.

Testing

  • Ran the new scripts against the real v0.11.0 release and the live CDN. The correct inputs pass. A wrong hash, a mismatched release, an older version and changed files are each refused before any upload. A retry of the live version passes.
  • actionlint (with shellcheck) passes, and shellcheck passes on the new scripts.

🤖 Generated with Claude Code

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE. Reviewed at d2f6f98720b869859219e2034612462891f0aae8 (stacked on #575 at 368a09cc; ancestry checked).

publish-cdn is now bound to the release job's own output: it checks out the built commit, confirms the tag still peels to that commit, downloads the recorded release by ID, requires checksums.txt to hash to the digest recorded in the release job, downloads only the archives that file lists, and refuses a rollback. Job outputs can't change after the job ends, and "Re-run failed jobs" reuses the original outputs, so a later edit to the release, its assets or its tag fails closed.

The rollback check: I ran it against the live CDN (CDN_BASE=https://static.heygen.ai/cli, which serves v0.11.0, using the real checksums.txt from the v0.11.0 release):

tag checksums result
v0.11.0 (retry of live) real publishing v0.11.0, rc=0
v0.10.0 real refused: "already serves v0.11.0, newer", rc=1
v0.12.0 any 403, so treated as new; publishing, rc=0
v0.11.0 one byte changed refused: "already on the CDN with different files", rc=1

A retry of the live version passes. A retry after a partial upload (archives up, pointer not flipped) also passes, because checksums.txt returns 200 and matches. Network errors and non-200/403/404 statuses fail closed: under set -e the curl assignment exits, and the *) branch refuses. git ls-remote origin 'refs/tags/<tag>^{}' returns the peeled line for annotated tags (checked on v0.11.0). A lightweight tag has no ^{} line, so tagged comes back empty and the step fails closed.

Can a 403 be induced to skip the "different files" guard? Only narrowly. The CDN is CloudFront in front of S3 (x-cache: Error from cloudfront on a miss), and CloudFront caches 4xx responses for a short window by default. Someone requesting releases/<tag>/checksums.txt just before it exists could prime a 403 that hides the real object from the check for a few seconds. To get anything out of that, a writer would also have to delete a published tag, re-dispatch the same version and hit the window. Even then, what gets uploaded is still a build of a commit on main that descends from the last stable release, so this is an integrity gap, not a way around review. Non-blocking. If you want it race-free without giving the role bucket read access, upload checksums.txt first with aws s3api put-object --if-none-match '*' (S3 conditional write, needs only PutObject). On a 412, fall back to today's CDN cmp; the object definitely exists then, so a 403 there should refuse.

Nits (non-blocking):

  1. Leading zeros alias a version. v0.11.00 passed the check above against live v0.11.0, and sort -V ranks 0.11.00 above 0.11.0. The workflow's own validation accepts it too. It still only ships reviewed main code, so this is version confusion, not a bypass. Suggested pattern for the validate step and both scripts:
    ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$
    
  2. The stable read can be up to 60s stale (max-age=60). The concurrency group already serializes runs and re-runs, so a stale pointer only matters within a minute of another publish. Fine as is.

Follow-up (pre-existing, not this PR): workflow_dispatch can run this workflow from any branch, using that branch's copy of the file. Against someone with write access, every check here holds only as far as the AWS role's OIDC trust policy restricts who can assume it: pinned to ref:refs/heads/main, or to a protected environment with required reviewers. Worth confirming the trust policy does that. If it doesn't, an environment: with required reviewers on publish-cdn is the smallest fix.

Need: yes, the CDN job trusted whatever the tag and release held when it ran · Size: ok · Reuse: GoReleaser's own checksums.txt as the manifest, no new format · Simpler: already minimal; the two scripts each do one job · Structure: fine (checked the existing find-run-draft.sh and cleanup-failed-release.sh script pattern; no split)
Risk: medium — gates the public installer and stable pointer; every new check fails closed.

— Rames

@somanshreddy
somanshreddy force-pushed the 11-16-ci_bind_cdn_publish_to_the_built_release branch from d2f6f98 to 888e813 Compare November 16, 2026 00:40

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE (re-review). Reviewed at 888e813034b4ac7c308c5c63c105b6902b72bfa8, stacked on #575 at 06db8dc (ancestry checked).

Delta since d2f6f987: git range-diff shows the restacked CDN commit b2624c8 is patch-identical to d2f6f98 (1: d2f6f98 = 1: b2624c8). The one new commit 888e813 only tightens the version regex in check-cdn-publish.sh (on both the tag and the CDN's current pointer) and in download-release-assets.sh.

Re-ran the rollback check at this head against the live CDN (serving v0.11.0):

tag result
v0.11.0 (retry of live) publishing, rc=0
v0.11.00 refused: "not a stable release tag", rc=1 (round 1: passed)
v0.10.0 refused as rollback, rc=1

Tightening the regex on the stable read also fails closed: if the pointer ever held a leading-zero value, the job would stop rather than compare it. The conditional-write follow-up for the cached-403 window is noted as a follow-up and stays non-blocking.

Need: yes · Size: ok · Reuse: nothing to reuse · Simpler: already minimal · Structure: fine (checked the round-1 patterns in both scripts; no split)
Risk: medium — gates the public installer; this delta only narrows accepted input.

— Rames

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

APPROVE (re-review). Reviewed at 0c4ee660d6bc6f344785eb28f5d4a2a241652088. The delta since my approval at 888e8130 is one commit (ahead 1, behind 0), so the base is still #575 at 06db8dc.

The rollback check now reads S3 instead of CloudFront, which closes the cached-pointer and cached-403 window I raised.

Checked:

  • The listing logic, run against the real bucket. I ran the exact list-objects-v2 … --query "length(Contents[?Key=='…'] || \[]`)"read-only againstheygen-public`:

    • v0.11.0 gives 1.
    • v9.9.9 gives 0. An empty listing has no Contents, and the || [] turns that into 0.

    aws s3 cp s3://heygen-public/cli/stable - returns v0.11.0.

  • The exact-key filter matters. --prefix alone would also match keys like checksums.txt.bak, and the Key== filter keeps only the manifest. The tag is regex-validated before it reaches the JMESPath string, so nothing can break out of the quotes.

  • It fails closed. Under set -euo pipefail, a failing aws s3 cp … | tr or list-objects-v2 inside the command substitution stops the step. If listing were denied, the result would be a blocked release, not a skipped check. Any value other than 0 or 1 also refuses.

  • Listing over fetching is the right call. Without list access on the key, S3 answers a missing-object GET with 403, so deciding "absent" from a 403 would be exactly the ambiguity that was here before.

  • Step order: the check now runs after Configure AWS credentials, which it needs, and still runs before any upload. The upload paths now use the same S3_CLI_PREFIX, so the place checked and the place written can't drift apart.

  • What remains of the race: S3 is strongly consistent and the stable-release concurrency group serializes runs and re-runs. The only gap left is a writer with direct bucket credentials, which is out of scope.

Nit (non-blocking): the two refusal messages still say "already on the CDN" while the check now reads the bucket. They mean the same thing to the person reading them, so this is optional.

Need: yes · Size: ok · Reuse: reuses the job's existing role and aws CLI, with no new tooling · Simpler: already minimal · Structure: fine (checked the upload step's paths; one prefix variable now drives both)
Risk: medium — gates the public installer; every new path fails closed.

— Rames

Base automatically changed from 11-16-ci_pass_release_version_through_env to main November 16, 2026 01:15
@somanshreddy
somanshreddy force-pushed the 11-16-ci_bind_cdn_publish_to_the_built_release branch from 0c4ee66 to c40538e Compare November 16, 2026 01:15
@somanshreddy
somanshreddy merged commit 113465a into main Nov 16, 2026
9 of 10 checks passed
@somanshreddy
somanshreddy deleted the 11-16-ci_bind_cdn_publish_to_the_built_release branch November 16, 2026 01:27
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.

2 participants