Repository navigation
ci: publish to the CDN only what the release job built (SECOPS-1259) - #576
Conversation
jrusso1020
left a comment
There was a problem hiding this comment.
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):
- Leading zeros alias a version.
v0.11.00passed the check above against livev0.11.0, andsort -Vranks0.11.00above0.11.0. The workflow's own validation accepts it too. It still only ships reviewedmaincode, 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]*)$ - The
stableread 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
d2f6f98 to
888e813
Compare
jrusso1020
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.0gives1.v9.9.9gives0. An empty listing has noContents, and the|| []turns that into0.
aws s3 cp s3://heygen-public/cli/stable -returnsv0.11.0. -
The exact-key filter matters.
--prefixalone would also match keys likechecksums.txt.bak, and theKey==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 failingaws s3 cp … | trorlist-objects-v2inside the command substitution stops the step. If listing were denied, the result would be a blocked release, not a skipped check. Any value other than0or1also 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 sameS3_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-releaseconcurrency 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
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
0c4ee66 to
c40538e
Compare
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
checksums.txt. The CDN job checks out that commit, downloads that release, and verifies the files against the recorded hash before uploading anything.RELEASE.mdexplains what each refusal means.Details are in the linked SecOps issue.
Testing
actionlint(with shellcheck) passes, and shellcheck passes on the new scripts.🤖 Generated with Claude Code