Reject non-PNG signature export data (#1651)

This commit is contained in:
red person
2026-06-03 08:10:54 +03:00
committed by GitHub
parent 558d6ddf24
commit 40e1d6e876
2 changed files with 17 additions and 2 deletions

View File

@@ -34,9 +34,12 @@ def _decode_png_data(data_png: str) -> bytes:
if "," in raw:
raw = raw.split(",", 1)[1]
try:
return base64.b64decode(raw, validate=True)
decoded = base64.b64decode(raw, validate=True)
except Exception as e:
fail(f"data_png is not valid base64: {e}")
if not decoded.startswith(b"\x89PNG\r\n\x1a\n"):
fail("data_png is not a PNG image")
return decoded
def cmd_list(args):