Repository navigation
MIAF derived-image validator skips the auxiliary-image chain of plain coded images #1929
Description
Summary
check_miaf_derivation_constraints() in image_item.cc, introduced in c1f6abf, returns early for plain coded images at the âcoded image: leaf of the derivation chainâ branch.
Because this return occurs before the auxiliary-image recursion later in the function, auxiliary alpha images attached to plain coded primary images are never checked against the derivation constraints in ISO/IEC 23000-22 section 7.3.11.
This means a miaf-branded file can contain a normal coded primary image with an auxl-linked alpha image whose own derivation chain violates MIAF rules, such as a nested grid or an iden-over-iden chain, and still pass validation.
The same auxiliary-image structure is correctly rejected when attached to a grid or overlay primary image.
Reproduction
Create a file with the miaf brand and a normal coded primary image, such as AV1 or HEVC.
Attach an auxiliary image to the primary using an auxl reference.
Make the auxiliary image a derived image with a derivation chain that should violate MIAF constraints. Examples include a grid whose tiles are themselves grids, or two chained iden items.
When ImageItem::verify_decodable() runs on the primary image, check_decode_reference_cycles() succeeds because there is no reference cycle.
Because MIAF validation is enabled, verify_decodable() calls check_miaf_derivation_constraints(primary, MIAF_RANK_OVERLAY, false, ...).
The primary item is classified as CODED. The coded-image branch then immediately returns Error::Ok.
As a result, execution never reaches the get_alpha_channel() check later in the function, and the auxiliary imageâs derivation chain is never validated.
If the same auxiliary image is instead attached to a grid or overlay primary image, validation reaches the auxiliary-image recursion and correctly reports:
âMIAF: derived-image dependencies are not in the order allowed by ISO/IEC 23000-22â
Reachability
I verified this behavior against current master at 2f642b1.
HeifContext::interpret_heif_files() processes auxl references in context.cc around line 943 and calls master_img->set_alpha_channel(image). This applies to plain coded primary images as well as derived images.
Per-item decode validation calls ImageItem::verify_decodable() in context.cc around line 1499, so a plain coded primary image with an attached alpha channel reaches check_miaf_derivation_constraints().
get_alpha_channel(), declared in image_item.h around line 246, returns the auxiliary image associated with the primary.
However, the coded-image branch in image_item.cc around lines 1057-1059 returns Error::Ok before execution reaches the auxiliary-image check around lines 1075-1080.
As a result, an auxiliary derivation chain such as iden-over-iden or a grid-as-alpha is not validated when the primary image is coded, while the same chain is validated when the primary image is a grid or overlay.
Impact
This appears to be a specification-validation issue rather than a direct memory-safety issue.
Files that violate MIAF derivation rules can be accepted while carrying the miaf brand. This is inconsistent with the validatorâs intended behavior that an auxiliary image is a separate image whose own derivation chain must independently satisfy MIAF requirements.
The relevant alpha-plane consumers already contain independent guards introduced by f4fb8bd, bc7cf37, c0a63aa, 1fcada5, and cd365da, so I do not currently see this as a standalone memory-safety vulnerability.
The issue does, however, bypass one layer of MIAF validation and creates inconsistent behavior depending on whether the primary image is coded or derived.
Suggested fix
Validate the auxiliary image before the rank-based early returns.
The simplest approach would be to move the existing get_alpha_channel() validation block above the child-rank dispatch so that auxiliary derivation chains are checked for every item type, including coded images.
Alternatively, the same validation could be added directly to the coded-image branch before it returns Error::Ok.
The existing memoization behavior should remain in place so that shared items are not unnecessarily revalidated.
I can also provide a PR with a regression test modeled after tests/parallel_grid_deadlock.cc.
Activity
Check the MIAF derivation chain of auxiliary images of coded images (#âĶ
farindk commentedon Oct 3, 2026
Thank you. Should be fixed in the above commit. Please confirm.
overtimepog commentedon Oct 9, 2026
Confirmed Fixed.
I built master at
7dde893and the parent commit689d0c3, then ran the new MIAF regression tests:miafbrand" case decodes successfully (err.code == heif_error_Ok) â reproducing the bug exactly as described.7dde893, the same case now correctly returnsheif_error_Invalid_input, and the full MIAF test suite (10 assertions / 5 cases) passes, including the "no brand â still accepted" and "grid primary â still rejected" consistency checks.The fix (falling through to the auxiliary-image check for coded leaves instead of returning early) matches the root cause described above. Thanks for the quick turnaround!
farindk commentedon Oct 9, 2026
Thanks for cross checking.