Skip to content

Conversation

@ming1
Copy link
Collaborator

@ming1 ming1 commented Jul 9, 2025

A malformed qcow2 header with an invalid cluster_bits value could cause a panic due to a left-shift overflow when calculating the cluster size. This could be triggered by a crafted qcow2 image, leading to a denial of service.

This commit fixes the issue by validating the cluster_bits field before it is used. The value is now checked to be within a valid range (9 to 30, inclusive) to prevent the overflow. If the value is out of range, the header parsing function now returns an error instead of panicking.

A test case with a known malformed header has been added to ensure this vulnerability does not regress.

A malformed qcow2 header with an invalid cluster_bits value could
cause a panic due to a left-shift overflow when calculating the
cluster size. This could be triggered by a crafted qcow2 image,
leading to a denial of service.

This commit fixes the issue by validating the cluster_bits field
before it is used. The value is now checked to be within a valid
range (9 to 30, inclusive) to prevent the overflow. If the value is
out of range, the header parsing function now returns an error instead
of panicking.

A test case with a known malformed header has been added to ensure
this vulnerability does not regress.

Signed-off-by: Ming Lei <[email protected]>
@ming1 ming1 mentioned this pull request Jul 9, 2025
@ming1 ming1 merged commit b3e6634 into main Jul 10, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants