Skip to content

Fix public action lookups blocked by organization IP allowlists - #275

Open
dm3ch wants to merge 17 commits into
github:mainfrom
dm3ch:fix/ip-allowlist-public-fallback
Open

dm3ch wants to merge 17 commits into
github:mainfrom
dm3ch:fix/ip-allowlist-public-fallback

Conversation

@dm3ch

@dm3ch dm3ch commented Nov 7, 2026 •

Copy link
Copy Markdown

Fixes #274.

  • --verify on GitHub-hosted runners fails for public actions whose organization has an IP allow list (for example aquasecurity/setup-trivy): GitHub refuses the job token with an HTTP 403 or a GraphQL FORBIDDEN item, so the pin is reported as inaccessible.
  • Those explicit denials now take the existing anonymous public-repository fallback, for REST and GraphQL. Per-alias GraphQL evidence is kept, so unaffected private actions in the same batch stay authenticated. The github.com public client of a *.ghe.com run retries such a denial once without its token.
  • Repository identity, commit/ref, ancestry and action-content checks are unchanged. A repository the anonymous read can't see (private, or a missing ref only an authenticated read could answer) keeps the original denial and fails closed.
  • Only a 403, or a FORBIDDEN item whose own message names the IP allow list, qualifies. Bare messages, ordinary forbidden responses and rate-limit responses do not. SAML/SSO handling is unchanged.
  • An outage or rate limit in the fallback (probe, metadata or read) is reported as retryable, with its reset time, rather than as a final denial. IP-policy diagnostics stay distinct from SAML/SSO and never suggest a token: for a rate-limited fallback they say to wait for the reset or run from an allow-listed address.

Validation (current head):

  • make fmt-check, go vet ./... (also with GOOS=windows) and make test (race) pass locally on macOS. Command tests run --verify under an IP allow list: success from anonymous reads with the lockfile unchanged, fail-closed with IP guidance for a private repository, and a rate-limited fallback. make test-stub was not run on this revision.
  • Hosted: run 44780968351 uses the exact reproduction from Public Aqua action verification fails on GitHub-hosted runners with IP-allowlist 403 #274 (repository). On 3 of 3 GitHub-hosted runners, v0.4.1 fails with the error from the issue and the branch at 799cf0d passes --verify. It has not been re-run on the current head.

P.S. This PR was prepared with LLM assistance.

@dm3ch
dm3ch marked this pull request as ready for review November 7, 2026 18:21
@dm3ch
dm3ch requested a review from a team as a code owner November 7, 2026 18:21
Copilot AI adaptive review requested due to automatic review settings November 7, 2026 18:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Batch-wide handling of a GraphQL IP-policy 403 can force unrelated private actions to retry without authentication, causing spurious 404 failures.

1 open issue
What changed in this PR

Extends gh-actions-lock’s anonymous public-repository fallback to explicit organization IP-allowlist HTTP 403 responses, while retaining repository identity, ref, commit, ancestry, and action-content checks.

Changes:

  • Reuses anonymous fallback across repository, ref, release, and action lookups blocked by IP policy.
  • Distinguishes IP-policy diagnostics from SAML/SSO, including rate-limited fallbacks.
  • Adds hermetic regression coverage for token-free requests, fallback eligibility, and fail-closed behavior.
File Description
internal/​pipeline/​parity.go Adds IP-specific verification remediation.
internal/​pipeline/​parity_test.go Tests plain denials and rate-limited fallback diagnostics.
internal/​ghapi/​tagsource.go Enables policy fallback for releases and commit resolution.
internal/​ghapi/​rest_fallback.go Adds IP-policy detection and policy-aware fallback tracking.
internal/​ghapi/​rest_fallback_test.go Tests denial classification, anonymous action reads, rate limits, and Proxima exclusion.
internal/​ghapi/​repos.go Applies policy fallback to metadata, branch, tag, and comparison reads.
internal/​ghapi/​repos_test.go Tests anonymous ancestry comparisons and failure handling.
internal/​ghapi/​refs.go Enables IP-policy fallback for REST ref reads.
internal/​ghapi/​graphql_reachability_test.go Tests policy attribution when cached metadata precedes a rate-limited fallback.
internal/​ghapi/​graphql_parity_test.go Tests fallback verification verdicts and excluded denial cases.
internal/​ghapi/​brief.go Preserves organization-policy details in concise errors.
internal/​ghapi/​brief_test.go Tests IP-policy and rate-limit error formatting.

