Impact
POST /verify/image returns VERIFIED, is_valid: true and admission ADMIT for a size claim about data that is not a valid image. A 25-byte input made of the PNG signature, eight zero bytes, a width of 800, a height of 600 and one more byte, with the claim "The image is 800x600 pixels", is admitted and signed.
The header is read at fixed offsets and never checked, so a real image can also be misread: an extended WebP that is 1000x1000 is read as 9984x3 (reported by the review; not re-run for this draft).
Affected
qwed (PyPI) through 10.0.0. Reproduced on main @ d4ca8dc.
Reachable from POST /verify/image and ImageVerifier.verify_image.
Reproduction
import struct
from qwed_new.core.image_verifier import ImageVerifier
from qwed_new.core.diagnostics import admission_decision
fake = b"\x89PNG\r\n\x1a\n" + b"\x00" * 8 + struct.pack(">II", 800, 600) + b"\x00"
dr = ImageVerifier().verify_image(fake, "The image is 800x600 pixels")
print(len(fake), dr.status.value, dr.developer_fields.get("is_valid"), admission_decision(dr).value)
# 25 VERIFIED True ADMIT
Details
ImageVerifier._extract_metadata (src/qwed_new/core/image_verifier.py:311-349) checks the signature and reads width and height at fixed byte offsets. It does not check the chunk type (IHDR), the chunk length, the CRC, or that the data is long enough to be an image, and it does the same for the other formats it supports.
Patches
Fixed in 11.0.0. Upgrade with pip install -U "qwed>=11.0.0". PNG, JPEG, GIF and WebP containers are walked, and the dimensions are read only when the structure holds together as one image of that size; otherwise a size claim is UNVERIFIABLE. Animated WebP is not read.
Advisory page: https://qwedai.tech/security/advisories/ghsa-vch3-x5fq-m7r2
