Skip to content

fix(ci): pin actions by SHA, least-privilege tokens, digest-pinned builder - #14

Merged
Jerry-CodeHub merged 1 commit into
masterfrom
fix/workflow-hardening
Sep 23, 2026
Merged

Jerry-CodeHub merged 1 commit into
masterfrom
fix/workflow-hardening

Conversation

@Jerry-CodeHub

Copy link
Copy Markdown
Owner

背景

审计 2026-09-22 M-3 + M-4 + L-1:

  • 4 个 GitHub Action 全部 tag 引用未钉 commit SHA,其中 peaceiris/actions-gh-pages 持有写权限的 GITHUB_TOKEN 且上游维护长期停滞——tag 被移动即攻击者代码在特权上下文执行(可篡改 gh-pages 内容,对访客构成存储型攻击面)
  • 两个 workflow 未声明 permissions:,GITHUB_TOKEN 依赖仓库宽松默认(read+write)
  • Dockerfile builder 阶段 node:22-alpine 浮动标签(运行镜像钉了 digest,但产物 dist 由 builder 产出——信任链实际未闭合);ARG→ENV 把 token 持久化进 builder 层 history

改动

  • 4 个 action 全部钉 full commit SHA(注释保留版本号):checkout@v7.0.1 / setup-node@v7.0.0 / pnpm/action-setup@v6.1.0 / peaceiris/actions-gh-pages@v4.1.0
  • 显式最小权限:ci.yml → contents: read;deploy.yml → contents: write(推 gh-pages 的最小集)
  • 新增 .github/dependabot.yml(github-actions + npm,weekly):SHA 钉固后的升级经 PR 显式过目,避免钉死即过期的另一个极端
  • Dockerfile:builder 钉 digest(与运行阶段同等待遇);删除无意义的 ENV CESIUM_ION_TOKEN(ARG 在 RUN 中本就可见,ENV 只留 history 痕迹)

验证

  • 三个 YAML 语法校验通过;SHA 经 gh api repos/<owner>/<repo>/commits/<tag> 逐一核实
  • docker build 本地未验证(daemon 不可用),由 CI 兜底;pnpm check 全绿

@coderabbitai

coderabbitai Bot commented Sep 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 48ae4ead-a3e6-4d74-ba8b-9c694e838561

📥 Commits

Reviewing files that changed from the base of the PR and between 8e537c4 and 78581ef.

📒 Files selected for processing (4)
  • .github/dependabot.yml
  • .github/workflows/ci.yml
  • .github/workflows/deploy.yml
  • Dockerfile

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying umi-react-admin with  Cloudflare Pages  Cloudflare Pages

Latest commit: 78581ef
Status: ✅  Deploy successful!
Preview URL: https://0fe034be.umi-react-admin.pages.dev
Branch Preview URL: https://fix-workflow-hardening.umi-react-admin.pages.dev

View logs

@Jerry-CodeHub
Jerry-CodeHub merged commit 8832854 into master Sep 23, 2026
5 checks passed
@Jerry-CodeHub
Jerry-CodeHub deleted the fix/workflow-hardening branch September 23, 2026 02:35
…ilder

- all four actions pinned to full commit SHAs (version kept as comment);
  peaceiris/actions-gh-pages holds a write-capable GITHUB_TOKEN and its
  upstream is dormant, so a moved tag there meant attacker-controlled
  code in a privileged context - a SHA makes tag moves inert
- explicit permissions blocks: ci.yml contents:read, deploy.yml
  contents:write (the minimum for pushing gh-pages), instead of
  inheriting the repo-wide read+write default
- dependabot for github-actions and npm keeps the pins upgradable via
  reviewable PRs instead of silent tag drift in the other direction
- Dockerfile: builder stage pinned to a digest like the runtime stage
  (a pinned runtime image provides no guarantee when the layer that
  produces dist/ floats), and the token ARG no longer leaks into the
  builder image history via a pointless ENV line

docker build verification deferred to CI (local daemon unavailable);
YAML syntax validated locally
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