CVE-2026-29050
Description
melange allows users to build apk packages using declarative pipelines. Starting in version 0.32.0 and prior to version 0.43.4, an attacker who can influence a melange configuration file — for example through pull-request-driven CI or build-as-a-service scenarios — could set pipeline[].uses to a value containing ../ sequences or an absolute path. The (*Compiled).compilePipeline function in pkg/build/compile.go passed uses directly to filepath.Join(pipelineDir, uses + ".yaml") without validating the value, so the resolved path could escape each --pipeline-dir and read an arbitrary YAML-parseable file visible to the melange process. Because the loaded file is subsequently interpreted as a melange pipeline and its runs: block is executed via /bin/sh -c in the build sandbox, this additionally allowed shell commands sourced from an out-of-tree file to run during the build, bypassing the review boundary that normally covers the in-tree pipeline definition. The issue is fixed in melange v0.43.4 via commit 5829ca4. The fix rejects uses values that are absolute paths or contain .., and verifies (via filepath.Rel after filepath.Clean) that the resolved target remains within the pipeline directory. As a workaround, only run melange build against configuration files from trusted sources. In CI systems that build user-supplied melange configs, gate builds behind manual review of pipeline[].uses values and reject any containing .. or leading /.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
chainguard.dev/melangeGo | >= 0.32.0, < 0.43.4 | 0.43.4 |
Affected products
1Patches
15829ca45cfe1Merge commit from fork
1 file changed · +11 −1
pkg/build/compile.go+11 −1 modified@@ -225,14 +225,24 @@ func (c *Compiled) compilePipeline(ctx context.Context, sm *SubstitutionMap, pip // When compiling an already-compiled config, `uses` will be redundant and FYI only, // so ignore it if there is also a `pipelines` spelled out. if uses != "" && len(pipeline.Pipeline) == 0 { + // Validate that 'uses' does not contain path traversal sequences or absolute paths. + if filepath.IsAbs(uses) || strings.Contains(uses, "..") { + return fmt.Errorf("invalid pipeline 'uses' value %q: must not contain absolute paths or '..' sequences", uses) + } + var data []byte // Set this to fail up front in case there are no pipeline dirs specified // and we can't find them. err := fmt.Errorf("could not find 'uses' pipeline %q", uses) for _, pd := range c.PipelineDirs { log.Debugf("trying to load pipeline %q from %q", uses, pd) - data, err = os.ReadFile(filepath.Join(pd, uses+".yaml")) // #nosec G304 - Loading pipeline definition from configured directory + target := filepath.Join(pd, uses+".yaml") + // Verify the resolved path is still within the pipeline directory. + if rel, err := filepath.Rel(pd, filepath.Clean(target)); err != nil || strings.HasPrefix(rel, "..") { + return fmt.Errorf("pipeline 'uses' value %q resolves outside pipeline directory %q", uses, pd) + } + data, err = os.ReadFile(target) // #nosec G304 - Loading pipeline definition from configured directory if err == nil { log.Debugf("Found pipeline %s", string(data)) break
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
4- github.com/chainguard-dev/melange/security/advisories/GHSA-98f2-w9h9-7fp9nvdMitigationPatchVendor AdvisoryWEB
- github.com/advisories/GHSA-98f2-w9h9-7fp9ghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2026-29050ghsaADVISORY
- github.com/chainguard-dev/melange/commit/5829ca45cfe14dfeb73ffb716992db3b1b7892acghsaWEB
News mentions
1- The npm Threat Landscape: Attack Surface and Mitigations (Updated May 1)Unit 42 · May 2, 2026