/

CVE-2026-30874

Severity:

HIGH RISK

(7.8)

Privilege Escalation via Environment Manipulation

CVE-2026-30874

Analyzed

Vulnerability type

Category:

Privilege Escalation via Environment Manipulation

CWE:

CWE-74, CWE-187, CWE-269

Impact:

Privilege Escalation

Severity:

HIGH RISK

(7.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A flaw in OpenWrt's hotplug_call environment filtering allows an attacker to inject a controlled PATH variable into hotplug scripts.

Because PATH is not correctly stripped, an attacker who can influence the hotplug environment may redirect which binaries are executed by privileged procd-invoked scripts, potentially leading to privilege escalation.

Affected context

This vulnerability affects OpenWrt-based systems where:

  • The procd hotplug mechanism invokes scripts from /etc/hotplug.d/*
  • Environment variables supplied to hotplug_call are expected to be filtered before script execution
  • Downstream scripts rely on the system PATH rather than using fully qualified executable paths

The issue arises because the PATH variable from the caller's environment is not removed as intended, even when scripts execute with elevated privileges.

Exploit preconditions

  • Attack surface: Hotplug events processed by procd and related subsystems that use hotplug_call
  • Required access: Ability to influence or set environment variables for processes that trigger hotplug_call (e.g., via controlled services, scripts, or interfaces that emit hotplug events)
  • Trigger point: Execution of hotplug scripts under /etc/hotplug.d where PATH determines which binaries are run
  • Why exploitation is possible: The filtering logic compares full environment strings such as PATH=/some/value against the literal "PATH" using strcmp instead of strncmp, causing the filter to miss the PATH variable entirely and allowing untrusted values to reach privileged scripts.

Why this happens

The root cause is a flawed environment sanitization routine in hotplug_call, where the code attempts to strip sensitive environment variables but performs an incorrect comparison.

Instead of comparing only the variable name portion ("PATH") of each environment string, the implementation uses strcmp on the full string (e.g., "PATH=/usr/bin"), which never matches the bare "PATH" token.

This logic error maps to CWE-187: Partial Comparison, and it leads to a violation of CWE-269: Improper Privilege Management, because privileged scripts inherit untrusted PATH values that can alter which executables are run.

Conceptually, this is an environment-variable injection issue, where assumptions about sanitized context do not hold due to a subtle string comparison bug.

Potential impact

  • Attackers may control which binaries are executed by privileged hotplug scripts by pointing PATH to attacker-controlled directories.
  • Malicious or trojaned binaries placed in accessible locations may be executed with elevated privileges.
  • System integrity may be compromised through unauthorized configuration changes or code execution.
  • Subsequent lateral movement or persistence could be established using the elevated context of the affected scripts.

General mitigation guidance

Effective mitigation focuses on hardening environment handling and reducing reliance on inherited state:

  • Treat all environment variables as untrusted, especially in privileged or system service contexts.
  • Implement strict environment sanitization: explicitly whitelist variables that are allowed, rather than blacklisting a few sensitive names.
  • Use correct string handling for variable name comparison (e.g., comparing up to the = delimiter) to avoid partial or failed matches.
  • In privileged scripts, prefer fully qualified executable paths instead of relying on PATH resolution, and avoid modifying PATH unless strictly necessary.
  • Run procd-invoked scripts with the minimum necessary privileges and, where possible, in restricted or sandboxed execution contexts.

How teams detect issues like this

Detection can rely on a combination of code- and behavior-focused techniques:

  • Static analysis and code review: Flag patterns where environment variables are filtered using full-string comparisons instead of separating variable names and values; pay special attention to checks against strings like "PATH", "LD_PRELOAD", and similar.
  • Configuration and script review: Examine hotplug and other privileged scripts for reliance on inherited PATH, and for executions that omit fully qualified paths.
  • Runtime monitoring: Observe for anomalous PATH values in processes spawned by procd or other system daemons; baseline normal PATH usage and alert on unexpected directories or user-writable paths.
  • Policy enforcement: Use CI policies or security checks that require explicit environment sanitization for privileged components and discourage ad-hoc environment forwarding.

Sources

SourceLink
github.comgithub.com/openwrt/openwrt/security/advisories/GHSA-jw28-hxcm-j934
github.comgithub.com/openwrt/procd/commit/e08cdc8562f55b9ac228a21f3f7605a18c522b81

Frequently asked

questions

Exploitability depends on whether an attacker can influence environment variables for processes that trigger hotplug_call; in environments where untrusted users or services can affect hotplug events, the risk is significantly higher.

Typically some form of local or adjacent access is required, such as control over a service, script, or interface that can set environment variables before procd invokes hotplug_call, though the exact path depends on the specific OpenWrt configuration.

The robust pattern is to implement strict environment sanitization using explicit whitelists, correctly parsing variable names (up to the =) and discarding or normalizing sensitive variables before running privileged code, combined with using absolute paths for all critical executables.

Prevention involves coding standards that forbid reliance on inherited environments in privileged components, mandatory code review for environment handling, regular static analysis focused on string comparison and filtering logic, and design guidelines that default to least privilege and explicit, well-defined execution contexts.

Find out what's already
exploitable in your codebase.