CVE-2024-1540 (YAML, published 2024-03-27T16:15Z)
Description: value: A command injection vulnerability exists in the deploy+test-visual.yml workflow of the gradio-app/gradio repository, due to improper neutralization of special elements used in a command. This vulnerability allows attackers to execute unauthorized commands, potentially leading to unauthorized modification of the base repository or secrets exfiltration. The issue arises from the unsafe handling of GitHub context information within a `run` operation, where expressions inside `${{ }}` are evaluated and substituted before script execution. Remediation involves setting untrusted input values to intermediate environment variables to prevent direct influence on script generation.
Severity: nan (CVSS v3 base score: )
Weakness: CWE-77 \u2014 Improper Neutralization of Special Elements used in a Command ('Command Injection')
The product constructs all or part of a command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended command when it is sent to a downstream component.
Repository: https://github.com/gradio-app/gradio
Files changed:
.github/workflows/deploy+test-visual.yml
.github/workflows/deploy-spaces.yml
.github/workflows/deploy-website.yml
.github/workflows/generate-changeset.yml
.github/workflows/test-hygiene.yml
.github/workflows/test-python.yml
.github/workflows/tests-js.yml
Commit message: fix spaces comment and remove echos (#7373)

* remove unnecessary condition for deployment workflow

* remove unnecessary echo statements in GitHub Actions workflows

* fix website ci

* add condition to only run comment-spaces-start workflow if changes workflow outputs 'should_run' as 'true'

Vulnerable code:
      - name: echo github context
        if: always()
        run: echo "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
  

      - name: echo github context
        if: always()
        run: echo "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
    if: >
      github.event.workflow_run.event == 'pull_request' &&
      github.event.workflow_run.conclusion == 'success' &&
      needs.deploy-spaces.result == 'success'
    if: always() && needs.deploy-spaces == 'failure'
      - name: echo github context
        if: always()
        run: echo "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"

      - name: echo outputs
        run: |
          echo "source_repo=${{ needs.changes.outputs.source_repo }}"
          echo "source_branch=${{ needs.changes.outputs.source_branch }}"
          echo "found_pr=${{ needs.changes.outputs.found_pr }}"
          echo "pr_number=${{ needs.changes.outputs.pr_number }}"
    - name: echo github context
      if: always()
      run: echo "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"

      - name: echo github context
        if: always()
        run: echo "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"
  
      - name: echo github context
        if: always()
        run: echo "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"

  
      - name: echo github context
        if: always()
        run: echo "${{ github.event.workflow_run.head_repository.full_name }}-${{ github.event.workflow_run.head_branch }}-${{ github.workflow_ref }}"


Fixed code:
      found_pr: ${{ steps.changes.outputs.found_pr }}
    if: ${{ needs.changes.outputs.should_run == 'true' }}
    if: needs.deploy-spaces.result == 'success' && needs.changes.outputs.found_pr == 'true'
    if: always() && needs.deploy-spaces == 'failure' && needs.changes.outputs.found_pr == 'true'