Skip to content
DoS Write-up Advanced

An Infinite Loop in Samsung’s UltraHDR Stack

An infinite loop in the UltraHDR image parser causes the decoding process to hang and consume 100% CPU when it encounters a byte it cannot parse. An attacker could trigger a denial of service by supplying a crafted HDR JPEG file.

medium.com

Published on medium.com

So I found a loop that doesn’t stop. That’s the whole story.

Kareem Hesham, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The error handler in the parsing loop did not set an error flag or advance the input position, so the loop repeated indefinitely on the same unparseable byte.

Impact

The vulnerability causes a process-level denial of service (hang and high CPU) but no memory corruption; the impact is limited because Samsung Gallery does not call the vulnerable function during normal image viewing.

What the attacker needed

Crafted HDR JPEG file; ability to supply file to vulnerable parser

The fix

The fix adds a check for an internal error flag to the loop condition so the loop exits when an error occurs; this fix exists upstream in libultrahdr since v1.0.0 and in AOSP, but the device shipped a pre-fix version.

How it was found

  1. Create a file with a variant byte (0x01, 0x02, or 0x03) at offset 0.
  2. Include a primary JPEG whose XMP metadata contains at least one byte the grammar cannot consume.
  3. Include a secondary JPEG whose XMP metadata passes all required hdrgm field checks.
  4. Run the crafted file through the uhdr_decode() function (e.g., via a harness).
  5. Observe the process hangs and consumes high CPU until killed.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A parser is a program that reads a file and checks its structure. Here, when the parser met a byte it did not understand, it reported an error but did not stop or move forward, so it kept trying the same byte forever. This made the process use all the CPU and hang until it was killed.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.