Review effort: Max (auto)

Comment thread internal/ghapi/rest_fallback.go Resolved
@dm3ch
dm3ch marked this pull request as draft November 7, 2026 18:37
@dm3ch
dm3ch marked this pull request as ready for review November 7, 2026 19:52
@dm3ch
dm3ch requested an adaptive review from Copilot November 7, 2026 19:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Anonymous fallback rate-limit failures lose diagnostic context, causing --verify to omit the rate-limit explanation and commit/action resolution to drop the originating IP-policy cause.

3 open issues

Review effort: Max (auto)

Comment thread internal/ghapi/graphql_parity.go Resolved
Comment thread internal/ghapi/rest_fallback.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

IP-policy fallback can fail on null GraphQL aliases, while anonymous rate-limit errors lose diagnostic context or receive incomplete recovery guidance.

No open issues 🎉

3 previously missed issues

In code that hasn't changed since last review

Medium severity Preserve batch IP-policy errors for null aliases

internal/​ghapi/​graphql_parity.go:204

A batch-level IP-policy FORBIDDEN error without a path is discarded when an alias is present as null, so the public lookup fails instead of reaching REST fallback. Preserve batchErr for null as well as missing aliases, including after splitting to a single input. Same issue in internal/ghapi/graphql_action_files.go:295.

Medium severity Preserve anonymous rate-limit context in CompareRefs errors

internal/​ghapi/​repos.go:430

If an IP-policy denial is followed by a rate-limited anonymous organization probe, CompareRefs returns the original 403 and loses the reason fallback was skipped. Wrap the error with c.ssoErr(owner, err), as the other REST paths do, so ancestry diagnostics retain the anonymous rate-limit context.

Medium severity Add retry guidance for rate-limited IP-policy fallbacks

internal/​pipeline/​parity.go:711

When an IP-policy fallback is rate-limited, this only recommends using an IP address on the organization's allowlist. For a third-party public action on a hosted runner, waiting for the anonymous limit to reset may be the only available remedy. Give SSORateLimitedError its own reset/retry guidance and update the exact-string expectation in TestParityFinding_RateLimitedIPAllowListFallback.

3 resolved since last review

Review effort: Max (auto)

@dm3ch
dm3ch force-pushed the fix/ip-allowlist-public-fallback branch from b23a0f5 to 799cf0d Compare November 20, 2026 17:10
@dm3ch

dm3ch commented Nov 20, 2026 •

Copy link
Copy Markdown
Author

@nodeselector could you take a look when you have time? This fixes #274.

It is rebased on main, the review findings are addressed, and it is verified on GitHub-hosted runners with the exact reproduction from the issue: v0.4.1 fails and this branch passes on 3 of 3 runners (run).

The workflows on this fork PR need approval to run. If the diff is too large to review at once, I can split it: the REST 403 fallback first, the GraphQL per-alias handling second.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

IP-policy fallback defects can block accessible public actions and misclassify transient or rate-limit failures as non-retryable, discarding retry metadata.

6 open issues

Review effort: Max

Comment thread internal/ghapi/graphql_parity.go Resolved
Comment thread internal/ghapi/repos.go Resolved
Comment thread internal/ghapi/repos.go Resolved
Comment thread internal/ghapi/rest_fallback.go Resolved
Comment thread internal/ghapi/rest_fallback.go Resolved
Comment thread internal/pipeline/parity.go Resolved
- Report a transient failure of the fallback's metadata or probe read
  instead of the final IP allow list denial, so the check stays retryable.
- Keep the rate-limited anonymous response (status, reset headers) in the
  error for IP-policy fallbacks, and treat those as unanswered with
  IP-specific retry advice. SAML handling is unchanged.
