Skip to content

Verify WinAppCli release downloads before extraction - #49

Merged
Alexandre Zollinger Chohfi (azchohfi) merged 5 commits into
mainfrom
azchohfi-verify-release-downloads
Nov 3, 2026
Merged

Alexandre Zollinger Chohfi (azchohfi) merged 5 commits into
mainfrom
azchohfi-verify-release-downloads

Conversation

@azchohfi

@azchohfi Alexandre Zollinger Chohfi (azchohfi) commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Dependency and scope

Layer 2 of the three focused Glasswing remediation PRs; depends on #48 and targets azchohfi-validate-release-versions, not main. Synced onto its final parent 1ced5c611d4462a4f70172b3869e82be12cbbd19, preserving the release-version whitelist, raw-input validation, architecture/platform restrictions, validation cases, and version-input documentation. Build-gate workflow changes remain excluded and belong in layer 3.

Report finding Assessment Changes in this PR
CWE-494 — download without integrity verification (60ddfb9f-a520-4e4d-b808-be96cf710dce) Missing verification is real. Mutable latest can be verified by resolving a concrete release and checking its digest. Resolve a validated release tag and architecture-specific official SHA-256 digest; stream-hash the ZIP before extraction; support independently pinned digests in both integrations.

Changes

  • Add optional 64-hex sha256 inputs, with one shared verification implementation. A specific version plus caller pin skips metadata lookup; latest plus a pin also checks the resolved metadata digest.
  • Request only the official public GitHub release API with fixed headers, rejected redirects, and a 30-second request/body deadline. Validate unknown metadata shape, safe tag, exact requested-tag match, architecture-specific asset, and digest. All metadata/HTTP/JSON/download/digest errors fail closed without a verification bypass.
  • Preserve each integration's original proxy/bypass matching. Azure metadata transport applies agent proxy credentials, CA/client certificate settings, and bypass rules; environment fallback reuses the existing toolkit matcher. Explicit Basic proxy auth supports partial and percent-encoded credentials. Destroy one-use dispatchers so stalled CONNECT requests cannot extend the metadata deadline.
  • Add optional secret github-token inputs, used only for official API metadata and never for ZIP downloads. Actions defaults to the workflow token only on github.com; GitHub Enterprise defaults empty and may explicitly provide a public token. Report exhausted rate-limit headers without logging credentials.
  • Download to an explicit ZIP path inside owned staging and clean it even if the downloader rejects without returning a path. Extract into a separate child so the ZIP is never installed. Replace the managed copy with the newly verified installation; do not silently reuse an unverified executable. Azure cleanup retries asynchronous removal while installation replacement remains synchronous.
  • Document trust limits: official API digests detect corrupt/substituted archives, not compromise of both official assets and metadata. An independently obtained caller pin is the stronger trust anchor.
  • Regenerate both shipped bundles with unchanged build.mjs. Declare already-locked undici and toolkit HTTP helpers as direct dependencies; no dependency versions or build-gate workflows changed.

Validation and review convergence

  • npm test -- --runInBand __tests__/winappcliconfigurator.test.ts __tests__/integrity-inputs.test.ts __tests__/main.validation.test.ts — 138 passing tests, preserving parent validation cases and full-descriptor process mocking.
  • Regressions cover actual toolkit bypass matching with real dispatchers, local-proxy Basic auth captures, stalled-CONNECT cancellation within one second of deadline firing (configured timeout remains 30 seconds), actual partial-archive cleanup, ZIP exclusion, and both integration replacement/error surfaces.
  • npm run build, npm run lint, npm run format-check, and git diff --check passed. Both bundles regenerated.
  • All checks pass on final head dbd45527a3c22d8d36874c8ed21ff83c8d46eed9, including the live setup + winapp --version smoke test and full build, distributable consistency, CodeQL, and CLA.
  • Five actual Copilot review rounds, including assessment and fixes for summary-only findings. Final completed review reviewed that exact head and reports Approval recommended / No open issues. All three inline conversations are replied to and resolved; no remaining actionable summary findings.
  • Local validation uses temporary fixtures and local test proxies, without live downloads or installation into the shared user profile. CI performs the real installation. No merge or stack metadata mutation.

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 direct fetch bypasses Azure agent proxy and certificate settings, causing metadata resolution to fail on self-hosted agents that require them.

1 open issue
What changed in this PR

Adds download integrity verification to the shared WinAppCli installer used by GitHub Actions and Azure DevOps, building on #48’s version validation without changing build-gate workflows.

Changes:

  • Resolves release metadata and verifies ZIP SHA-256 digests before extraction, with optional caller-provided pins.
  • Installs the verified copy and cleans download and staging paths.
  • Adds verification tests, documents trust boundaries, and regenerates both shipped bundles.
