Closed Bug 2014899 Opened 9 months ago Closed 9 months ago

AssertedCast error: Cannot cast 9223372036855000000 from uint64_t to int64_t: out of range [@ mozilla::WebMContainerParser::ParseStartAndEndTimestamps]

Categories

(Core :: Audio/Video: Playback, defect)

x86_64
Linux
defect

Tracking

()

VERIFIED FIXED
149 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr140 --- wontfix
firefox147 --- wontfix
firefox148 --- wontfix
firefox149 --- verified

People

(Reporter: tsmith, Assigned: padenot)

Details

(4 keywords, Whiteboard: [bugmon:bisected,confirmed][adv-main149-])

Crash Data

Attachments

(2 files, 1 external file)

Reproduced on mozilla-central rev ed1c0b4f0bbe (built with: --enable-debug --enable-fuzzing).

Testcase can be reproduced using the following commands:

$ pip install fuzzfetch grizzly-framework pipx --upgrade
$ python -m pipx ensurepath
$ fuzzfetch --build ed1c0b4f0bbe --debug --fuzzing  -n firefox
$ grizzly-replay-bugzilla ./firefox/firefox <bugid>
[@ MOZ_CrashSequence]

    ==45991==ERROR: UndefinedBehaviorSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7b68b4073f13 bp 0x7b689c81f5d0 sp 0x7b689c81f0f0 T46031)
    ==45991==The signal is caused by a WRITE memory access.
    ==45991==Hint: address points to the zero page.
        #0 0x7b68b4073f13 in MOZ_CrashSequence /builds/worker/workspace/obj-build/dist/include/mozilla/Assertions.h:237:3
        #1 0x7b68b4073f13 in AssertedCast<long, unsigned long> /builds/worker/workspace/obj-build/dist/include/mozilla/Casting.h:238:5
        #2 0x7b68b4073f13 in mozilla::WebMContainerParser::ParseStartAndEndTimestamps(mozilla::MediaSpan const&, mozilla::media::TimeUnit&, mozilla::media::TimeUnit&) /dom/media/mediasource/ContainerParser.cpp:287:9
        #3 0x7b68b40636d4 in mozilla::TrackBuffersManager::SegmentParserLoop() /dom/media/mediasource/TrackBuffersManager.cpp:1008:26
        #4 0x7b68af6d1286 in operator()<> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1083:18
        #5 0x7b68af6d1286 in __invoke_impl<nsresult, (lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1082:9)> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:60:14
        #6 0x7b68af6d1286 in __invoke<(lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1082:9)> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/bits/invoke.h:95:14
        #7 0x7b68af6d1286 in __apply_impl<(lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1082:9), std::tuple<> &> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/tuple:1740:14
        #8 0x7b68af6d1286 in apply<(lambda at /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1082:9), std::tuple<> &> /builds/worker/fetches/sysroot-x86_64-linux-gnu/usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/tuple:1751:14
        #9 0x7b68af6d1286 in apply<nsIThread, nsresult (nsIThread::*)()> /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1081:12
        #10 0x7b68af6d1286 in mozilla::detail::RunnableMethodImpl<nsUpdateProcessor*, void (nsUpdateProcessor::*)(), true, (mozilla::RunnableKind)0>::Run() /builds/worker/workspace/obj-build/dist/include/nsThreadUtils.h:1132:13
        #11 0x7b68af941af0 in mozilla::TaskQueue::Runner::Run() /xpcom/threads/TaskQueue.cpp:311:20
        #12 0x7b68af96869e in nsThreadPool::Run() /xpcom/threads/nsThreadPool.cpp:446:14
        #13 0x7b68af95fec2 in nsThread::ProcessNextEvent(bool, bool*) /xpcom/threads/nsThread.cpp:1162:16
        #14 0x7b68af96594f in NS_ProcessNextEvent(nsIThread*, bool) /xpcom/threads/nsThreadUtils.cpp:461:10
        #15 0x7b68b0556418 in mozilla::ipc::MessagePumpForNonMainThreads::Run(base::MessagePump::Delegate*) /ipc/glue/MessagePump.cpp:299:20
        #16 0x7b68b04ae691 in RunHandler /ipc/chromium/src/base/message_loop.cc:366:3
        #17 0x7b68b04ae691 in MessageLoop::Run() /ipc/chromium/src/base/message_loop.cc:348:3
        #18 0x7b68af95baee in nsThread::ThreadFunc(void*) /xpcom/threads/nsThread.cpp:373:10
        #19 0x7b68c173e3ac in _pt_root /nsprpub/pr/src/pthreads/ptthread.c:191:3
        #20 0x7b68c109caa3 in start_thread ./nptl/pthread_create.c:447:8
        #21 0x7b68c1129c6b in clone3 ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:78:0
    
    ==45991==Register values:
    rax = 0x00000000000000ee  rbx = 0x00007b689c81f1a0  rcx = 0x000055c8a317c118  rdx = 0x00007b68c1204563
    rdi = 0x00007b68c1205700  rsi = 0x0000000000000000  rbp = 0x00007b689c81f5d0  rsp = 0x00007b689c81f0f0
     r8 = 0x0000000000000000   r9 = 0x0000000000000003  r10 = 0x0000000000000002  r11 = 0x0000000000000293
    r12 = 0x0000000000000001  r13 = 0x8000000000036bc0  r14 = 0x0000000000000000  r15 = 0x0000000001f78a40
    UndefinedBehaviorSanitizer can not provide additional info.
    SUMMARY: UndefinedBehaviorSanitizer: SEGV (/home/user/workspace/browsers/m-c-20260205163736-fuzzing-debug/libxul.so+0x9073f13) (BuildId: 0b411186bb9521ab7e302998bc6191dc011c2d12)
    ==45991==ABORTING
