Skip to content

verify-action-build: recognize @actions/http-client JSON helpers as data fetches#790

Merged
dave2wave merged 1 commit intomainfrom
verify-action-build-recognize-json-rpc-helpers
May 2, 2026
Merged

verify-action-build: recognize @actions/http-client JSON helpers as data fetches#790
dave2wave merged 1 commit intomainfrom
verify-action-build-recognize-json-rpc-helpers

Conversation

@potiuk
Copy link
Copy Markdown
Member

@potiuk potiuk commented May 2, 2026

Summary

  • The verify check on Add rubygems/release-gem to allowlist #789 (rubygems/release-gem) failed on a false positive: it transitively scanned rubygems/configure-rubygems-credentials@bc6dd217... (composite action → node20 helper) and flagged two OIDC token-exchange files that POST a JWT to ${server}/api/v1/oidc/... via @actions/http-client's postJson. The response there is a short-lived credential validated through a Zod schema — not a binary or executable.
  • Extends the existing _file_is_pure_data_fetch heuristic (verify-action-build: skip binary-download check for pure data fetches #775) by recognizing the *Json family (postJson / getJson / putJson / patchJson / delJson / requestJson) as data-parse markers. These methods auto-parse the response body as JSON, so reaching for them is an explicit "consume as structured data" signal.
  • The binary-handle gate is unchanged: if the same file also calls tc.extractTar / fs.writeFile / exec.exec / chmod +x / etc., the exemption still does not apply.

Test plan

  • pytest tests/verify_action_build/test_security.py -q — 78/78 pass, including 3 new tests:
    • test_postJson_token_exchange_exempted — mirrors the exact PR Add rubygems/release-gem to allowlist #789 shape (HttpClient.postJson → OIDC exchange).
    • test_getJson_alone_exempts — sibling getJson.
    • test_postJson_with_extract_in_same_file_not_exempt — guard: a getJson next to tc.downloadTool + tc.extractTar keeps both flagged.
  • After merge, re-run the verify check on Add rubygems/release-gem to allowlist #789 and confirm it now passes.

Generated-by: Claude Opus 4.7 (1M context)

…ata fetches

The binary-download check flagged rubygems/configure-rubygems-credentials
(transitively pulled in by rubygems/release-gem) for two OIDC token-exchange
files that use HttpClient.postJson against RubyGems.org. The response there
is a credential, not a binary — the *Json variants of @actions/http-client
auto-parse the body as JSON, so the file is a pure data fetch and should
be exempt under the existing _file_is_pure_data_fetch heuristic.

Adds postJson/getJson/putJson/patchJson/delJson/requestJson to the
data-parse markers, plus three regression tests including the exact
PR #789 shape and a guard test confirming a real binary extraction in
the same file still disables the exemption.
@potiuk potiuk requested a review from dave2wave May 2, 2026 01:08
@potiuk potiuk requested a review from dfoulks1 as a code owner May 2, 2026 01:08
@potiuk potiuk requested review from dfoulks1 and raboof May 2, 2026 01:08
@potiuk potiuk mentioned this pull request May 2, 2026
7 tasks
const url = `${server}/api/v1/oidc/trusted_publisher/exchange_token`
const res = await http.postJson(url, {jwt: webIdentityToken}, {})
return res.result
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the plan to handle each of the OIDC / Trusted publishing actions as they upgrade and fail?

Also, it would be good to think about tagging these as it is important to identify all of the Trusted publishing actions that PMCs are using.

# delJson/requestJson) auto-parse the response body as JSON. Reaching for
# these is an explicit "treat the response as structured data" signal
# — typical of OIDC/RPC token-exchange calls, not binary downloads.
re.compile(r"\.(?:get|post|put|patch|del|request)Json\s*\("),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This handles other generic OIDC token exchanges?

Copy link
Copy Markdown
Member

@dave2wave dave2wave left a comment

Choose a reason for hiding this comment

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

Small incremental changes

@dave2wave dave2wave merged commit 8b890b7 into main May 2, 2026
8 checks passed
@dave2wave dave2wave deleted the verify-action-build-recognize-json-rpc-helpers branch May 2, 2026 15:50
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.

3 participants