github / github/codeql

Unpinned floating tags (e.g. `v4`) on immutable Actions are not flagged by `actions/unpinned-tag`

未關閉
#22,414 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
CodeQL
星號
10.1k
分支
2.1k
平均合併
2 天 18 小時
30 天內合併 PR
152

描述

**Description of the issue**

The `actions/unpinned-tag` query (`actions/ql/src/Security/CWE-829/UnpinnedActionsTag.ql`) exempts any Action on the immutable-actions allow list from the unpinned-tag warning, regardless of the ref used. The exclusion is version-independent:

```ql
not exists(UsesStep step | uses = step and isImmutableAction(step, nwo))
```

and `isImmutableAction` (`actions/ql/lib/codeql/actions/security/UseOfUnversionedImmutableAction.qll`) only checks membership in `immutableActionsDataModel(nwo)`; it never inspects the version.

**Why this is a gap**

GitHub's immutability guarantee only applies to fully-expanded SemVer release tags (`vX.Y.Z`) and full commit SHAs. Floating tags such as `v4`, `v4.0` and `main` remain mutable: maintainers move them to the latest matching release, so they can change under a consumer exactly like any other tag. See [Using immutable releases and tags to manage your action's releases](https://docs.github.com/en/actions/how-tos/create-and-publish-actions/using-immutable-releases-and-tags-to-manage-your-actions-releases).

As a result, a reference like `actions/checkout@v2` is flagged by neither query:

- `UnpinnedActionsTag` skips it because `actions/checkout` is on the immutable list.
- `UnversionedImmutableAction` skips it because its `isSemVer` predicate accepts a bare major tag like `v2`.

So a genuinely mutable floating tag on an immutable Action goes unwarned.

**Suggested direction**

Narrow the exemption so an immutable Action is only exempt when pinned to a full `vX.Y.Z` (or a SHA), for example:

```ql
not (isImmutableAction(step, nwo) and isFullSemVer(version))
```

with an `isFullSemVer` stricter than the current `isSemVer` (which also matches floating `vX` and `vX.Y`). This would need care because the immutable-action model is shared with the experimental `UnversionedImmutableAction` query, and it would increase alert volume for consumers pinning immutable Actions to floating major tags, so it deserves its own change note and review.

Filed as a follow-up to #22409 (which is scoped to the trusted-owner allow list and does not address this).

貢獻指南

開啟貢獻指南

研究方向

閱讀 actions/ql/src/Security/CWE-829/UnpinnedActionsTag.ql 和 actions/ql/lib/codeql/actions/security/UseOfUnversionedImmutableAction.qll,從 isImmutableAction 和現有的 SemVer predicate 開始。完成的標準是:完整的 vX.Y.Z 標籤和完整的 SHA 仍維持豁免,而 vX 和 vX.Y 等浮動參照會被回報,並包含所需的變更說明。

由索引模型根據 Issue 內容生成。

評估

領域
security
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
活躍
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。