fix(media): validate PNG headers - #1252
Open
Promise Emmanuel Oluwadare (promiseeuler) wants to merge 1 commit into
Open
fix(media): validate PNG headers#1252 Promise Emmanuel Oluwadare (promiseeuler) wants to merge 1 commit into
Promise Emmanuel Oluwadare (promiseeuler) wants to merge 1 commit into
Conversation
Promise Emmanuel Oluwadare (promiseeuler)
requested a review
from a team
as a code owner
August 23, 2026 16:53
Promise Emmanuel Oluwadare (promiseeuler)
requested review from
Naveed Jooma (njooma) and
Ethan (stuqdog)
August 23, 2026 16:53
|
|
Member
|
👋 Thanks for requesting a review from the team! We aim to review PRs within one business day. If this is urgent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While using
viam-sdk==0.80.0, I found thatViamImageaccepts PNG data with an invalid signature or a non-IHDRfirst chunk and reports dimensions from those bytes. For example, an invalid payload can be reported as640x480.The PNG parser was constructing
ValueErrorobjects without raising them, and it compared abytessignature with a list of integers. This change raises the validation errors and compares the signature withbytes, allowingViamImageto fall back to unknown dimensions for malformed PNG data.Regression coverage includes both an invalid signature with a plausible
IHDRchunk and a valid signature with an invalid first chunk.Validation
uv run ruff format --check src/viam/media/video.py tests/test_media.pyuv run ruff check src/viam/media/video.py tests/test_media.pyuv run pyright— 0 errors (1 existing warning insrc/viam/module/types.py)uv run pytest -q tests/test_media.py— 9 passeduv run pytest -q— 866 passed, 5 skipped becauseviam-serveris not installedgit diff --check