GHSA-mcph-m25j-8j63

Suggest an improvement
Source
https://github.com/advisories/GHSA-mcph-m25j-8j63
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/01/GHSA-mcph-m25j-8j63/GHSA-mcph-m25j-8j63.json
JSON Data
https://api.test.osv.dev/v1/vulns/GHSA-mcph-m25j-8j63
Aliases
Published
2024-01-02T16:41:27Z
Modified
2026-09-15T06:32:39Z
Severity
  • 7.3 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:N CVSS Calculator
Summary
tj-actions/changed-files has Potential Actions command injection in output filenames (GHSL-2023-271)
Details

Summary

The tj-actions/changed-files workflow allows for command injection in changed filenames, allowing an attacker to execute arbitrary code and potentially leak secrets.

Details

The changed-files action returns a list of files changed in a commit or pull request which provides an escape_json input enabled by default, only escapes " for JSON values.

This could potentially allow filenames that contain special characters such as ; and ` (backtick) which can be used by an attacker to take over the GitHub Runner if the output value is used in a raw fashion (thus being directly replaced before execution) inside a run block. By running custom commands an attacker may be able to steal secrets such as GITHUB_TOKEN if triggered on other events than pull_request. For example on push.

Proof of Concept

  1. Submit a pull request to a repository with a new file injecting a command. For example $(whoami).txt which is a valid filename.
  2. Upon approval of the workflow (triggered by the pull request), the action will get executed and the malicious pull request filename will flow into the List all changed files step below.
      - name: List all changed files
        run: |
          for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
            echo "$file was changed"
          done

Example output:

##[group]Run for file in $(whoami).txt; do
    for file in $(whoami).txt; do
        echo "$file was changed"
    done
shell: /usr/bin/bash -e {0}
##[endgroup]
runner.txt was changed

Impact

This issue may lead to arbitrary command execution in the GitHub Runner.

Resolution

  • A new safe_output input would be enabled by default and return filename paths escaping special characters like ;, ` (backtick), $, (), etc for bash environments.

  • A safe recommendation of using environment variables to store unsafe outputs.

- name: List all changed files
  env:
    ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
  run: |
    for file in "$ALL_CHANGED_FILES"; do
      echo "$file was changed"
    done

Resources

Database specific
{
    "cwe_ids":  [
        "CWE-74",
        "CWE-77"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2024-01-02T16:41:27Z",
    "nvd_published_at":  "2023-12-27T17:15:08Z",
    "severity":  "HIGH"
}
References

Affected packages

GitHub Actions / tj-actions/changed-files

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
41
Type
GIT
Repo
https://github.com/tj-actions/changed-files
Events
Introduced
0 Unknown introduced commit / All previous commits are affected
Fixed

Affected versions

Other
v1
v10
v11
v12
v16
v17
v18
v19
v2
v20
v21
v22
v23
v24
v25
v26
v27
v28
v29
v3
v30
v31
v32
v33
v34
v36
v37
v38
v39
v4
v40
v5
v6
v7
v8
v9
v1.*
v1.0.2
v1.0.3
v1.1.0
v1.1.1
v1.1.2
v1.1.3
v1.2.0
v1.2.1
v1.2.2
v1.3.0
v1.3.1
v10.*
v10.1
v11.*
v11.1
v11.2
v11.3
v11.4
v11.5
v11.6
v11.7
v11.8
v11.9
v12.*
v12.1
v12.2
v15.*
v15.1
v17.*
v17.1
v17.2
v17.3
v18.*
v18.1
v18.2
v18.3
v18.4
v18.5
v18.6
v18.7
v19.*
v19.1
v19.2
v19.3
v2.*
v2.0.0
v2.0.1
v2.1
v20.*
v20.1
v20.2
v22.*
v22.1
v22.2
v23.*
v23.1
v23.2
v24.*
v24.1
v26.*
v26.1
v28.*
v28.0.0
v29.*
v29.0.0
v29.0.1
v29.0.2
v29.0.3
v29.0.4
v29.0.5
v29.0.6
v29.0.7
v29.0.8
v29.0.9
v3.*
v3.1
v3.2
v3.3
v30.*
v30.0.0
v31.*
v31.0.0
v31.0.1
v31.0.2
v31.0.3
v32.*
v32.0.0
v32.0.1
v32.1.0
v32.1.1
v32.1.2
v33.*
v33.0.0
v34.*
v34.0.0
v34.0.1
v34.0.2
v34.0.3
v34.0.4
v34.0.5
v34.1.1
v34.2.0
v34.2.1
v34.2.2
v34.3.0
v34.3.1
v34.3.2
v34.3.3
v34.3.4
v34.4.0
v34.4.1
v34.4.2
v34.4.3
v34.4.4
v34.5.0
v34.5.1
v34.5.2
v34.5.3
v34.5.4
v34.6.0
v34.6.1
v34.6.2
v35.*
v35.0.0
v35.0.1
v35.1.0
v35.1.1
v35.1.2
v35.2.0
v35.2.1
v35.3.0
v35.3.1
v35.3.2
v35.4.0
v35.4.1
v35.4.2
v35.4.3
v35.4.4
v35.5.0
v35.5.1
v35.5.2
v35.5.3
v35.5.4
v35.5.5
v35.5.6
v35.6.0
v35.6.1
v35.6.2
v35.6.3
v35.6.4
v35.7.0
v35.7.0-sec
v35.7.1
v35.7.10
v35.7.11
v35.7.12
v35.7.2
v35.7.3
v35.7.4
v35.7.5
v35.7.6
v35.7.7
v35.7.8
v35.7.9
v35.8.0
v35.9.0
v35.9.1
v35.9.2
v36.*
v36.0.0
v36.0.1
v36.0.10
v36.0.11
v36.0.12
v36.0.13
v36.0.14
v36.0.15
v36.0.16
v36.0.17
v36.0.18
v36.0.2
v36.0.3
v36.0.4
v36.0.5
v36.0.6
v36.0.7
v36.0.8
v36.0.9
v36.1.0
v36.2.0
v36.2.1
v36.3.0
v36.4.0
v36.4.1
v36.4.2
v37.*
v37.0.0
v37.0.1
v37.0.2
v37.0.3
v37.0.4
v37.0.5
v37.1.0
v37.1.1
v37.1.2
v37.2.0
v37.3.0
v37.4.0
v37.5.0
v37.5.1
v37.5.2
v37.6.0
v37.6.1
v38.*
v38.0.0
v38.1.0
v38.1.1
v38.1.2
v38.1.3
v38.2.0
v38.2.1
v38.2.2
v39.*
v39.0.0
v39.0.1
v39.0.2
v39.0.3
v39.1.0
v39.1.1
v39.1.2
v39.2.0
v39.2.1
v39.2.2
v39.2.3
v39.2.4
v4.*
v4.1
v4.2
v4.3
v4.4
v40.*
v40.0.0
v40.0.1
v40.0.2
v40.1.0
v40.1.1
v40.2.0
v40.2.1
v40.2.2
v40.2.3
v41.*
v41.0.0
v5.*
v5.1
v5.2
v5.3
v6.*
v6.1
v6.2
v6.3
v8.*
v8.1
v8.2
v8.3
v8.4
v8.5
v8.6
v8.7
v8.8
v8.9
v9.*
v9.1
v9.2
v9.3

Database specific

source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/01/GHSA-mcph-m25j-8j63/GHSA-mcph-m25j-8j63.json"