Summary
OPNsense service settings can be vulnerable to CRLF injection when authenticated Web UI or API users with delegated access submit carriage-return or line-feed characters in fields intended to hold a single line. When the affected configuration is generated and applied, injected lines may change service behavior or cross the intended access boundary; root command execution was demonstrated in a Monit configuration path, but was not confirmed for Dnsmasq.
Affected context
The issue affects OPNsense configurations where user-controlled, single-line fields are rendered into privileged service configuration files without reliably rejecting or encoding CR and LF characters. Confirmed Dnsmasq fields include dhcp_boot.filename, dhcp_boot.servername, dhcp_boot.address, and dhcp_options.value, rendered into /usr/local/etc/dnsmasq.conf. Related affected settings span OpenVPN, DHCPv6, Unbound, IPsec, NTP, PPP or MPD, Monit, firewall, sudo, WebGUI, and System General. Risk depends on the affected setting, the user's delegated permissions, and whether the generated configuration is applied or the service is restarted.
Exploit preconditions
- Attack surface: OPNsense Web UI or API configuration fields that feed generated service configuration files.
- Required access: An authenticated user with delegated access to the affected settings.
- Trigger point: Saving and applying the configuration, or restarting the affected service.
- Why exploitation is possible: CR or LF characters in a single-line value may be interpreted as configuration line boundaries, allowing additional directives or policy lines to enter a privileged file.
Why this happens
The underlying bug is improper neutralization of CR and LF characters in values that are later written into line-oriented configuration files. This maps primarily to CWE-93: Improper Neutralization of CRLF Sequences, a specific form of the broader input-neutralization weakness described by CWE-74. Treating a user-controlled value as a single line without enforcing that boundary can let it alter the structure and meaning of generated configuration. The demonstrated Monit path allowed root command execution; that outcome should not be assumed for every affected service or for the Dnsmasq path.
Potential impact
- Injected directives could alter service behavior beyond the setting the user is authorized to manage.
- Configuration changes could cross delegated role-based access control boundaries.
- Affected services could create files or apply attacker-controlled policies.
- Malformed or hostile configuration could cause service disruption or denial of service.
- In the demonstrated Monit path, line injection could lead to root command execution.
General mitigation guidance
Defensive patterns focus on preserving the boundary between a single-line value and configuration syntax:
- Reject CR and LF characters in fields that are defined as single-line values.
- Validate inputs against field-specific types, length limits, and allowlists.
- Use structured configuration-generation APIs or serializers that safely encode values rather than assembling configuration text directly.
- Keep delegated settings narrowly scoped and run services with the least privileges practical.
- Treat configuration as untrusted until validated, and limit who can modify, apply, or restart services using generated files.
How teams detect issues like this
- Use static analysis to identify user-controlled values written into configuration files, especially through string concatenation or template rendering without CR/LF validation.
- Review single-line fields across service and API handlers for consistent validation, including less commonly used settings.
- Inspect generated configuration changes for unexpected additional lines or directives after values are saved or applied.
- Enforce input-validation policies and automated tests that verify line breaks cannot change generated configuration structure.
- Automated code review tools can help flag unsafe configuration-generation patterns for manual review.

