Lookup for vulnerable packages by Package URL.

Purlpkg:deb/debian/golang-github-ulikunitz-xz@0.5.15-1
Typedeb
Namespacedebian
Namegolang-github-ulikunitz-xz
Version0.5.15-1
Qualifiers
Subpath
Is_vulnerablefalse
Next_non_vulnerable_versionnull
Latest_non_vulnerable_versionnull
Affected_by_vulnerabilities
Fixing_vulnerabilities
0
url VCID-aag6-jhbk-qqd6
vulnerability_id VCID-aag6-jhbk-qqd6
summary
github.com/ulikunitz/xz leaks memory when decoding a corrupted multiple LZMA archives
### Summary

It is possible to put data in front of an LZMA-encoded byte stream without detecting the situation while reading the header. This can lead to increased memory consumption because the current implementation allocates the full decoding buffer directly after reading the header. The LZMA header doesn't include a magic number or has  a checksum to detect such an issue according to the [specification](https://github.com/jljusten/LZMA-SDK/blob/master/DOC/lzma-specification.txt).

Note that the code recognizes the issue later while reading the stream, but at this time the memory allocation has already been done.

### Mitigations

The release v0.5.15 includes following mitigations:

- The ReaderConfig DictCap field is now interpreted as a limit for the dictionary size.
- The default is 2 Gigabytes - 1 byte (2^31-1 bytes).
- Users can check with the [Reader.Header] method what the actual values are in  their LZMA files and set a smaller limit using ReaderConfig.
- The dictionary size will not exceed the larger of the file size and the minimum dictionary size. This is another measure to prevent huge memory allocations for the dictionary.
- The code supports stream sizes only up to a pebibyte (1024^5).

Note that the original v0.5.14 version had a compiler error for 32 bit platforms, which has been fixed by v0.5.15.

### Methods affected