- Retry a github.com public client's IP-policy 403 without credentials.
- Treat an anonymous compare 404/422 as a cached false verdict.
- Probe the repository when the requested owner is not an organization,
  so a repository transferred into an IP-restricted organization falls back.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread internal/ghapi/rest_fallback.go Resolved
Comment thread internal/ghapi/rest_fallback.go Resolved
Comment thread internal/pipeline/parity.go Resolved
Comment thread internal/pipeline/parity.go Resolved
- Report probe outages (repository probe 5xx, organization probe transport
  failures) instead of the final IP allow list denial.
- Send eligibility probes without credentials, and tag errors from a
  credential-free retry as anonymous, keeping the IP policy on a rate limit.
- Name no organization in IP allow list guidance: after a transfer the
  requested owner is not the one whose allow list refused the token.
- Move IP-policy retry advice into Finding.MarkRetryable and RetryAdvice so
  every retryable check and the terminal summary agree.
…sitory

Address review of the fallback paths:

- After an IP allow list denial, treat an anonymous 404/422 as a verdict on
  the ref or commit only when the repository's anonymous metadata is
  readable. For a private repository the denial stands, instead of a
  not-found error or a cached "not an ancestor" verdict.
- Clear stale rate-limit and outage markers before each eligibility probe,
  always record the policy that sent a lookup to the fallback, and treat a
  rate-limited credential-free retry as IP policy.
- Give resolver failures and the rate-limit headline IP-specific wording.
- Reset all fallback caches in tests, cover the REST list paths, and fix the
  cancellation test.
A final IP allow list refusal is GitHub's answer, like a 404: only
inconclusive lookups fail the host check. Also cover public repositories
whose missing ref or commit is still a verdict after the fallback.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The IP-policy fallback incorrectly treats authenticated or cached repository metadata as proof of anonymous readability, allowing anonymous 404/422 responses to produce false missing-ref or ancestry verdicts.

4 open issues
2 resolved since last review

Review effort: Max (adaptive)

Comment thread internal/ghapi/rest_fallback.go Resolved
…tadata

Metadata from an authenticated read, or from the cache of one, doesn't show
that the anonymous reads that follow can see the repository. After an IP
allow list denial, take the fallback only when the repository was read
without credentials, and propagate an outage or rate limit of that read.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Mutable owner-wide state can misclassify concurrent IP fallback failures and lose probe errors, while command tests are missing for verification success and anonymous-metadata 404 failure.

2 open issues
4 resolved since last review

Review effort: Max (adaptive)

Comment thread internal/ghapi/graphql_parity.go Outdated
Comment on lines 123 to 124
if ok, failure := c.repoFallback(ctx, pins[i].Owner, pins[i].Repo, s.Err); ok {
states[i] = c.checkPinREST(ctx, pins[i])
Comment thread internal/ghapi/rest_fallback.go Resolved
Owner-wide maps (anonIPBlocked, anonRateLimited, anonProbeFailed) let a
concurrent lookup of the same owner overwrite or clear the evidence of an
in-flight one, mislabeling an IP-policy rate limit as SSO or dropping a
probe outage. Carry which policy refused the token on the lookup's
context, and return probe rate limits and outages to the lookup that made
the probe, so policyFailure reports them. Only definitive answers stay in
anonProbeCache.

Add command tests for --verify under an IP allow list: success from
anonymous reads with an unchanged lockfile, fail-closed with IP guidance
when the repository isn't public, and a rate-limited fallback.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The REST fallback can reuse a SAML-wrapped rate-limit error for an IP-policy denial, causing the pipeline to report an SSO failure instead of a retryable IP-policy limit.

2 open issues
1 resolved since last review

Review effort: Max (adaptive)

Comment thread internal/ghapi/rest_fallback.go Resolved
dm3ch and others added 3 commits November 21, 2026 02:40
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
A rate limit hit by a SAML-refused read is reported as SAML's. Returning it
for a lookup that an IP allow list sent to the fallback turned a retryable
IP-policy limit into an SSO failure.
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.

Public Aqua action verification fails on GitHub-hosted runners with IP-allowlist 403

2 participants