Use after free in Audio (CVE-2024-5845)
An audio device listener callback in Chrome's macOS audio manager was bound with an unretained pointer to the manager object, so the callback could fire after the manager was destroyed. An attacker who could trigger audio device changes at the right moment could cause a use-after-free, potentially leading to memory corruption or code execution.
- Fix shipped in 30 days
VULNERABILITY DETAILS
The specific vulnerability is the same as https://issues.chromium.org/issues/40065022, AudioManagerMac::HandleDeviceChanges bind as unretaied, so there may be UAF during competition. Because the calling paths are different, ASAN is still reproducing, but the vulnerability is exactly the same as 40065022. You can see the obvious problem directly in the code.
AudioOutputStream* AudioManagerMac::MakeLowLatencyOutputStream( const AudioParameters& params, const std::string& device_id, const LogCallback& log_callback) { DCHECK(GetTaskRunner()->BelongsToCurrentThread()); bool device_listener_first_init = false; // Lazily create the audio device listener on the first stream creation, // even if getting an audio device fails. Otherwise, if we have 0 audio // devices, the listener will never be initialized, and new valid devices // will never be detected. if (!output_device_listener_) { // NOTE: Use base::BindPostTaskToCurrentDefault() to ensure the callback is // always PostTask'd even if OSX calls us on the right thread. Some // CoreAudio drivers will fire the callbacks during stream creation, leading // to re-entrancy issues otherwise. See http://crbug.com/349604 output_device_listener_ = AudioDeviceListenerMac::Create( base::BindPostTaskToCurrentDefault(base::BindRepeating( &AudioManagerMac::HandleDeviceChanges, base::Unretained(this))), //[0] /monitor_sample_rate_changes=/ base::FeatureList::IsEnabled(kMonitorOutputSampleRateChangesMac), /monitor_default_input=/false, /monitor_addition_removal=/false, /monitor_sources=/false); device_listener_first_init = true; }
AudioDeviceID device = GetAudioDeviceIdByUId(false, device_id); if (device == kAudioObjectUnknown) { DLOG(ERROR) << "Failed to open output device: " << device_id; return NULL; }
// Only set the device and sample rate if we just initialized the device // listener. if (device_listener_first_init) { // Only set the current output device for the default device. if (AudioDeviceDescription::IsDefaultDevice(device_id)) { current_output_device_ = device; } // Just use the current sample rate since we don't allow non-native sample // rates on OSX. current_sample_rate_ = params.sample_rate(); }
AUHALStream* stream = new AUHALStream(this, params, device, log_callback); output_streams_.insert(stream); return stream; }
fix see issue 40065022
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
Root cause
Likely the device-change callback was bound with base::Unretained(this) instead of a weak pointer, so it could run after the AudioManagerMac was destroyed.
Impact
A use-after-free in the browser process could lead to memory corruption and potentially code execution, though the report only demonstrates it under ASAN.
What the attacker needed
MacOS; trigger audio device changes at the right time
The fix
The fix is the same as the referenced issue 40065022, which the text does not describe in detail.
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.
When a program sets up a callback (a function that runs later when something happens), it must keep the object that callback uses alive. Here the callback held only a raw pointer to the audio manager without keeping it alive, so if the manager was freed first, the callback touched freed memory. That is a use-after-free, which can crash the browser or let an attacker take control.
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.