Only software that uses [lzma.NewReader](https://pkg.go.dev/github.com/ulikunitz/xz/lzma#NewReader) or [lzma.ReaderConfig.NewReader](https://pkg.go.dev/github.com/ulikunitz/xz/lzma#ReaderConfig.NewReader) is affected. There is no issue for software using the xz functionality.

I thank  @GregoryBuligin for his report, which is provided below.

### Summary
When unpacking a large number of LZMA archives, even in a single goroutine, if the first byte of the archive file is 0 (a zero byte added to the beginning), an error __writeMatch: distance out of range__ occurs. Memory consumption spikes sharply, and the GC clearly cannot handle this situation.

### Details
Judging by the error  __writeMatch: distance out of range__, the problems occur in the code around this function.
https://github.com/ulikunitz/xz/blob/c8314b8f21e9c5e25b52da07544cac14db277e89/lzma/decoderdict.go#L81

### PoC
Run a function similar to this one in 1 or several goroutines on a multitude of LZMA archives that have a 0 (a zero byte) added to the beginning.
```
const ProjectLocalPath = "some/path"
const TmpDir = "tmp"

func UnpackLZMA(lzmaFile string) error {
	file, err := os.Open(lzmaFile)
	if err != nil {
		return err
	}
	defer file.Close()

	reader, err := lzma.NewReader(bufio.NewReader(file))
	if err != nil {
		return err
	}

	tmpFile, err := os.CreateTemp(TmpDir, TmpLZMAPrefix)
	if err != nil {
		return err
	}
	defer func() {
		tmpFile.Close()
		_ = os.Remove(tmpFile.Name())
	}()

	sha256Hasher := sha256.New()
	multiWriter := io.MultiWriter(tmpFile, sha256Hasher)

	if _, err = io.Copy(multiWriter, reader); err != nil {
		return err
	}

	unpackHash := hex.EncodeToString(sha256Hasher.Sum(nil))
	unpackDir := filepath.Join(
		ProjectLocalPath, unpackHash[:2],
	)
	_ = os.MkdirAll(unpackDir, DirPerm)

	unpackPath := filepath.Join(unpackDir, unpackHash)

	return os.Rename(tmpFile.Name(), unpackPath)
}
```



### Impact
Servers with a small amount of RAM that download and unpack a large number of unverified LZMA archives
references
0
reference_url https://access.redhat.com/hydra/rest/securitydata/cve/CVE-2025-58058.json
reference_id
reference_type
scores
0
value 5.3
scoring_system cvssv3
scoring_elements CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
url https://access.redhat.com/hydra/rest/securitydata/cve/CVE-2025-58058.json
1
reference_url https://api.first.org/data/v1/epss?cve=CVE-2025-58058
reference_id
reference_type
scores
0
value 0.00062
scoring_system epss
scoring_elements 0.19136
published_at 2026-04-24T12:55:00Z
1
value 0.00062
scoring_system epss
scoring_elements 0.19506
published_at 2026-04-04T12:55:00Z
2
value 0.00062
scoring_system epss
scoring_elements 0.19223
published_at 2026-04-07T12:55:00Z
3
value 0.00062
scoring_system epss
scoring_elements 0.19301
published_at 2026-04-08T12:55:00Z
4
value 0.00062
scoring_system epss
scoring_elements 0.19354
published_at 2026-04-09T12:55:00Z
5
value 0.00062
scoring_system epss
scoring_elements 0.19357
published_at 2026-04-11T12:55:00Z
6
value 0.00062
scoring_system epss
scoring_elements 0.19308
published_at 2026-04-12T12:55:00Z
7
value 0.00062
scoring_system epss
scoring_elements 0.19253
published_at 2026-04-13T12:55:00Z
8
value 0.00062
scoring_system epss
scoring_elements 0.19215
published_at 2026-04-16T12:55:00Z
9
value 0.00062
scoring_system epss
scoring_elements 0.19224
published_at 2026-04-18T12:55:00Z
10
value 0.00062
scoring_system epss
scoring_elements 0.19237
published_at 2026-04-21T12:55:00Z
11
value 0.00065
scoring_system epss
scoring_elements 0.2027
published_at 2026-04-02T12:55:00Z
url https://api.first.org/data/v1/epss?cve=CVE-2025-58058
2
reference_url https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2025-58058
reference_id
reference_type
scores
url https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2025-58058
3
reference_url https://ftp.suse.com/pub/projects/security/yaml/suse-cvss-scores.yaml
reference_id
reference_type
scores
0
value 5.3
scoring_system cvssv3.1
scoring_elements CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
url https://ftp.suse.com/pub/projects/security/yaml/suse-cvss-scores.yaml
4
reference_url https://github.com/ulikunitz/xz
reference_id
reference_type
scores
0
value 5.3
scoring_system cvssv3.1
scoring_elements CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
1
value MODERATE
scoring_system generic_textual
scoring_elements
url https://github.com/ulikunitz/xz
5
reference_url https://github.com/ulikunitz/xz/commit/88ddf1d0d98d688db65de034f48960b2760d2ae2
reference_id
reference_type
scores
0
value 5.3
scoring_system cvssv3.1
scoring_elements CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
1
value MODERATE
scoring_system generic_textual
scoring_elements
url https://github.com/ulikunitz/xz/commit/88ddf1d0d98d688db65de034f48960b2760d2ae2
6
reference_url https://github.com/ulikunitz/xz/security/advisories/GHSA-jc7w-c686-c4v9
reference_id
reference_type
scores
0
value 5.3
scoring_system cvssv3.1
scoring_elements CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
1
value MODERATE
scoring_system generic_textual
scoring_elements
url https://github.com/ulikunitz/xz/security/advisories/GHSA-jc7w-c686-c4v9
7
reference_url https://nvd.nist.gov/vuln/detail/CVE-2025-58058
reference_id
reference_type
scores
0
value 5.3
scoring_system cvssv3.1
scoring_elements CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L
1
value MODERATE
scoring_system generic_textual
scoring_elements
url https://nvd.nist.gov/vuln/detail/CVE-2025-58058
8
reference_url https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1112508
reference_id 1112508
reference_type
scores
url https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1112508
9
reference_url https://bugzilla.redhat.com/show_bug.cgi?id=2391585
reference_id 2391585
reference_type
scores
url https://bugzilla.redhat.com/show_bug.cgi?id=2391585
fixed_packages
0
url pkg:deb/debian/golang-github-ulikunitz-xz@0.5.15-1
purl pkg:deb/debian/golang-github-ulikunitz-xz@0.5.15-1
is_vulnerable false
affected_by_vulnerabilities
resource_url http://public2.vulnerablecode.io/packages/pkg:deb/debian/golang-github-ulikunitz-xz@0.5.15-1
aliases CVE-2025-58058, GHSA-jc7w-c686-c4v9
risk_score 3.1
exploitability 0.5
weighted_severity 6.2
resource_url http://public2.vulnerablecode.io/vulnerabilities/VCID-aag6-jhbk-qqd6
Risk_scorenull
Resource_urlhttp://public2.vulnerablecode.io/packages/pkg:deb/debian/golang-github-ulikunitz-xz@0.5.15-1