Repository navigation
fix: every PHP# download and image is verified, and the release pipeline runs only pinned code - #203
Conversation
…ine runs only pinned code The 0.5.0 safety audit found code we ship running on users' machines and servers unverified: - The mago-sharp Composer wrapper extracted and ran the mago archive it downloaded with no integrity check. - Its stream-wrapper download path sent GITHUB_TOKEN to the redirect's host. curl already drops it. - install.sh installed with no verification when gh was missing. - Every third-party action re-resolved a tag or a branch on each run, in workflows that hold contents: write, id-token: write, packages: write and two deploy keys. - The runtime images took their Debian and Go bases by tag, so a new base arrived silently. - No image was CVE-scanned. - The IMAGE job pulled moby/buildkit from Docker Hub anonymously (#86). - mago's fuzz targets never ran, and none parsed PHP#. The release pins every binary, and every image and action is pinned: - release.yml writes mago-<version>-sha256sums.txt into the release. Its new composer job pushes the mirror's tag as the split of sharp/mago plus composer/sha256sums.txt. The wrapper refuses an archive whose SHA-256 differs, and names both hashes. - The stream-wrapper path follows redirects itself and sends the token only with the first request. The curl path sets CURLOPT_UNRESTRICTED_AUTH false explicitly. - install.sh verifies the attestation with gh, or else the SHA-256 in the release's sums file, and says that full provenance needs gh. - Every third-party action is pinned to a commit SHA with its version as a comment, and Dependabot moves them. release.yml's jobs hold only the permissions each needs. - The Dockerfiles pin their bases by digest under a REGISTRY that CI sets to ghcr.io. The new PIN job in base-images.yml opens the pull request that moves the digests. base-images.yml also copies moby/buildkit and docker/buildkit-syft-scanner. - PHP_EXTENSIONS scans each runtime image with Trivy, and fails on a fixable critical or high CVE. - IMAGE builds with our own Buildx steps from those copies after the login, keeps provenance and adds SBOM attestations, and IMAGE_TAGS attests the tagged image. - fuzz.yml runs the lexer, parser and the new sharp_parser target for 10 minutes each every day, and uploads a crashing input. Closes #86. .github/ ├── dependabot.yml new: github-actions SHAs stay current ├── actions/{ccache,freebsd,solaris}/action.yml SHA pins └── workflows/ ├── base-images.yml copies BuildKit and its SBOM scanner; PIN moves digests ├── fuzz.yml new: daily syntax fuzzing ├── release.yml sha256sums asset, composer job, least permissions ├── sharp.yml Trivy scan, own Buildx IMAGE + IMAGE_TAGS, no tag split └── 14 other workflows SHA pins, empty permissions where none are needed sharp/ ├── docker/runtime/{Dockerfile,frankenphp.Dockerfile} REGISTRY, digest-pinned bases └── mago/ ├── composer/src/internal.php checksum check, token sent only to the first host ├── composer/tests/Internal/ new: DownloadTest, ExtractArchiveTest ├── crates/syntax/fuzz/ new sharp_parser target ├── scripts/install.sh checksum verification without gh └── docs/…/installation.md en, fr, zh describe the new verification
The scan PHP_EXTENSIONS now runs failed on the FrankenPHP image. FrankenPHP v1.13.0's frankenphp binary links golang.org/x/net v0.59.0, with HIGH CVE-2026-78669 (an HTTP/2 SETTINGS-frame denial of service), fixed in v0.60.0. The image builds FrankenPHP v1.13.1, which takes golang.org/x/net v0.61.0 and keeps v1.13.0's Go 1.27 and e-dant/watcher pins. sharp/bin/hosts still builds v1.13.0 for HOSTS. sharp/ ├── README.md the runtime image names v1.13.1 └── docker/runtime/frankenphp.Dockerfile FrankenPHP v1.13.1
Review verdict on 4c984e0: changes requiredThe core design holds. The wrapper checks its pinned hash before download and deletes a mismatch, install.sh verifies the attestation or the sums file, every third-party pin matches its version comment (all 28 peeled and checked), the release jobs each hold only the permissions they use, and the Trivy gate fails on fixable critical and high CVEs with every scanner piece pinned. Three findings remain, plus debt to clean in the same round. 1. The images IMAGE publishes are never scanned
2. PIN's daily force-push would strand an open PRBeyond the redesign queued on the task (branch plus issue, no PR from 3. Prove the mirror tag's hashes match what users downloadThe release compares asset names, not contents. Before the Debt, in the same round
|
…ue, and every download is verified - IMAGE scans each pushed digest with the pinned trivy-action on its own platform's runner before the digest is uploaded, so IMAGE_TAGS tags only scanned images. - base-images.yml's PIN pushes one branch per digest set, named from the digests, never moves a pushed branch, and opens or updates one issue that names the old and new digests and links the compare view. It holds contents: write and issues: write only, so "Allow GitHub Actions to create and approve pull requests" stays off. - release.yml's composer job downloads the published assets and checks them and the published sums file against the SHA-256s the run wrote before it pushes the mago-sharp tag. - mago self-update verifies the downloaded archive before extracting it: its build attestation with gh, else its SHA-256 against the release's sums file, refusing a mismatch with both hashes. - frankenphp.Dockerfile fetches FrankenPHP v1.13.1 by commit SHA and checks the e-dant/watcher archive and the install-php-extensions script against pinned SHA-256s. sharp/bin/hosts builds v1.13.1 too, in a folder per release. - sharp.yml's new WORKFLOWS job fails on a third-party uses: without a 40-character SHA, on a # syntax= line under sharp/docker, and on any actionlint finding. .github/actionlint.yaml names php-src's runner labels and leaves out php-src's composite actions' missing descriptions and its two workflows' shellcheck notes. - splitsh-lite installs from one composite action, .github/actions/splitsh-lite. - sharp.yml, release.yml, mago.yml, base-images.yml and fuzz.yml use actions/checkout v7.0.1, actions/cache v6.1.0, actions/upload-artifact v7.0.2 and actions/download-artifact v8.0.2. Dependabot groups minor and patch updates and leaves each major update its own pull request. - re-actors/alls-green's pin comment names v1.3.0, and dwieeb/needs-reply moves to imhoffd/needs-reply. - The sharp_parser fuzz target calls parse_file_with_dialect with Dialect::Sharp, and fuzz.yml seeds it from the .sharp files under Zend/tests/sharp, keeps each target's corpus in a cache, runs nightly-2026-10-13 with -timeout=10, and checks the committed fuzz Cargo.lock.
Closes #86.
The 0.5.0 safety audit found code we ship running unverified on users' machines and servers. This PR verifies every
magodownload and pins every image and third-party action the release pipeline runs.Gaps and fixes
The
mago-sharpComposer wrapper ran a downloaded binary with no integrity check.release.ymlwritesmago-<version>-sha256sums.txtinto the release. Itscomposerjob downloads every published asset and checks it, and the published sums file, against the SHA-256s the run wrote. Only then does it push theheyJordanParker/mago-sharptag: the split ofsharp/magoplus a commit that adds those SHA-256s ascomposer/sha256sums.txt.extract_archiverefuses an archive whose SHA-256 differs. Its error names the expected and the actual hash, and it deletes the archive.sharp.yml'sCOMPOSERjob pushes only branches of the mirror.The wrapper's stream-wrapper path sent
GITHUB_TOKENto the redirect's host. The newDownloadTestredirects 127.0.0.1 to localhost. Before this PR, localhost receivedBearer <token>fromdownload_with_fopen, and none from curl (libcurl 8.18.0).download_with_fopennow follows each redirect itself, and only the first request carries the token.download_with_curlsetsCURLOPT_UNRESTRICTED_AUTHto false explicitly, with a comment that curl 7.58.0 and later already drop the header.mago self-update's ureq 3.4.1 drops it too: itsredirect_auth_headersdefaults toNever.install.shandmago self-updateinstalled with no verification. Both now verify the archive before they extract it. Withgh, they verify its build attestation, signed byrelease.yml. Withoutgh, they check it againstmago-<version>-sha256sums.txt, refuse a mismatch with both hashes, and say that full provenance needsgh.install.sh --no-verifyis still the only opt-out. A release that publishes no sums file, 0.5.0 and earlier, updates only withgh.Third-party actions were pinned to tags or branches. Every third-party
uses:in.github/workflowsand.github/actionsnames a 40-character SHA with its release as a comment.sharp.yml,release.yml,mago.yml,base-images.ymlandfuzz.ymluse one version of each action:actions/checkoutv7.0.1,actions/cachev6.1.0,actions/upload-artifactv7.0.2 andactions/download-artifactv8.0.2. The upstream php-src workflows keep upstream's versions..github/dependabot.ymlmoves the SHAs weekly, with a 7-day cooldown, grouping minor and patch updates and leaving each major update its own pull request.sharp.yml's newWORKFLOWSjob fails on a third-partyuses:without a full SHA, so an unpinned action can't come back. Every workflow and job holds the leastpermissionsit uses.The runtime images took their base by tag. Both Dockerfiles pin
BASE_IMAGEby digest as${REGISTRY}/debian:trixie-slim@sha256:…, andfrankenphp.DockerfilepinsGOLANG_IMAGEtoo.REGISTRYdefaults to ECR Public, and CI sets it toghcr.io/heyjordanparker.base-images.yml'sPINjob is the one thing that moves the digests. When a copy has a new digest, it pushes a branch named from the new digests, never moves a branch it pushed, and opens or updates one issue that names the old and new digests and links the compare view. An Agent opens the pull request from that issue, so its CI runs.PINholds onlycontents: writeandissues: write, so "Allow GitHub Actions to create and approve pull requests" stays off.No image was CVE-scanned.
aquasecurity/trivy-actionv0.36.0 (ed142fd0) runs Trivy v0.76.1 and fails on a critical or high CVE that a fixed package resolves.PHP_EXTENSIONSscans each image it builds.IMAGEscans each platform's pushed digest on its own runner before it uploads the digest, soIMAGE_TAGStags only scanned images,linux/arm64included. On 2026-03-19, attackers force-pushed 76 of trivy-action's 77 tags to malware (GHSA-69fq-xp46-6x23). v0.35.0 and later are immutable releases, v0.36.0 pins its ownsetup-trivyby SHA, and Trivy 0.71.1 and later fix GHSA-mcj4-mphf-j9ff. The first scan found HIGH CVE-2026-78669 in FrankenPHP v1.13.0'sgolang.org/x/netv0.59.0, so the image andsharp/bin/hostsboth build FrankenPHP v1.13.1.#86: the IMAGE job pulled
moby/buildkitfrom Docker Hub anonymously.docker/github-builderis replaced by our own steps.IMAGEbuilds each Dockerfile on a runner of each platform's own architecture. Each build logs in to ghcr.io first, then sets up Buildx withghcr.io/heyjordanparker/buildkit:v0.34.1at a pinned digest. It builds the tagged commit by SHA and pushes by digest, with BuildKit'smode=maxprovenance and an SBOM fromghcr.io/heyjordanparker/buildkit-syft-scanner:1.12.0.IMAGE_TAGStags the two platform images as<version>and<version>-frankenphp, and attests the image withactions/attest-build-provenance(push-to-registry).frankenphp.Dockerfilehas no# syntax=line, whose frontend BuildKit pulls from Docker Hub with no login. A comment says so where it was, andWORKFLOWSfails on one undersharp/docker.The FrankenPHP image downloaded its sources by tag and URL.
frankenphp.Dockerfilefetches FrankenPHP v1.13.1 by the commit its tag names,99d4e119, and checks the e-dant/watcher 0.14.5 archive and the install-php-extensions 2.12.0 script against pinned SHA-256s. The script's SHA-256 is the digest GitHub records for that release asset.mago's fuzz targets never ran. The new
sharp_parsertarget parses its input withparse_file_with_dialectinDialect::Sharp.fuzz.ymlrunslexer,parserandsharp_parserevery day for 10 minutes each, onnightly-2026-10-13, with-timeout=10. It keeps each target's corpus in a cache between runs, seedssharp_parserfrom the 521.sharpfiles underZend/tests/sharptoo, and checks the committed fuzzCargo.lock. It fails on a crash and uploads the crashing input.CI never ran actionlint.
WORKFLOWSinstalls actionlint v1.7.12 from its release archive at a pinned SHA-256 and runs it over every workflow..github/actionlint.yamlnames php-src'sgentooandppc64runner labels, and leaves out php-src's composite actions' missingdescription. It also leaves out the shellcheck notes of php-src'stest-suite.ymlandreal-time-benchmark.yml, kept as php-src writes them so they merge.sharp.yml's five shellcheck notes are fixed withshellcheck disablecomments that say why each word splits.splitsh-liteinstalls from one composite action,.github/actions/splitsh-lite.re-actors/alls-green's comment namesv1.3.0, the tag its SHA is, anddwieeb/needs-replymoves to its new name,imhoffd/needs-reply, at the same SHA.Needs the Architect
base-images.ymlrun createsghcr.io/heyjordanparker/buildkitandghcr.io/heyjordanparker/buildkit-syft-scanner.IMAGElogs in before it pulls them, so they work private.docker/github-buildersigned its attestation manifests with cosign. The new jobs attest with GitHub's Sigstore instead, the same way themagoarchives are attested. The SBOM is new: the 0.5.0 image carried none.Verification run locally
phpunit --configuration composer/phpunit.xml: 142 tests OK. Against the real v0.5.0 release, a pinned0000…failed withhas SHA-256 35f75d71…, and heyjordanparker/mago-sharp pins 0000… for it, and nothing was extracted. The real hash printedmago 0.5.0.download_with_fopensentBearer <token>to localhost. After,first host: Bearer redirect-test-token, redirect host: nonefor both paths.gh: a matching archive installed, and a tampered one failed withCHECKSUM VERIFICATION FAILED, naming both hashes.cargo test -p mago --bin mago: 110 passed, among thema_tampered_archive_is_refused_with_its_sha256_and_the_one_the_sums_file_names. Withgh,self-update --tag 0.4.2printedAttestation verified.and the binary printedmago 0.4.2. Withoutgh, it refused, because 0.4.2 publishes nomago-0.4.2-sha256sums.txt, and the binary still printedmago 0.5.0.run:scripts, read frombase-images.yml, ran in a Debian container against a local origin, the realskopeoand a stand-ingh. The first run pushedbase-images/debian-trixie-slim-62bd423aeee9-golang-1.27-trixie-fbb7ae40b62fand created the issue. The second found the branch, left it at the same commit, and edited issue 7. The realgh issue list --search 'in:title "…"' --jq 'map(select(.title == env.TITLE))…'found issue The release image job still pulls moby/buildkit anonymously from Docker Hub #86 by its exact title.composerjob's step passed on matching assets, and failed on a replaced asset and on a different sums file..github/workflows/mago.yml:343: uses: actions/checkout@v7with one unpinneduses:, and nothing on this branch. The# syntax=check printed the line added tofrankenphp.Dockerfile, and nothing on this branch.TRIVY_PLATFORM=linux/arm64scanned the arm64 image of the 0.5.0 index, attestations and all, andlinux/amd64the amd64 one.frankenphp.Dockerfilebuilt from this commit's tree with--build-arg REGISTRY=ghcr.io/heyjordanparker. The build fetchedfrankenphp.git#99d4e119…, printed/tmp/watcher.tar.gz: OKand/usr/local/bin/install-php-extensions: OK, and the image printedFrankenPHP 1.13.1 PHP 8.5.12. Trivy v0.76.1 found 0 fixable critical or high CVEs in its Debian packages and itsfrankenphpbinary, and the default command served HTTP 200. The fpmDockerfilechanged only in a comment, and it built at the pinned digest on 4c984e0.cargo fuzz run sharp_parser … -- -max_total_time=60 -timeout=10 -seed_inputs=@…onnightly-2026-10-13:Done 55016 runs in 61 second(s), with no crash. The seed list alone loadedseed corpus: files: 520.Annotated file tree