AVIF Decoder Error Handling for Corrupted OBUs

When decoding AVIF (AV1 Image File Format) images, bitstream corruption within Open Bitstream Units (OBUs) can cause crashes, visual artifacts, or security vulnerabilities. This article details the standard error-handling procedures an AVIF decoder must implement when encountering malformed or corrupted OBUs, covering parsing validation, critical versus non-critical classification, safe recovery mechanisms, and memory security.

1. Bitstream Validation and Bounds Checking

Before decoding payloads, the decoder must validate the syntactic integrity of the OBU framing.

2. Distinguishing Critical from Non-Critical OBUs

An AVIF decoder must not treat all OBUs equally when errors occur. Instead, it must classify the unit to decide whether to abort or proceed.

3. Safe Skipping via Size Delimitation

When an error is detected in an OBU that is not fatal to the overall decode process:

4. Tile-Level Error Concealment

AVIF images often utilize tiling for parallel decoding. If a corruption occurs within an OBU_TILE_GROUP:

5. Security and Memory Safety Controls

Corrupted OBUs are a frequent vector for exploitation. Decoders must enforce strict runtime guards:

6. Deterministic Error Signaling

An AVIF decoder must exit cleanly when corruption prevents successful processing. It should return specific, actionable status codes (such as AVIF_RESULT_BMFF_PARSE_FAILED, AVIF_RESULT_CORRUPTED_DATA, or AVIF_RESULT_DECODE_FRAME_FAILED) rather than failing silently or causing application-level crashes. State machines must be reset to allow the decoder context to be safely reused or destroyed without memory leaks.