Skip to content
Memory corruption Disclosed report Advanced CVE-2024-0745

stack-buffer-overflow webaudio/AudioEventTimeline.cpp:510 in AudioEventTimeline::GetValuesAtTimeHelperInternal

A stack buffer overflow occurs in Firefox's Web Audio code when oscillator frequency or detune automation values are fetched, because the code passes unchecked offsets and lengths into the timeline helper. An attacker could craft a web page that triggers the overflow, potentially causing a crash or memory corruption.

m.cooolie Follow

Originally disclosed on Mozilla

  • Fixed in 14 days
  • Paid in 16 days
  • Disclosed after 14 days
Text
Created attachment 9370190
poc.html

#Reproduce
OS:Win10 X64
123.0a1 (2023-12-19) (64-bit)

#Step:
1. python -m http.server 1337
2. python -m ffpuppet firefox.exe -p prefs.js -d -u http://localhost:1337/poc.html

#Analysis

missing boundary checks for `ticks + start, detune + start, end - start`

https://searchfox.org/mozilla-central/source/dom/media/webaudio/OscillatorNode.cpp#300
'''
  void ProcessBlock(AudioNodeTrack* aTrack, GraphTime aFrom,
                    const AudioBlock& aInput, AudioBlock* aOutput,
                    bool* aFinished) override {
    MOZ_ASSERT(mSource == aTrack, "Invalid source track");
    TRACE("OscillatorNodeEngine::ProcessBlock");

    TrackTime ticks = mDestination->GraphTimeToTrackTime(aFrom);
    if (mStart == -1) {
      ComputeSilence(aOutput);
      return;
    }

    if (ticks + WEBAUDIO_BLOCK_SIZE <= mStart || ticks >= mStop) {
      ComputeSilence(aOutput);

    } else {
      aOutput->AllocateChannels(1);
      float* output = aOutput->ChannelFloatsForWrite(0);

      uint32_t start, end;
      FillBounds(output, ticks, start, end);

      float frequency[WEBAUDIO_BLOCK_SIZE];
      float detune[WEBAUDIO_BLOCK_SIZE];
      if (ParametersMayNeedUpdate()) {
        if (mFrequency.HasSimpleValue()) {
          std::fill_n(frequency, WEBAUDIO_BLOCK_SIZE, mFrequency.GetValue());
        } else {
          mFrequency.GetValuesAtTime(ticks + start, frequency + start,
                                     end - start);
        }
        if (mDetune.HasSimpleValue()) {
          std::fill_n(detune, WEBAUDIO_BLOCK_SIZE, mDetune.GetValue());
        } else {
          mDetune.GetValuesAtTime(ticks + start, detune + start, end - start);
        }
      }
'''

The original report as published on Mozilla's Bugzilla, by m.cooolie. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

What the attacker needed

Victim opens a crafted web page; Web Audio oscillator with automation

How it was found

  1. Serve the proof-of-concept page from a local HTTP server.
  2. Launch Firefox with the supplied prefs and open the page URL.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Web Audio lets a page schedule changes to a sound over time, such as sliding a tone's pitch. Firefox stores those scheduled changes in a list and reads them back in chunks. Here the code asked for a chunk using numbers it never checked, so it could read or write past the end of a fixed-size buffer on the stack, which is memory reserved for local variables. That can crash the browser or corrupt memory.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by m.cooolie

View all

10 more disclosed reports, best first.

More from Mozilla

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.