Attached file Testcase —
Group: dom-core-security → media-core-security
Component: DOM: Core & HTML → Audio/Video: Playback

Verified bug as reproducible on mozilla-central 20260205213633-279b57ef4bf0.
Unable to bisect testcase (Testcase reproduces on start build!):

Start: ce0f77cae5a91e2cb4b1ec859117e08aa1182c52 (20250207164009)
End: ed1c0b4f0bbef7e458685d5f4743c73ae66cc3fd (20260205163736)
BuildFlags: BuildFlags(asan=False, tsan=False, debug=True, fuzzing=True, coverage=False, valgrind=False, no_opt=False, fuzzilli=False, nyx=False, searchfox=False, afl=False)

Whiteboard: [bugmon:confirm] → [bugmon:bisected,confirmed]
Blocks: media-triage

Running this in an ASan build does not trigger a failure.

Attached file (secure) —

When processing WebM clusters, the parser multiplies the cluster timecode
by the timecode scale to compute absolute timestamps. Malformed media files
can contain crafted values that cause this multiplication to overflow,
exceeding INT64_MAX. This triggers an AssertedCast crash when the result
is later cast to int64_t.

This patch adds overflow validation using CheckedInt before the cast. If
the multiplication overflows or exceeds INT64_MAX, the timecode is rejected
and logged, similar to how out-of-order timecodes are already handled. This
prevents the crash while allowing the parser to continue processing valid
portions of the media.

Assignee: nobody → padenot
Status: NEW → ASSIGNED
Severity: -- → S2
Priority: -- → P2

UB, in practice this outputs a wrong timestamp, and playback will fail, not a sec issue. sec-other.

Severity: S2 → --
Keywords: sec-other
Priority: P2 → --
Group: media-core-security → core-security-release
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch

Verified bug as fixed on rev mozilla-central 20260213093634-c898f98e4898.
Removing bugmon keyword as no further action possible. Please review the bug and re-add the keyword for further analysis.

Status: RESOLVED → VERIFIED
Keywords: bugmon
Flags: in-testsuite+
No longer blocks: media-triage
Whiteboard: [bugmon:bisected,confirmed] → [bugmon:bisected,confirmed][adv-main149-]
Group: core-security-release
Keywords: keep-hidden
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: