Skip to content

Fix cache poisoning code scanning alerts in Python integration workflows - #11863

Merged
iscai-msft merged 2 commits into
microsoft:mainfrom
iscai-msft:fix-http-client-python-security
Sep 4, 2026
Merged

Fix cache poisoning code scanning alerts in Python integration workflows#11863
iscai-msft merged 2 commits into
microsoft:mainfrom
iscai-msft:fix-http-client-python-security

Conversation

@iscai-msft

Copy link
Copy Markdown
Member

Summary

Resolves the 36 open code scanning alerts of rule actions/cache-poisoning/poisonable-step (Cache Poisoning via execution of untrusted code):

  • 31 alerts in .github/workflows/python-integration.yml (the http-client-python emitter CI)
  • 5 alerts in .github/workflows/external-integration.yml

Root cause

Both workflows check out untrusted PR code (they update the core submodule / checkout to github.event.pull_request.head.sha) and then run steps that use caching. Each also declared a workflow_dispatch trigger. Because workflow_dispatch runs in the context of the default branch, it has write access to the default-branch cache scope. CodeQL flags this combination as a cache-poisoning risk: a run could write poisoned entries into a cache that privileged default-branch workflows later restore.

Every flagged instance in the alerts is attributed to the workflow_dispatch trigger.

Fix

Remove the workflow_dispatch trigger from both workflows so they run only on pull_request. Under pull_request, the cache is scoped to the PR branch rather than the default branch, which is exactly the "Correct Usage" pattern in the CodeQL rule's guidance.

  • python-integration.yml: dropped workflow_dispatch:.
  • external-integration.yml: dropped workflow_dispatch:, and removed the now-dead || github.event_name == 'workflow_dispatch' disjunct from the azure-rest-api-specs job condition. That job remains manually triggerable via the existing int:azure-specs PR label.

Note: CodeQL does not evaluate step/job if: gates, so gating the untrusted checkout on github.event_name == 'pull_request' (as python-integration.yml already did) does not clear the alerts — removing the write-capable trigger is required.

Impact

  • No change to the primary PR-validation behavior of either workflow.
  • Loses the ability to manually dispatch these integration workflows with no PR context (which was not meaningful, since the jobs depend on PR head SHA). The azure-rest-api-specs job retains its label-based manual path.

Remove the workflow_dispatch trigger from python-integration.yml and
external-integration.yml. Both workflows check out untrusted PR code and
use caching; the workflow_dispatch trigger runs on the default branch and
therefore has write access to the default-branch cache scope, which
CodeQL flags as a cache poisoning risk (actions/cache-poisoning/poisonable-step).

Restricting these workflows to the pull_request trigger scopes their cache
to the PR branch, matching the 'Correct Usage' example in the CodeQL rule,
and resolves all 36 open alerts. The azure-rest-api-specs job keeps its
label-based (int:azure-specs) manual trigger.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The changes are minimal, YAML-valid, and directly eliminate the write-capable workflow_dispatch trigger that CodeQL flags for cache poisoning risk.

Pull request overview

This PR removes workflow_dispatch from two GitHub Actions workflows to address CodeQL actions/cache-poisoning/poisonable-step alerts caused by combining untrusted PR code checkout with cache writes in a default-branch privileged trigger context.

Changes:

  • Removed workflow_dispatch trigger from python-integration.yml.
  • Removed workflow_dispatch trigger from external-integration.yml.
  • Simplified the azure-rest-api-specs job condition by dropping the now-dead workflow_dispatch disjunct.
File summaries
File Description
.github/workflows/python-integration.yml Removes the manual dispatch trigger so cache writes only occur under pull_request scope.
.github/workflows/external-integration.yml Removes the manual dispatch trigger and updates a job-level if: condition accordingly.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

Copilot AI review requested due to automatic review settings September 4, 2026 19:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The workflow changes are minimal, YAML remains valid, and all workflow_dispatch references were cleanly removed to address the stated CodeQL alert root cause.

Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@azure-sdk-automation

Copy link
Copy Markdown

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@iscai-msft
iscai-msft added this pull request to the merge queue Sep 4, 2026
Merged via the queue into microsoft:main with commit 91a1d43 Sep 4, 2026
37 checks passed
@iscai-msft
iscai-msft deleted the fix-http-client-python-security branch September 4, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants