fix(security): restrict core-ref to existing tags only#48
Draft
DeepDiver1975 wants to merge 1 commit intomainfrom
Draft
fix(security): restrict core-ref to existing tags only#48DeepDiver1975 wants to merge 1 commit intomainfrom
DeepDiver1975 wants to merge 1 commit intomainfrom
Conversation
Replace the loose character-allowlist validation from the earlier fix with a two-stage check that: 1. Strips an optional refs/tags/ prefix then rejects any remaining slash, blocking branch refs (refs/heads/...) and PR head refs (refs/pull/N/head) which pass character-only validation but point at mutable or attacker-controlled code. 2. Uses git ls-remote --tags to confirm the value resolves to an actual annotated or lightweight tag in owncloud/core, so a caller cannot silently supply a non-existent or branch-shaped ref. Also updates input descriptions to document the tag-only constraint.
375bea8 to
0626f62
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Supersedes #45, which added a character-allowlist check that is insufficient on its own.
The root problem:
core-refis passed directly toactions/checkout'sref:parameter, thenmakeruns against the checked-out code. An attacker who can influence thecore-refvalue can point the checkout at code they control, getting arbitrary execution via the Makefile.Why #45's regex is not enough:
A character-allowlist (
[a-zA-Z0-9._/=-]+) blocks obviously malformed values but still permits:main(mutable — can change under you)refs/pull/9999/head— this is the main attack vector: an attacker opens a PR againstowncloud/corewith a maliciousMakefile, then pointscore-refatrefs/pull/9999/head. GitHub creates this ref automatically for every open PR, no merge required.This PR's fix — two-stage validation:
Slash check after prefix stripping — strips the optional
refs/tags/prefix then rejects any remaining/. This blocksrefs/pull/N/head,refs/heads/branch, and any other full ref path while still accepting short tag names (v10.14.0) and the explicitrefs/tags/v10.14.0form.git ls-remote --tagsexistence check — confirms the value resolves to an actual tag inowncloud/core. This prevents:main) — these have no matchingrefs/tags/mainentry and will failWhat callers need to do
No change for callers already using tag names like
v10.14.0. Callers using branch names or omittingcore-refentirely (defaults to'', which skips validation) are unaffected.Test plan
core-ref: v10.14.0— passes (existing tag, no slash)core-ref: refs/tags/v10.14.0— passes (prefix stripped, tag verified)core-ref: refs/pull/9999/head— rejected at slash checkcore-ref: main— rejected atgit ls-remotecheck (norefs/tags/mainin owncloud/core)core-ref: v99.99.99— rejected atgit ls-remotecheck (tag does not exist)core-ref: ''(default) — validation step skipped entirely🤖 Generated with Claude Code