CVE-2022-39326: Kartverket/github workflows Remote Code Execution Vulnerability

HIGH
Advisory Identifier: GHSA-f9qj-7gh3-mhj4
CVSS 8.8
CWE-94
Published
Advisory Summary

CVE-2022-39326 is a HIGH (CVSS 8.8) remote code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Kartverket/github workflows libraries in the GitHub Actions ecosystem. The issue involves run-terraform allows for rce via terraform plan. Remediation is available by upgrading affected packages to version 2.7.5.

CVE-2022-39326 at a Glance

CVE Identifier CVE-2022-39326
GHSA Identifier GHSA-f9qj-7gh3-mhj4
Severity HIGH
CVSS v3.1 Base Score 8.8
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Kartverket/github workflows
Package Ecosystem GitHub Actions
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2022-39326

To remediate this vulnerability, upgrade all affected Kartverket/github workflows dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

kartverket/github-workflows fixed: 2.7.5
Upgrade kartverket/github-workflows to 2.7.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for kartverket/github-workflows

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-39326, inspect your project dependencies for Kartverket/github workflows:

inspect dependencies for kartverket/github-workflows

Analyze the terminal output to locate any version of Kartverket/github workflows in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.7.5), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Kartverket/github workflows, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact _What kind of vulnerability is it? Who is impacted?_ All users of the `run-terraform` reusable workflow from the kartverket/github-workflows repo are affected. A malicious actor could potentially send a PR with a malicious payload leading to execution of arbitrary JavaScript code in the context of the workflow. ### Patches _Has the problem been patched? What versions should users upgrade to?_ Upgrade to at least 2.7.5 to resolve the issue. ### Workarounds _Is there a way for users to fix or remediate the vulnerability without upgrading?_ Until you are able to upgrade, make sure to review any PRs from exernal users for malicious payloads before allowing them to trigger a build. ### For more information If you have any questions or comments about this advisory: * Open an issue in [kartverket/github-workflows](https://github.com/kartverket/github-workflows)

CVE-2022-39326 Affected Kartverket/github workflows Versions

1 component(s)
Fixed Versions:
2.7.5
Product / Package Ecosystem Affected Versions Fixed Version
kartverket/github-workflows
GitHub Actions
< 2.7.5
2.7.5

References

Frequently Asked Questions

What is CVE-2022-39326?
CVE-2022-39326 is a security vulnerability in Kartverket/github workflows involving run-terraform allows for RCE via terraform plan under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Kartverket/github workflows versions are affected?
Affected versions include releases prior to 2.7.5 across affected packages: kartverket/github-workflows.
What version fixes CVE-2022-39326?
Upgrading to 2.7.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is kartverket/github-workflows affected?
Yes, kartverket/github-workflows is affected in releases prior to 2.7.5. Upgrade your dependency to 2.7.5 or later.
What is the CVSS score of CVE-2022-39326?
CVE-2022-39326 has a CVSS v3.1 base score of 8.8 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-39326?
CVE-2022-39326 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check GitHub Actions dependencies for CVE-2022-39326?
Run the dependency tree command: 'inspect dependencies for kartverket/github-workflows'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-f9qj-7gh3-mhj4",
  "modified" : "2022-10-25T20:30:47Z",
  "published" : "2022-10-19T18:54:28Z",
  "aliases" : [ "CVE-2022-39326" ],
  "summary" : "run-terraform allows for RCE via terraform plan",
  "details" : "### Impact\n_What kind of vulnerability is it? Who is impacted?_  \nAll users of the `run-terraform` reusable workflow from the kartverket/github-workflows repo are affected. A malicious actor could potentially send a PR with a malicious payload leading to execution of arbitrary JavaScript code in the context of the workflow.\n\n### Patches\n_Has the problem been patched? What versions should users upgrade to?_  \nUpgrade to at least 2.7.5 to resolve the issue.\n\n### Workarounds\n_Is there a way for users to fix or remediate the vulnerability without upgrading?_  \nUntil you are able to upgrade, make sure to review any PRs from exernal users for malicious payloads before allowing them to trigger a build.\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [kartverket/github-workflows](https://github.com/kartverket/github-workflows)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "GitHub Actions",
      "name" : "kartverket/github-workflows"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.7.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/kartverket/github-workflows/security/advisories/GHSA-f9qj-7gh3-mhj4"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-39326"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kartverket/github-workflows/pull/19"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/kartverket/github-workflows"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kartverket/github-workflows/releases/tag/v2.7.5"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-10-19T18:54:28Z",
    "nvd_published_at" : "2022-10-25T17:15:00Z"
  }
}