/

CVE-2026-24844

Severity:

HIGH RISK

(7.9)

Command Injection in Melange Pipelines

CVE-2026-24844

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution in Build Environment

Severity:

HIGH RISK

(7.9)

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

Melange pipelines from versions 0.3.0 to before 0.40.3 embed user-supplied values into shell scripts without proper quoting when used in the working-directory field with ${{vars.*}} or ${{inputs.*}} substitutions.

An attacker who can control these build input values, even without modifying the pipeline definition itself, may execute arbitrary shell commands during the build process.

Affected context

This vulnerability appears in Melange declarative pipelines where:

  • The working-directory field is set dynamically using ${{vars.*}} or ${{inputs.*}} substitutions
  • Build inputs or variables can be influenced by less-trusted users or external automation
  • The effective value is later interpolated into shell scripts that are executed as part of the build

The risk is present in CI/CD or build environments where Melange runs with elevated privileges, access to secrets, or access to internal package repositories.

Exploit preconditions

  • Attack surface: Melange build configuration and any interface that supplies pipeline variables or build inputs (e.g., CI parameters, config files, API calls).
  • Required access: Ability to control the values of vars.* or inputs.* referenced in the working-directory field; no need to change the pipeline YAML itself.
  • Trigger point: Execution of the build pipeline step that generates and runs shell scripts using the unescaped working-directory value.
  • Why exploitation is possible: The working-directory value is interpolated directly into shell command contexts without appropriate quoting or escaping, allowing crafted values to break out of the intended path and inject additional shell syntax.

Why this happens

The core issue maps to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

Melange treats working-directory as a simple string but later embeds it directly into shell scripts without enforcing safe quoting. When ${{vars.*}} or ${{inputs.*}} substitutions are used, untrusted data flows into a command line context where shell metacharacters (e.g., ;, &&, |, backticks, or $()) are interpreted as control operators.

This design implicitly assumes that substituted values are safe file system paths, but it does not enforce or encode that assumption, allowing an attacker-controlled value to modify the structure of the executed command instead of just its argument.

Potential impact

  • Execution of arbitrary shell commands during the build process
  • Compromise of the build agent or CI worker environment
  • Theft or exposure of build-time secrets, credentials, and signing keys
  • Manipulation or backdooring of built APK packages
  • Lateral movement within the CI/CD or build infrastructure

General mitigation guidance

Effective mitigation focuses on treating all substituted values as untrusted and ensuring they cannot alter shell command structure:

  • Use APIs or execution models that avoid constructing shell command strings; prefer direct process invocation with argument arrays where possible.
  • Apply strict quoting and escaping to any variable interpolated into shell commands, especially path-like fields such as working-directory.
  • Constrain working-directory to validated, whitelist-based path patterns (e.g., alphanumeric, _, -, /) and reject values containing shell metacharacters.
  • Separate configuration privileges so that untrusted parties cannot provide values for fields that end up in execution-critical contexts.
  • Run build jobs with least privilege, minimizing access to secrets and sensitive file system locations so that impact is limited even if injection occurs.

How teams detect issues like this

Organizations can detect and manage this class of issue through:

  • Static analysis of pipeline definitions: Flagging uses of ${{vars.*}} or ${{inputs.*}} in execution-related fields (like working-directory) that are later passed to shell commands without a clear quoting strategy.
  • Pattern-based scanning: Searching for command templates or script fragments that concatenate user-controlled values into shell strings instead of passing them as separate arguments.
  • Code review checklists: Ensuring reviewers specifically verify how Melange variables and inputs are consumed when they influence paths, commands, or environment variables.
  • Policy enforcement in CI: Adding automated checks in CI to block pipelines that interpolate untrusted inputs directly into shell execution contexts.

Sources

SourceLink
github.comgithub.com/chainguard-dev/melange/commit/e51ca30cfb63178f5a86997d23d3fff0359fa6c8
github.comgithub.com/chainguard-dev/melange/security/advisories/GHSA-vqqr-rmpc-hhg2

Frequently asked

questions

Exploitability depends on who can control the values used in ${{vars.*}} or ${{inputs.*}}. If those values are derived from user-controlled sources (e.g., CI parameters, external configuration), an attacker with access to those inputs can potentially achieve code execution in the build environment.

No. The issue specifically affects scenarios where the attacker cannot change the pipeline YAML but can provide values for vars or inputs consumed in the working-directory field. That control over input is sufficient to trigger command injection.

Ensure that any variable substituted into working-directory or similar fields is either strictly validated as a safe path or passed to the OS as a separate argument rather than being concatenated into a shell command. Using APIs that avoid shell parsing entirely is the most robust pattern.

Design pipeline engines so that user-provided values never directly shape shell command strings. Enforce strong validation on any data that influences execution contexts, adopt a default-deny approach for shell metacharacters, and incorporate automated security checks into CI/CD workflows to detect unsafe interpolation patterns early.

Find out what's already
exploitable in your codebase.