File Description
src/​winappcliconfigurator.ts Implements release resolution, digest verification, installation, and cleanup.
src/​main.ts Passes the GitHub Actions checksum input to the configurator.
src/​azure-devops-task.ts Passes the Azure DevOps checksum input to the configurator.
setup-winappcli-task/​task.json Declares the optional Azure DevOps checksum input.
setup-winappcli-task/​index.js Updates the shipped Azure DevOps bundle.
README.md Documents verification, checksum pins, and trust boundaries.
dist/​index.js Updates the shipped GitHub Actions bundle.
action.yml Declares the optional GitHub Actions checksum input.
__tests__/​winappcliconfigurator.test.ts Covers verification, metadata validation, and cleanup failures.
__tests__/​integrity-inputs.test.ts Tests checksum input forwarding and failure reporting in both integrations.

Review effort: Balanced

Comment thread src/winappcliconfigurator.ts 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.

🟡 Changes recommended

Default token handling breaks release resolution on GitHub Enterprise, and metadata requests can incorrectly use a proxy despite existing NO_PROXY bypass rules.

2 open issues
1 resolved since last review

Review effort: Balanced

Comment thread action.yml Resolved
Comment thread src/main.ts 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

Username-only proxy credentials are omitted, risking HTTP 407 failures, and graceful dispatcher closure can delay setup until the five-minute headers timeout when CONNECT stalls.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Send proxy Basic auth when either credential field is present

src/​main.ts:16

With a username-only proxy URL such as HTTPS_PROXY=http://proxy-user@proxy.example:8080, metadata requests omit Basic authentication and can fail with HTTP 407. The bundled Undici derives credentials only when both fields are nonempty, whereas the existing Actions HTTP client accepts either field. Pass an explicit Basic token when either credential field is present.

Medium severity Destroy proxy dispatcher after metadata request to cancel stalled CONNECT

src/​main.ts:24

If a proxy accepts the connection but never answers CONNECT, fetch times out after 30 seconds, but this graceful close() can keep setup waiting until Undici's five-minute headers timeout. Destroy the one-use dispatcher after the request to cancel the pending tunnel request, and add a stalled-CONNECT regression. The same change is needed in src/azure-devops-task.ts:56.

2 resolved since last review

Review effort: Balanced

@azchohfi

Copy link
Copy Markdown
Collaborator Author

Addressed both summary-only findings from the latest Copilot review in 2231123. Both transports now send explicit proxy Basic authorization when either credential field is present, including decoded URL credentials. The one-use metadata dispatchers are destroyed after the request so an aborted stalled CONNECT cannot extend the deadline. Added real local-proxy tests for partial/encoded credentials and cancellation within one second of the metadata deadline firing, while verifying the configured deadline remains 30 seconds. All 132 focused tests passed and both bundles were regenerated. These findings were summary-only, so there are no additional inline threads to resolve; the three existing inline conversations are already 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

Human assessment is needed to evaluate the cross-component cleanup risk from partial archives left behind after failed downloads.

No open issues 🎉

Review effort: Balanced

@azchohfi

Copy link
Copy Markdown
Collaborator Author

Assessed the partial-download cleanup concern in the latest Copilot review. The Azure toolkit can reject on a stream failure without deleting its partial file, and its default destination was not available to the caller on failure. Fixed in dbd4552: both integrations now download into a known path within owned staging and always clean that path; extraction uses a separate child so the ZIP is never installed. Azure cleanup uses retrying asynchronous removal to handle streams finishing closure; managed-copy replacement remains synchronous. Added regressions that actually write a partial archive and reject before returning its path, verify both archive and staging removal, verify ZIP exclusion from installation, and exercise both integration cleanup/replacement paths. All 138 focused tests passed and both bundles were regenerated. The concern was summary-only; all existing inline conversations remain 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.

🟢 Approval recommended

No active review issues require follow-up on the download integrity verification changes.

No open issues 🎉

Review effort: Balanced

Base automatically changed from azchohfi-validate-release-versions to main November 2, 2026 22:37
Resolve official release metadata and check streaming SHA-256 before extraction, with optional independently pinned digests for both integrations. Preserve version validation and document trust limits and fail-closed behavior.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use pipeline-provided metadata transports with Azure proxy bypass, proxy authentication, and CA/client certificate settings. Preserve redirect rejection and the full request/body timeout. Default Actions metadata requests to github.token, support an optional secret token in both integrations, and identify API rate-limit responses without leaking credentials.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Only default to github.token for github.com workflows. Reuse each downloader toolkit's own environment proxy bypass matching instead of EnvHttpProxyAgent semantics, with real-agent regression coverage and unchanged locked dependency versions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Send explicit Basic proxy authorization when either credential field is present, including percent-decoded URL credentials. Destroy one-use dispatchers after metadata requests so an aborted stalled CONNECT cannot extend the deadline. Cover both integrations with real local proxy authentication and bounded cancellation regressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Pass a known ZIP destination in staging to both toolkit downloaders, always clean it even when download rejects without returning a path, and extract into a separate child directory so the ZIP is not installed. Use retrying asynchronous Azure cleanup and synchronous managed-copy replacement. Add actual partial-file and directory-replacement regressions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) merged commit eda30ac into main Nov 3, 2026
6 checks passed
@azchohfi
Alexandre Zollinger Chohfi (azchohfi) deleted the azchohfi-verify-release-downloads branch November 3, 2026 21:48
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