CVE-2024-39700 (Other, published 2024-07-16T18:15Z)
Description: value: JupyterLab extension template is a  `copier` template for JupyterLab extensions. Repositories created using this template with `test` option include `update-integration-tests.yml` workflow which has an RCE vulnerability. Extension authors hosting their code on GitHub are urged to upgrade the template to the latest version. Users who made changes to `update-integration-tests.yml`, accept overwriting of this file and re-apply your changes later. Users may wish to temporarily disable GitHub Actions while working on the upgrade. We recommend rebasing all open pull requests from untrusted users as actions may run using the version from the `main` branch at the time when the pull request was created. Users who are upgrading from template version prior to 4.3.0 may wish to leave out proposed changes to the release workflow for now as it requires additional configuration.
Severity: nan (CVSS v3 base score: )
Weakness: NVD-CWE-noinfo \u2014 Insufficient Information
There is insufficient information about the issue to classify it; details are unkown or unspecified.
Repository: https://github.com/jupyterlab/extension-template
Files changed:
template/.github/workflows/{% if test %}update-integration-tests.yml{% endif %}	
Commit message: Merge pull request from GHSA-45gq-v5wm-82wg

* Fix for update-snapshots template

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
Co-authored-by: RedYetiDev <38299977+RedYetiDev@users.noreply.github.com>

* Update date check

* Pull in changes from hotfix 16560

---------

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
Co-authored-by: RedYetiDev <38299977+RedYetiDev@users.noreply.github.com>

Vulnerable code:
    if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'please update snapshots') }}
        run: gh pr checkout ${{ github.event.issue.number }}

Fixed code:
    if: >
      (
        github.event.issue.author_association == 'OWNER' ||
        github.event.issue.author_association == 'COLLABORATOR' ||
        github.event.issue.author_association == 'MEMBER'
      ) && github.event.issue.pull_request && contains(github.event.comment.body, 'please update snapshots')
      - name: Get PR Info
        id: pr
        env:
          PR_NUMBER: ${{ github.event.issue.number }}
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GH_REPO: ${{ github.repository }}
          COMMENT_AT: ${{ github.event.comment.created_at }}
        run: |
          pr="$(gh api /repos/${GH_REPO}/pulls/${PR_NUMBER})"
          head_sha="$(echo "$pr" | jq -r .head.sha)"
          pushed_at="$(echo "$pr" | jq -r .pushed_at)"

          if [[ $(date -d "$pushed_at" +%s) -gt $(date -d "$COMMENT_AT" +%s) ]]; then
              echo "Updating is not allowed because the PR was pushed to (at $pushed_at) after the triggering comment was issued (at $COMMENT_AT)"
              exit 1
          fi

          echo "head_sha=$head_sha" >> $GITHUB_OUTPUT

        run: gh pr checkout ${{ github.event.issue.number }}

      - name: Validate the fetched branch HEAD revision
        env:
          EXPECTED_SHA: ${{ steps.pr.outputs.head_sha }}
        run: |
          actual_sha="$(git rev-parse HEAD)"

          if [[ "$actual_sha" != "$EXPECTED_SHA" ]]; then
              echo "The HEAD of the checked out branch ($actual_sha) differs from the HEAD commit available at the time when trigger comment was submitted ($EXPECTED_SHA)"
              exit 1
          fi