Skip to content

fix(security): prevent SSRF in GitHub OIDC token URL handling (CWE-918) - #2106

Merged
Erik Osterman (Cloud Posse) (osterman) merged 8 commits into
mainfrom
copilot/fix-code-scanning-issue-5164
Mar 2, 2026
Merged

Erik Osterman (Cloud Posse) (osterman) merged 8 commits into
mainfrom
copilot/fix-code-scanning-issue-5164

Conversation

Copilot AI commented Feb 24, 2026 •

Copy link
Copy Markdown
Contributor
  • Identify SSRF vulnerability in GitHub OIDC URL handling (CWE-918, CodeQL alert #5164)
  • Fix SSRF in pkg/auth/providers/github/oidc.go - add validateGitHubActionsURL helper, injectable HTTP client
  • Fix SSRF in pkg/auth/providers/azure/oidc.go - add scheme + hostname validation in fetchGitHubActionsToken
  • Fix SSRF in pkg/pro/api_client.go - add URL validation, proper URL query manipulation, variadic client injection
  • Update pkg/auth/providers/github/oidc_test.go - use TLS server, inject client
  • Update pkg/auth/providers/azure/oidc_test.go - use TLS server, inject client
  • Update pkg/pro/api_client_test.go - use TLS server, inject client via oidcHTTPClientOverride
  • Update pkg/pro/api_client_get_github_oidc_token_test.go - use TLS server, https URL for network test
  • Add TestValidateGitHubActionsURL unit tests
  • Add TestGetGitHubOIDCToken_URLValidation unit tests
  • Apply gofmt formatting fixes
  • Add TestOIDCProvider_FetchGitHubActionsToken_URLValidation (azure) - cover http scheme and empty host error paths
  • Add TestOIDCProvider_getHTTPClient (github) - cover both branches of getHTTPClient
  • Add TestOIDCProvider_Authenticate_URLValidation (github) - cover validateGitHubActionsURL error path in requestParams
  • All tests pass

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@mergify mergify Bot added triage Needs triage wip Work in Progress: Not ready for final review or merge labels Feb 24, 2026
@nitrocode RB (nitrocode) added the patch A minor, backward compatible change label Feb 24, 2026
Copilot AI and others added 2 commits February 24, 2026 04:56
Validate ACTIONS_ID_TOKEN_REQUEST_URL before making HTTP requests in
the GitHub OIDC, Azure OIDC, and Atmos Pro API client code paths.

- Require https:// scheme (reject http://)
- Require non-empty hostname
- Use proper url.Parse + query manipulation instead of string
  concatenation in pkg/pro/api_client.go
- Add injectable HTTP client to oidcProvider in pkg/auth/providers/github
  and variadic client support in pkg/pro/api_client.go for testability
- Update all affected tests to use httptest.NewTLSServer and inject
  TLS-aware clients
- Add TestValidateGitHubActionsURL and TestGetGitHubOIDCToken_URLValidation
  unit tests to cover the new validation logic

Co-authored-by: nitrocode <[email protected]>
Copilot AI changed the title [WIP] Fix code scanning issue according to CLAUDE.md fix(security): prevent SSRF in GitHub OIDC token URL handling (CWE-918) Feb 24, 2026
Copilot AI requested a review from RB (nitrocode) February 24, 2026 05:00
@mergify mergify Bot removed the wip Work in Progress: Not ready for final review or merge label Feb 24, 2026
@github-actions github-actions Bot added the size/m Medium size PR label Feb 24, 2026
@github-actions

github-actions Bot commented Feb 24, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@codecov

codecov Bot commented Feb 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.53%. Comparing base (d30448e) to head (64b78c5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2106      +/-   ##
==========================================
+ Coverage   76.51%   76.53%   +0.01%     
==========================================
  Files         832      832              
  Lines       79407    79441      +34     
==========================================
+ Hits        60758    60797      +39     
+ Misses      14856    14852       -4     
+ Partials     3793     3792       -1     
Flag Coverage Δ
unittests 76.53% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/auth/providers/azure/oidc.go 90.53% <100.00%> (+0.14%) ⬆️
pkg/auth/providers/github/oidc.go 71.42% <100.00%> (+3.57%) ⬆️
pkg/pro/api_client.go 92.37% <100.00%> (+0.55%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@osterman

Copy link
Copy Markdown
Member

Copilot can you address the missing tests?

pkg/auth/providers/azure/oidc.go 0.00% 2 Missing and 2 partials ⚠️
pkg/auth/providers/github/oidc.go 81.25% 2 Missing and 1 partial ⚠️

pkg/auth/providers/azure/oidc.go 0.00% 2 Missing and 2 partials ⚠️
pkg/auth/providers/github/oidc.go 81.25% 2 Missing and 1 partial ⚠️

…providers

- Add TestOIDCProvider_FetchGitHubActionsToken_URLValidation for azure
  (http scheme and empty hostname cases) covering the two new error
  return paths in fetchGitHubActionsToken
- Add TestOIDCProvider_getHTTPClient for github to cover both branches
  of getHTTPClient (default &http.Client and injected custom client)
- Add TestOIDCProvider_Authenticate_URLValidation for github to cover
  the validateGitHubActionsURL error return path in requestParams

Coverage improvements:
  github/oidc.go: getHTTPClient 66.7%→100%, requestParams 76.9%→84.6%
  azure/oidc.go:  fetchGitHubActionsToken 87.2%→92.3%

Co-authored-by: osterman <[email protected]>

Copilot AI commented Feb 26, 2026

Copy link
Copy Markdown
Contributor Author

Copilot can you address the missing tests?

...

Added coverage for the missing branches in commit 9f311a0:

  • azure/oidc.go (fetchGitHubActionsToken): Added TestOIDCProvider_FetchGitHubActionsToken_URLValidation covering the http scheme rejection and empty-hostname rejection paths. Coverage: 87.2% → 92.3%
  • github/oidc.go (getHTTPClient): Added TestOIDCProvider_getHTTPClient covering both the default-client and custom-client branches. Coverage: 66.7% → 100%
  • github/oidc.go (requestParams): Added TestOIDCProvider_Authenticate_URLValidation covering the validateGitHubActionsURL error-return path. Coverage: 76.9% → 84.6%

@mergify mergify Bot removed the triage Needs triage label Feb 26, 2026
@osterman
Erik Osterman (Cloud Posse) (osterman) merged commit 314b3d5 into main Mar 2, 2026
56 checks passed
@osterman
Erik Osterman (Cloud Posse) (osterman) deleted the copilot/fix-code-scanning-issue-5164 branch March 2, 2026 02:30
@github-actions

github-actions Bot commented Mar 3, 2026

Copy link
Copy Markdown

These changes were released in v1.208.0.

Igor Rodionov (goruha) added a commit that referenced this pull request Mar 9, 2026
…raform-plan

* osterman/native-ci-terraform: (28 commits)
  feat: Add source cache TTL for JIT-vendored components (#2138)
  feat: Per-target version overrides in vendor manifests (#2141)
  docs: Add PRD for browser-based auth in aws/user identity (#1887)
  docs: Add EKS kubeconfig authentication integration PRD (#1884)
  fix: correct marketplace.json schema and update docs with install/uninstall commands (#2142)
  fix: propagate auth to all YAML functions in multi-component execution (#2140)
  fix: Use atmos_component for source provisioner workdir paths (#2137)
  Fix identity prompts to respect --interactive flag (#2130)
  Increase PR size thresholds to accommodate AI-assisted development (#2136)
  docs: Add Azure authentication provider documentation (#2132)
  fix: propagate component-type level dependencies through stack processor (#2127)
  fix: Add retry and missing workflow step properties to all schema copies (#2113)
  Exclude unsupported windows/arm from goreleaser build matrix (#2133)
  Add AI Agent Skills for LLM-Powered Infrastructure Development (#2121)
  Fix: Convert toolchain paths to absolute in PATH to resolve exec.LookPath failures (#2095)
  Fix workdir collision for component instances sharing base component (#2093)
  fix(auth): propagate TTY state to subprocesses for SSO device flow in workflows (#2126)
  fix(security): prevent SSRF in GitHub OIDC token URL handling (CWE-918) (#2106)
  Fix #2112: add workflow_retry definition and retry property to workflow step schema (#2114)
  fix(auth): auto-detect GitHub Actions WIF with proper audience, host validation, and lazy GSM init (#2109)
  ...
@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown

These changes were released in v1.208.1-test.9.

@github-actions

github-actions Bot commented Mar 9, 2026

Copy link
Copy Markdown

These changes were released in v1.208.1-test.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants