Skip to content

Prevent Telegram short media IDs from aborting message parsing - #2564

Merged
abrignoni merged 3 commits into
abrignoni:mainfrom
mvanhorn:fix/1145-telegram-short-media-ids
Oct 24, 2026
Merged

abrignoni merged 3 commits into
abrignoni:mainfrom
mvanhorn:fix/1145-telegram-short-media-ids

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Telegram message parsing can stop with a buffer-unpacking error when a referenced media item contains a short ID, preventing messages from being reported. The file, image and webpage decoders attempted to unpack any nonempty ID as a 32-bit integer followed by a 64-bit integer. IDs shorter than the required 12 bytes therefore raised an exception.

All three decoders now require at least 12 bytes before unpacking an ID. Missing or short IDs use (None, None), and nonempty short IDs produce a log entry with the media type and byte length. Message text and independently decoded media metadata are retained. A regression test constructs a referenced file with a one-byte ID and checks that the message survives and the expected warning is logged.

python_tests reported no discovered tests; the transcript does not show the new regression test running.
repo_lint was invoked three times, but no output or exit status is recorded.
python admin/test/scripts/test_no_pypi_blackboxprotobuf.py was invoked, but no result is recorded.
python admin/scripts/check_claim_language.py was invoked, but no result is recorded.
python admin/scripts/check_artifact_descriptions.py was invoked, but no result is recorded.
python admin/scripts/check_conversation_column_order.py was invoked, but no result is recorded.
python admin/scripts/check_artifact_paths.py was invoked, but no result is recorded.
python admin/scripts/check_container_markers.py was invoked, but no result is recorded.

python admin/scripts/check_html_safety.py was invoked, but no result is recorded.
python admin/scripts/check_report_local_paths.py was invoked, but no result is recorded.
python admin/scripts/check_source_path.py was invoked, but no result is recorded.
python admin/scripts/check_source_file_column.py was invoked, but no result is recorded.
python admin/scripts/check_vendored.py was invoked, but no result is recorded.
python admin/scripts/lint_changed.py --base-ref "$BASE" ${{ steps.changed-files-py.outputs.all_changed_files }} appears in the transcript, but no resolved arguments or result are recorded.
Ran python3 -m pytest -q admin/test/scripts/test_telegram_message_media_ids.py in a Linux container (python:3.12) for the iLEAPP telegramMessages change; 2 tests passed.

Refs #1145

For a new or changed artifact

  • Ran the tool against a real extraction and confirmed the row counts, not just that it imports.
    The "Ran the tool against a real extraction and confirmed the row counts, not just that it imports" step needs a person and was not done for the iLEAPP telegramMessages change.
  • Ran python admin/scripts/check_artifact_output.py <report folder> on that report and fixed or documented every finding. An empty or constant column is often a real result (no group chats, coarse location denied); the fix for those is a sentence in the artifact's notes naming the column and saying it was empty or uniform, which is also what stops the checker reporting it.
    The "Ran python admin/scripts/checkartifactoutput.py on that report and fixed or documented every finding. An empty or constant column is often a real result ; the fix for those is a sentence in the artifact's notes naming the column and saying it was empty or uniform, which is also what stops the checker reporting it" step needs a person and was not done for the iLEAPP telegramMessages change.
  • Checked it against a second app data directory where the platform provides one (a second user, account, or container). --compare <multi-container report> reads the scaling for you: it should be exactly double.
    No local test run is recorded for the iLEAPP telegramMessages change to scripts/artifacts/telegramMesssages.py.
  • notes, description and sample_data say only what the data shows, and the numbers were re-derived from the finished run.

Anything reviewers should know

Nothing beyond what is described above.

All three decoders now require at least 12 bytes before unpacking an ID.
Missing or short IDs use (None, None), and nonempty short IDs produce a
log entry with the media type and byte length. Message text and
independently decoded media metadata are retained. A regression test
constructs a referenced file with a one-byte ID and checks that the
message survives and the expected warning is logged.

Fixes abrignoni#1145
@github-actions

Copy link
Copy Markdown

Thanks for the contribution!

The changed artifact modules cite public research images in their sample_data, so a maintainer can generate the test fixtures from those images. Nothing is needed from you, though you are welcome to add the fixtures yourself with admin/test/scripts/make_test_data.py.

  • telegramMesssages.py: cites abe_ios16, dexter_ios18, felix23_ios16, felix_ios17, hickman_ios13, hickman_ios14, iphone11_ios17, otto_ios17; a maintainer can generate the fixture.

@github-actions github-actions Bot added the fixture-needed Cites a public image; a maintainer can generate the fixture label Oct 24, 2026
@abrignoni

Copy link
Copy Markdown
Owner

Thanks for digging into this one, and for the test.

#2566 landed today. A media entry that can't be read is now logged and noted on its row instead of stopping the whole artifact. Your change still adds something on top of that: an embedded file with a damaged ID keeps its name, MIME type and thumbnail instead of showing as unreadable. So I'd like to merge it.

Two small changes first:

  • Please change "Fixes telegramMessages Artifact Error #1145" to "Refs telegramMessages Artifact Error #1145". The reporter's crash went through the referenced-media path, which this change alone doesn't cover, and we never got their data to confirm the fix.
  • In the notes, please say this was only exercised on constructed data. Something like: "This handling was exercised on constructed test data; no tested image produced a short ID."

When you push, please merge main in first so CI runs against #2566 and #2568. #2568 changes one of the #2566 tests so it no longer depends on a short ID failing, which your change would otherwise break.

abrignoni added a commit to mvanhorn/iLEAPP that referenced this pull request Oct 24, 2026
The test made an embedded media entry unreadable with a 1-byte ID. Once short
IDs decode to an unknown ID (abrignoni#2564) that entry reads fine and the test fails
for the wrong reason. A media entry that ends inside a field's length prefix
fails in the reader itself, whatever the ID handling does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@abrignoni

Copy link
Copy Markdown
Owner

I went ahead and made both changes so this doesn't wait on you. The PR now says Refs #1145, the notes say the handling was only exercised on constructed test data, and main is merged in. Nothing more needed from you. Thanks again for the fix.

@abrignoni
abrignoni merged commit 473b57b into abrignoni:main Oct 24, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fixture-needed Cites a public image; a maintainer can generate the fixture

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants