Skip to content

feat: add php 8.1.34 alpine3.22 build from ghcr base - #4

Merged
hoangbh-0986 merged 3 commits into
masterfrom
feat/php-8.1.34-alpine3.22
Oct 28, 2026
Merged

hoangbh-0986 merged 3 commits into
masterfrom
feat/php-8.1.34-alpine3.22

Conversation

@hoangbh-0986

@hoangbh-0986 hoangbh-0986 commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Why

php-dev:8.1-* runs PHP 8.1.9, which is vulnerable to CVE-2026-109618 and CVE-2026-109619 (PHP2Shell, unauthenticated RCE). sun-asterisk-research/docker-php#6 published patched php:8.1.34-*-alpine3.22 images. This PR builds the CI image for 8.1 on top of them, so app CI can run the same PHP and phpredis as production.

What changes

  • New versions_8.1.yml builds 8.1/alpine3.22 from ghcr.io/sun-asterisk-research/php:8.1.34-nginx-alpine3.22, pinned by digest (sha256:52414238…e998). 8.1.9 is dropped from versions.yml.
  • New keys in the versions files:
    • base_image is required.
    • base_image_sha256 is required with exact_tags_only.
    • exact_tags_only publishes only 8.1.34-alpine3.22.
    • dockerhub_push: false drops the Docker Hub step.
    • platforms limits the build to linux/amd64.
  • 19 tags stop being rebuilt and keep their current digests:
    • latest, alpine, bullseye and buster.
    • alpine3.15, alpine3.16 and 8-alpine3.15.
    • The 8.1 and 8.1.9 families.
  • 8 is still built from 8.2.
  • Makefile fixes:
    • The clean loop was missing ls, so it never ran. It runs now.
    • A failing versions file now stops make instead of being masked.
    • Every versions file is validated before anything is cleaned.
    • A sha256:-prefixed digest is rejected with a clear message.
  • The 8.1 workflow declares its token permissions, the same way docker-php does: contents: read at the top level, and contents: read plus packages: write on the docker job.
  • The other versions keep their output. Their workflows only gain if: true on the Docker Hub steps, and they trigger on <minor>/** only, so they do not run.

Verification (local, linux/amd64)

  • make all leaves a clean git status on two consecutive runs, under both mawk (ubuntu:24.04) and gawk.
  • Image checks:
    • PHP is 8.1.34 and Composer is 2.4.1.
    • xdebug and pcov are loaded.
    • After docker-php-ext-disable xdebug, xdebug is gone and pcov remains.
  • A Laravel 8.83.23 Redis check (cache, lock, queue, session) gives the same result in this image (phpredis 6.3.0) as in the current production image, laravel-base 8.1.14 with phpredis 5.3.7, apart from version fields.
  • 18 invalid versions files are rejected, both directly and through make all, and no generated file is removed.

Notes

  • This branch's CI run pushes 8.1.34-alpine3.22, and the merge pushes it again. CI consumers must pin the digest from the master run, not the tag.
  • xdebug and pcov come from pecl unpinned, as before, so each rebuild can pick up newer releases.
  • This is the first Actions run in this repo since February 2023. A denied on the ghcr push would mean the package does not grant this repo write access.

Build 8.1 from ghcr.io/sun-asterisk-research/php:8.1.34-nginx-alpine3.22
pinned by digest, via a dedicated versions_8.1.yml: one exact tag
(8.1.34-alpine3.22), linux/amd64 only, no Docker Hub step. 8.1.9 is
dropped from versions.yml.

Generator: new base_image, base_image_sha256, exact_tags_only and
dockerhub_push keys, validated before anything is written or removed.
base_image is required, and base_image_sha256 is required when
exact_tags_only is true. Other versions keep their output; their
workflows only gain 'if: true' on the Docker Hub steps.

Makefile: fix the clean loop (missing ls) so make all removes stale
version directories, stop on the first failing versions file instead of
masking it, and validate every versions file before cleaning.
Exact-tag builds publish to ghcr with GITHUB_TOKEN, so the 8.1 workflow now declares read-only contents at the top and packages: write on the docker job instead of relying on the org default.
@hoangbh-0986

Copy link
Copy Markdown
Contributor Author

🚫 Chặn merge: push lên branch nào cũng ghi đè được tag 8.1.34-alpine3.22 trên ghcr, không cần qua review

Vấn đề

  • Trigger push trong ci.yml.template:7 không lọc branch.
  • Bước GHCR build and push đẩy image lên mỗi khi github.event_name == 'push' (.github/workflows/8.1.yml:84).
  • PR này cấp thêm packages: write cho job docker (.github/workflows/8.1.yml:37-39).

Ghép ba điểm trên lại: ai có quyền push vào repo cũng đẩy được image lên đúng tag mà CI của các app sẽ kéo về. master có branch protection cũng không chặn được, vì việc publish chạy ngay trên branch.

Đã xảy ra ngay trên PR này: run 40620892538 (event push, branch feat/php-8.1.34-alpine3.22) đã đẩy ghcr.io/sun-asterisk-research/php-dev:8.1.34-alpine3.22@sha256:c61c006265b0b5040a6ab0745ee9969acbd0cb555a1b2b0713dbbaec11af5e93 từ code chưa merge.

Vì sao chặn merge

  • PR này làm ra để vá lỗi RCE, và comment ở generate.sh:221 gọi đây là tag "immutable". Thực tế tag bị ghi đè mỗi lần có ai push lên một branch đụng tới 8.1/**.
  • Job CI của app thường có secret (DB, token deploy…). Một image chưa qua review chạy trong đó là đường tấn công chuỗi cung ứng.
  • Ghi chú "pin digest từ run của master" trong mô tả PR không ép được ai làm theo, mà người dùng cũng không có chỗ nào để tra digest đó.

Gợi ý sửa (sửa template rồi chạy lại make all):

# ci.yml.template
on:
  pull_request:
    paths:
      - {{ php_minor }}/**
  push:
    branches:
      - master
    paths:
      - {{ php_minor }}/**

Nếu chưa muốn đổi hành vi của 7.3/7.4/8.0/8.2, có hai cách:

  • Chỉ sinh branches: [master] khi exact_tags_only: true, làm giống cách đang sinh workflow_permissions.
  • Đổi điều kiện push thành ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}.

Sau khi merge, run trên master sẽ ghi đè lại tag. Nên ghi digest của run đó vào README hoặc release note để người dùng có chỗ pin.

@hoangbh-0986
hoangbh-0986 merged commit 90d4123 into master Oct 28, 2026
4 checks passed
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