Reject ambiguous PNG headers before pixel validation

This commit is contained in:
Artyom
2026-11-06 21:33:09 +03:00
parent bcbd4ebc02
commit 7c8a1a6489
21 changed files with 498 additions and 34 deletions
+4 -1
View File
@@ -10,7 +10,7 @@ from httpx import AsyncClient, Response
from conftest import actor, make_chat, register, resolve, running_app, scalar
from fakes import MemoryObjectStorage
from messenger.attachments.application.ports import ObjectStorage
from pictures import BROKEN_PNG, GIF, JPEG, SAMPLE, WEBP, png
from pictures import BROKEN_PNG, DUPLICATE_IHDR_PNG, GIF, JPEG, SAMPLE, WEBP, png
LIMIT = 10_485_760
PNG = {"Content-Type": "image/png"}
@@ -182,6 +182,7 @@ async def test_pixel_limit_is_read_from_header(
("content", "header"),
[
(BROKEN_PNG, "image/png"),
(DUPLICATE_IHDR_PNG, "image/png"),
(JPEG, "image/png"),
(GIF, "image/png"),
(WEBP, "image/png"),
@@ -194,6 +195,8 @@ async def test_pixel_limit_is_read_from_header(
(SAMPLE, "image/gif"),
],
ids=[
"invalid-zlib",
"duplicate-ihdr",
"jpeg-as-png",
"gif-as-png",
"webp-as-png",