/

CVE-2026-28279

Severity:

HIGH RISK

(7.3)

OS Command Injection in osctrl Admin Environment Hostname

CVE-2026-28279

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution on Enrolling Endpoints

Severity:

HIGH RISK

(7.3)

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

osctrl's admin interface allows an authenticated administrator to inject arbitrary shell commands via the environment hostname field, which are then embedded into enrollment one-liner scripts without proper shell escaping.

Any endpoint that enrolls using a compromised environment executes these commands as root/SYSTEM before osquery is installed, enabling stealthy remote code execution and full endpoint compromise.

Affected context

This vulnerability arises in deployments of osctrl where administrators create or edit environment configurations through the osctrl-admin interface.

The hostname parameter from an environment is inserted into generated enrollment scripts via Go's text/template package and used within shell commands without proper escaping or quoting.

Any system that runs these enrollment one-liners (for example during initial endpoint onboarding or automated provisioning) becomes a potential execution target if the hostname field has been maliciously crafted.

Exploit preconditions

  • Attack surface: Web-based osctrl-admin management interface, specifically the environment creation/editing functionality.
  • Required access: Valid authenticated administrator account (or an attacker who has compromised such an account).
  • Trigger point: Execution of generated enrollment one-liner scripts on endpoints using the compromised environment configuration.
  • Why exploitation is possible: The hostname value is treated as trusted input and interpolated directly into shell command strings by Go's text/template engine without shell escaping, allowing special characters and separators to break out of the intended context and inject arbitrary commands.

Why this happens

The underlying issue is a classic OS command injection pattern (CWE-78), where user-controlled data is composed into shell commands without robust validation or quoting.

In this case, the environment hostname parameter—controlled via the admin UI—is embedded in shell one-liner enrollment scripts using Go templates, but the templates do not escape shell metacharacters.

This creates a situation where the hostname value is effectively part of the command line, so an attacker can inject additional commands or alter the structure of the script that runs on endpoints during enrollment.

Because these scripts are typically executed with elevated privileges (root/SYSTEM), the injected commands inherit high-level permissions and execute prior to agent installation and monitoring.

Potential impact

  • Remote execution of arbitrary commands on every endpoint that enrolls using a compromised environment.
  • Installation of persistent backdoors or malicious software during the provisioning process.
  • Exfiltration of credentials, secrets, and sensitive configuration from endpoints.
  • Full compromise of endpoint integrity, including tampering with security controls and logging.
  • Use of compromised endpoints as a foothold for lateral movement within the network.

General mitigation guidance

Effective mitigation focuses on breaking the assumption that configuration fields can safely be interpolated into shell commands and on limiting the blast radius of administrative actions.

Recommended patterns include:

  • Avoid constructing shell commands via string concatenation or templates with untrusted data; prefer direct execution of binaries with parameterized arguments (e.g., exec-style APIs) where the runtime does not invoke a shell.
  • If shell usage is unavoidable, apply rigorous escaping and quoting functions specifically designed for shell contexts, ensuring user-supplied values cannot introduce additional commands or change syntax.
  • Constrain and validate environment fields like hostnames against strict allowlists (e.g., DNS-safe character sets and length limits) to prevent shell metacharacters or control characters from being accepted.
  • Implement role separation and least privilege in the admin UI so that only trusted, minimal roles can modify environment configurations that influence enrollment scripts.
  • Treat enrollment scripts as sensitive deployment artifacts: store them in controlled repositories, review changes, and avoid dynamic composition with arbitrary text where possible.

How teams detect issues like this

Organizations can approach detection on several levels:

  • Static analysis and code scanning:
  • Flag usage of templating systems (such as Go's text/template) that produce shell commands from mixed static and user-controlled data.
  • Identify patterns where request parameters or database-backed fields are inserted into strings passed to shell execution APIs or script templates.
  • Enforce code review rules around any component that generates deployment or enrollment scripts.
  • Code review and governance:
  • During reviews, scrutinize any feature that builds command-line one-liners, bootstrap scripts, or installers from configuration data.
  • Require security sign-off for changes to environment configuration handling and script generation logic.
  • Maintain documented patterns for safe command execution and reject ad hoc string-based command construction.
  • Operational monitoring:
  • Monitor generated enrollment scripts for unexpected characters or commands in fields that should be simple identifiers (e.g., hostnames).
  • Correlate abnormal process execution on freshly enrolled endpoints—especially pre-agent and root/SYSTEM activity—with recent environment configuration changes.
  • Optionally employ integrity checks or file-change monitoring on script distribution points to detect tampering.

Automated SAST tools and CI-integrated linters can assist by surfacing command construction anti-patterns and template misuse early in the development lifecycle.

Sources

SourceLink
github.comgithub.com/jmpsec/osctrl/pull/777
github.comgithub.com/jmpsec/osctrl/pull/780
github.comgithub.com/jmpsec/osctrl/security/advisories/GHSA-rchw-322g-f7rm

Frequently asked

questions

The immediate exploitation path requires access to the osctrl-admin interface with administrator privileges. Once a malicious environment is configured, the impact extends to any endpoint that subsequently runs the generated enrollment script, effectively turning ordinary enrollment operations into a remote code execution channel.

An attacker must either possess valid osctrl administrator credentials or have compromised an account with equivalent privileges. There is no need for direct access to endpoints; execution occurs when those endpoints enroll using the malicious environment.

Refactor script and command generation so that user-controlled values are never embedded directly into shell command lines. Use APIs that execute binaries with structured arguments instead of passing strings to a shell, validate and constrain configuration fields (such as hostnames) to safe character sets, and introduce explicit escaping routines only where strictly necessary.

Adopt a design rule that configuration values are data, not code: they should never be treated as pieces of shell commands or scripts. Implement secure coding guidelines for command execution and templating, enforce strict validation on all admin-supplied fields, add automated checks for command-injection patterns, and include security review for features that generate deployment, installation, or enrollment scripts.

Find out what's already
exploitable in your codebase.