Skip to content
Memory corruption Advisory Advanced CVE-2026-5874

Use after free in PrivateAI (CVE-2026-5874)

A use-after-free occurs in Chromium's PrivateAI component when a decryption callback deletes the SecureChannelImpl object and then the code continues to use it. An attacker could exploit this to escape the sandbox without a compromised renderer.

Weipeng Jiang Follow

Originally disclosed on Chrome VRP

Bounty$11,000 Medium View original
  • Fix shipped in 49 days

Steps to reproduce the problem

  1. apply the change.txt to the newest Chromium and compile chrome with ASAN
  2. Run chrome with : ./chrome --user-data-dir=/tmp/noexist --enable-features=ZeroStateSuggestionsUseLegion,Legion
  3. Move mouse to the "Ask Gemini" button. (Don't need to click)

Note that this UAF can be exploited to escape the sandbox without requiring a compromised renderer. The patch I provided only simulates a successful decryption operation to trigger the callback, and does not affect Chromium’s original logic

Bisect This UAF is introduced in this commit: https://chromium-review.googlesource.com/c/chromium/src/+/7139550 According to the commit, this UAF affects Chrome Stable 144.0.7559.59.

Problem Description

Vulnerability Analysis

In the SecureChannleImpl class, response_callback_ deletes the SecureChannleImpl instance itself [1]. Therefore, any reference to |this| after invoking the callback will result in a use-after-free vulnerability.

[1]

C++
void SecureChannelImpl::OnDecryptedResponse(
    const std::optional<Request>& decrypted_response) {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

  if (!decrypted_response.has_value()) {
    DLOG(ERROR) << "Failed to decrypt response.";
    FailAllRequestsAndClose(ErrorCode::kDecryptionFailed);
    return;
  }
  DVLOG(1) << "Response decrypted successfully.";

  CHECK(response_callback_);
   response_callback_.Run(base::ok(*decrypted_response)); //@audit: the response_callback_ will delete |this|

  ProcessPendingEncryptionRequests(); 
}

void SecureChannelImpl::ProcessPendingEncryptionRequests() {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

  DCHECK_EQ(state_, State::kEstablished);
  if (state_ != State::kEstablished) { //@audit: use after |this| hase been deleted
    return;
  }

SecureChannelImpl is owned by a std::unique_ptr created by ConnectionBasic [2], which itself is owned by a std::unique_ptr in ClientImpl [3][4]. This establishes an ownership chain: ClientImpl → ConnectionBasic → SecureChannelImpl.

ConnectionBasic is reset in ClientImpl::OnConnectionDisconnected() [5]. This function is registered as a callback in ConnectionBasic, which in turn passes ConnectionBasic::OnResponseReceived to SecureChannelImpl as a callback. When triggered, this callback ultimately deletes ClientImpl, thereby destroying ConnectionBasic and, consequently, SecureChannelImpl.

[2]

C++
ConnectionBasic::ConnectionBasic(
    std::unique_ptr<SecureChannel::Factory> secure_channel_factory,
    base::OnceClosure on_disconnect)
    : on_disconnect_(std::move(on_disconnect)) {
  CHECK(secure_channel_factory);
  CHECK(on_disconnect_);

  secure_channel_ = secure_channel_factory->Create(base::BindRepeating(
      &ConnectionBasic::OnResponseReceived, weak_factory_.GetWeakPtr()));
  CHECK(secure_channel_);
}

[3]

C++
std::unique_ptr<Connection> CreateBasicMetricsTimeoutConnection(
    const GURL& url,
    network::mojom::NetworkContext* network_context,
    LegionLogger* logger,
    base::OnceClosure on_disconnect) {
  auto connection_basic = std::make_unique<ConnectionBasic>(
      std::make_unique<SecureChannelImpl::FactoryImpl>(url, network_context,
                                                       logger),
      std::move(on_disconnect));

  auto connection_metrics =
      std::make_unique<ConnectionMetrics>(std::move(connection_basic));

  auto connection_timeout =
      std::make_unique<ConnectionTimeout>(std::move(connection_metrics));

  return connection_timeout;
}

[4]

C++
Connection* ClientImpl::GetOrCreateConnection() {
  if (!connection_) {
    connection_ = connection_factory_->Create(base::BindRepeating(
        &ClientImpl::OnConnectionDisconnected, base::Unretained(this)));
  }
  return connection_.get();
}

[5]

C++
void ClientImpl::OnConnectionDisconnected() {
  logger_->LogInfo(FROM_HERE,
                   "Connection disconnected. Destroying connection.");
  connection_.reset();
}

[1] https://source.chromium.org/chromium/chromium/src/+/main:components/legion/secure_channel_impl.cc;l=357 [2] https://source.chromium.org/chromium/chromium/src/+/main:components/legion/connection_basic.cc;l=26 [3] https://source.chromium.org/chromium/chromium/src/+/main:components/legion/connection_factory_impl.cc;l=33 [4] https://source.chromium.org/chromium/chromium/src/+/main:components/legion/client_impl.cc;l=95 [5] https://source.chromium.org/chromium/chromium/src/+/main:components/legion/client_impl.cc;l=183

Summary

Security: Heap-use-after-free in SecureChannelImpl::OnDecryptedResponse

Custom Questions

Type of crash:

browser

Crash state:

================================================================= ==608920==ERROR: AddressSanitizer: heap-use-after-free on address 0x7c1f73a6fca0 at pc 0x5653945f5dc2 bp 0x7ffc213669d0 sp 0x7ffc213669c8 READ of size 4 at 0x7c1f73a6fca0 thread T0 (chrome) #0 0x5653945f5dc1 in legion::SecureChannelImpl::ProcessPendingEncryptionRequests() components/legion/secure_channel_impl.cc:421:7 #1 0x5653945f6ce2 in legion::SecureChannelImpl::OnDecryptedResponse(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) components/legion/secure_channel_impl.cc:367:3 #2 0x5653945f8980 in base::internal::Invoker<base::internal::FunctorTraits<void (legion::SecureChannelImpl::&&)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), base::WeakPtrlegion::SecureChannelImpl&&>, base::internal::BindState<true, true, false, void (legion::SecureChannelImpl::)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), base::WeakPtrlegion::SecureChannelImpl>, void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::RunOnce(base::internal::BindStateBase*, std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/bind_internal.h:740:12 #3 0x565394607987 in base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>::Run(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/callback.h:155:12 #4 0x565394607bc5 in base::internal::Invoker<base::internal::FunctorTraits<void (base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>::* const&)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), std::__Cr::unique_ptr<base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>, std::__Cr::default_delete<base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>>> const&>, base::internal::BindState<true, true, false, void (base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>::)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), std::__Cr::unique_ptr<base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>, std::__Cr::default_delete<base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>>>>, void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::Run(base::internal::BindStateBase, std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/bind_internal.h:740:12 #5 0x565394603ecb in base::internal::Invoker<base::internal::FunctorTraits<legion::SecureSessionAsyncImpl::Decrypt(oak::session::v1::EncryptedMessage const&, base::OnceCallback<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>)::$_0&&, base::OnceCallback<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>&&>, base::internal::BindState<false, false, false, legion::SecureSessionAsyncImpl::Decrypt(oak::session::v1::EncryptedMessage const&, base::OnceCallback<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>)::$_0, base::OnceCallback<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>>, void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::RunOnce(base::internal::BindStateBase*, std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/callback.h:155:12 #6 0x565394607212 in mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::Run(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/callback.h:155:12 #7 0x565394607435 in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::&&)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), std::__Cr::unique_ptr<mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>, std::__Cr::default_delete<mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>>>&&>, base::internal::BindState<true, true, false, void (mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), std::__Cr::unique_ptr<mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>, std::__Cr::default_delete<mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>>>>, void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::RunOnce(base::internal::BindStateBase*, std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/bind_internal.h:740:12 #8 0x56539461ff5d in legion::mojom::OakSession_Decrypt_ForwardToCallback::Accept(mojo::Message*) base/functional/callback.h:155:12 #9 0x7f4ff243391f in mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message*) mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:1079:41 #10 0x7f4ff244a65b in mojo::MessageDispatcher::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/message_dispatcher.cc:44:19 #11 0x7f4ff2438b64 in mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message*) mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:747:20 #12 0x7f4ff2459c1e in mojo::internal::MultiplexRouter::ProcessIncomingMessage(mojo::internal::MultiplexRouter::MessageWrapper*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*) mojo/public/cpp/bindings/lib/multiplex_router.cc:1204:42 #13 0x7f4ff245844d in mojo::internal::MultiplexRouter::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/multiplex_router.cc:790:7 #14 0x7f4ff244a65b in mojo::MessageDispatcher::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/message_dispatcher.cc:44:19 #15 0x7f4ff241eeff in mojo::Connector::DispatchMessage(mojo::ScopedHandleBasemojo::MessageHandle) mojo/public/cpp/bindings/lib/connector.cc:568:49 #16 0x7f4ff242074e in mojo::Connector::ReadAllAvailableMessages() mojo/public/cpp/bindings/lib/connector.cc:629:14 #17 0x7f4ff24201e7 in mojo::Connector::OnWatcherHandleReady(char const*, unsigned int) mojo/public/cpp/bindings/lib/connector.cc:454:3 #18 0x7f4ff2422dd1 in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::Connector::* const&)(char const*, unsigned int), mojo::Connector*, char const* const&>, base::internal::BindState<true, true, false, void (mojo::Connector::)(char const, unsigned int), base::internal::UnretainedWrapper<mojo::Connector, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>, base::internal::UnretainedWrapper<char const, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, void (unsigned int)>::Run(base::internal::BindStateBase*, unsigned int) base/functional/bind_internal.h:740:12 #19 0x7f4ff242247e in base::RepeatingCallback<void (unsigned int)>::Run(unsigned int) const & base/functional/callback.h:343:12 #20 0x7f4ff2422234 in base::internal::Invoker<base::internal::FunctorTraits<void (* const&)(base::RepeatingCallback<void (unsigned int)> const&, unsigned int, mojo::HandleSignalsState const&), base::RepeatingCallback<void (unsigned int)> const&>, base::internal::BindState<false, true, false, void ()(base::RepeatingCallback<void (unsigned int)> const&, unsigned int, mojo::HandleSignalsState const&), base::RepeatingCallback<void (unsigned int)>>, void (unsigned int, mojo::HandleSignalsState const&)>::Run(base::internal::BindStateBase, unsigned int, mojo::HandleSignalsState const&) base/functional/bind_internal.h:673:12 #21 0x7f4ff0767430 in base::RepeatingCallback<void (unsigned int, mojo::HandleSignalsState const&)>::Run(unsigned int, mojo::HandleSignalsState const&) const & base/functional/callback.h:343:12 #22 0x7f4ff0766e0b in mojo::SimpleWatcher::OnHandleReady(int, unsigned int, mojo::HandleSignalsState const&) mojo/public/cpp/system/simple_watcher.cc:286:14 #23 0x7f4ff0767e74 in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::SimpleWatcher::&&)(int, unsigned int, mojo::HandleSignalsState const&), base::WeakPtrmojo::SimpleWatcher&&, int&&, unsigned int&&, mojo::HandleSignalsState&&>, base::internal::BindState<true, true, false, void (mojo::SimpleWatcher::)(int, unsigned int, mojo::HandleSignalsState const&), base::WeakPtrmojo::SimpleWatcher, int, unsigned int, mojo::HandleSignalsState>, void ()>::RunOnce(base::internal::BindStateBase*) base/functional/bind_internal.h:740:12 #24 0x7f4ff1c8d8b2 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) base/functional/callback.h:155:12 #25 0x7f4ff1d0ee2e in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*) base/task/common/task_annotator.h:112:5 #26 0x7f4ff1d0de06 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:346:40 #27 0x7f4ff1ee2737 in base::MessagePumpGlib::HandleDispatch() base/message_loop/message_pump_glib.cc:736:46 #28 0x7f4ff1ee5ee2 in base::(anonymous namespace)::WorkSourceDispatch(_GSource*, int ()(void), void*) base/message_loop/message_pump_glib.cc:355:43 #29 0x7f4f82e7617c in g_main_context_dispatch (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x5217c) (BuildId: 2c1d2f9d4a08c71a36797aeb246ab7ae377934ea)

0x7c1f73a6fca0 is located 32 bytes inside of 144-byte region [0x7c1f73a6fc80,0x7c1f73a6fd10) freed by thread T0 (chrome) here: #0 0x56539178f4d2 in operator delete(void*, unsigned long) (/home/krace/fuzz/chromium/src/out/ui/chrome+0x67e64d2) (BuildId: 3cd4a8fa4a7bd132) #1 0x5653945e1635 in legion::ConnectionBasic::~ConnectionBasic() gen/third_party/libc++/src/include/__memory/unique_ptr.h:74:5 #2 0x5653945e7d07 in legion::ConnectionMetrics::~ConnectionMetrics() gen/third_party/libc++/src/include/__memory/unique_ptr.h:74:5 #3 0x5653945edc8c in legion::ConnectionTimeout::~ConnectionTimeout() gen/third_party/libc++/src/include/__memory/unique_ptr.h:74:5 #4 0x5653945f0334 in legion::ConnectionTokenAttestation::~ConnectionTokenAttestation() gen/third_party/libc++/src/include/__memory/unique_ptr.h:74:5 #5 0x5653945d9f0c in legion::ClientImpl::OnConnectionDisconnected() gen/third_party/libc++/src/include/__memory/unique_ptr.h:74:5 #6 0x5653945dd862 in base::internal::Invoker<base::internal::FunctorTraits<void (legion::ClientImpl::* const&)(), legion::ClientImpl*>, base::internal::BindState<true, true, false, void (legion::ClientImpl::)(), base::internal::UnretainedWrapper<legion::ClientImpl, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, void ()>::Run(base::internal::BindStateBase) base/functional/bind_internal.h:740:12 #7 0x5653945e20de in legion::ConnectionBasic::HandleDisconnect(legion::ErrorCode) base/functional/callback.h:155:12 #8 0x5653945e0f2d in legion::ConnectionBasic::OnResponseReceived(base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>) components/legion/connection_basic.cc:71:5 #9 0x5653945e297b in void base::internal::DecayedFunctorTraits<void (legion::ConnectionBasic::)(base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>), base::WeakPtrlegion::ConnectionBasic const&>::Invoke<void (legion::ConnectionBasic::)(base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>), base::WeakPtrlegion::ConnectionBasic const&, base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>>(void (legion::ConnectionBasic::)(base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>), base::WeakPtrlegion::ConnectionBasic const&, base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>&&) base/functional/bind_internal.h:740:12 #10 0x5653945e26b2 in base::internal::Invoker<base::internal::FunctorTraits<void (legion::ConnectionBasic:: const&)(base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>), base::WeakPtrlegion::ConnectionBasic const&>, base::internal::BindState<true, true, false, void (legion::ConnectionBasic::)(base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>), base::WeakPtrlegion::ConnectionBasic>, void (base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>)>::Run(base::internal::BindStateBase, base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>&&) base/functional/bind_internal.h:956:5 #11 0x5653945f712f in base::RepeatingCallback<void (base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>)>::Run(base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>) const & base/functional/callback.h:343:12 #12 0x5653945f6ca5 in legion::SecureChannelImpl::OnDecryptedResponse(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) components/legion/secure_channel_impl.cc:365:22 #13 0x5653945f8980 in base::internal::Invoker<base::internal::FunctorTraits<void (legion::SecureChannelImpl::&&)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), base::WeakPtrlegion::SecureChannelImpl&&>, base::internal::BindState<true, true, false, void (legion::SecureChannelImpl::)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), base::WeakPtrlegion::SecureChannelImpl>, void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::RunOnce(base::internal::BindStateBase*, std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/bind_internal.h:740:12 #14 0x565394607987 in base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>::Run(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/callback.h:155:12 #15 0x565394607bc5 in base::internal::Invoker<base::internal::FunctorTraits<void (base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>::* const&)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), std::__Cr::unique_ptr<base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>, std::__Cr::default_delete<base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>>> const&>, base::internal::BindState<true, true, false, void (base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>::)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), std::__Cr::unique_ptr<base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>, std::__Cr::default_delete<base::internal::OnceCallbackHolder<std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&>>>>, void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::Run(base::internal::BindStateBase, std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/bind_internal.h:740:12 #16 0x565394603ecb in base::internal::Invoker<base::internal::FunctorTraits<legion::SecureSessionAsyncImpl::Decrypt(oak::session::v1::EncryptedMessage const&, base::OnceCallback<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>)::$_0&&, base::OnceCallback<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>&&>, base::internal::BindState<false, false, false, legion::SecureSessionAsyncImpl::Decrypt(oak::session::v1::EncryptedMessage const&, base::OnceCallback<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>)::$_0, base::OnceCallback<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>>, void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::RunOnce(base::internal::BindStateBase*, std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/callback.h:155:12 #17 0x565394607212 in mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::Run(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/callback.h:155:12 #18 0x565394607435 in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::&&)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), std::__Cr::unique_ptr<mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>, std::__Cr::default_delete<mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>>>&&>, base::internal::BindState<true, true, false, void (mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::)(std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&), std::__Cr::unique_ptr<mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>, std::__Cr::default_delete<mojo::internal::CallbackWithDeleteHelper<void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>>>>, void (std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&)>::RunOnce(base::internal::BindStateBase*, std::__Cr::optional<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>> const&) base/functional/bind_internal.h:740:12 #19 0x56539461ff5d in legion::mojom::OakSession_Decrypt_ForwardToCallback::Accept(mojo::Message*) base/functional/callback.h:155:12 #20 0x7f4ff243391f in mojo::InterfaceEndpointClient::HandleValidatedMessage(mojo::Message*) mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:1079:41 #21 0x7f4ff244a65b in mojo::MessageDispatcher::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/message_dispatcher.cc:44:19 #22 0x7f4ff2438b64 in mojo::InterfaceEndpointClient::HandleIncomingMessage(mojo::Message*) mojo/public/cpp/bindings/lib/interface_endpoint_client.cc:747:20 #23 0x7f4ff2459c1e in mojo::internal::MultiplexRouter::ProcessIncomingMessage(mojo::internal::MultiplexRouter::MessageWrapper*, mojo::internal::MultiplexRouter::ClientCallBehavior, base::SequencedTaskRunner*) mojo/public/cpp/bindings/lib/multiplex_router.cc:1204:42 #24 0x7f4ff245844d in mojo::internal::MultiplexRouter::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/multiplex_router.cc:790:7 #25 0x7f4ff244a65b in mojo::MessageDispatcher::Accept(mojo::Message*) mojo/public/cpp/bindings/lib/message_dispatcher.cc:44:19 #26 0x7f4ff241eeff in mojo::Connector::DispatchMessage(mojo::ScopedHandleBasemojo::MessageHandle) mojo/public/cpp/bindings/lib/connector.cc:568:49 #27 0x7f4ff242074e in mojo::Connector::ReadAllAvailableMessages() mojo/public/cpp/bindings/lib/connector.cc:629:14 #28 0x7f4ff24201e7 in mojo::Connector::OnWatcherHandleReady(char const*, unsigned int) mojo/public/cpp/bindings/lib/connector.cc:454:3 #29 0x7f4ff2422dd1 in base::internal::Invoker<base::internal::FunctorTraits<void (mojo::Connector::* const&)(char const*, unsigned int), mojo::Connector*, char const* const&>, base::internal::BindState<true, true, false, void (mojo::Connector::)(char const, unsigned int), base::internal::UnretainedWrapper<mojo::Connector, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>, base::internal::UnretainedWrapper<char const, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, void (unsigned int)>::Run(base::internal::BindStateBase*, unsigned int) base/functional/bind_internal.h:740:12

previously allocated by thread T0 (chrome) here: #0 0x56539178e8cd in operator new(unsigned long) (/home/krace/fuzz/chromium/src/out/ui/chrome+0x67e58cd) (BuildId: 3cd4a8fa4a7bd132) #1 0x5653945f3b60 in legion::SecureChannelImpl::FactoryImpl::Create(base::RepeatingCallback<void (base::expected<std::__Cr::vector<unsigned char, std::__Cr::allocator<unsigned char>>, legion::ErrorCode>)>) gen/third_party/libc++/src/include/__memory/unique_ptr.h:756:26 #2 0x5653945e0692 in legion::ConnectionBasic::ConnectionBasic(std::__Cr::unique_ptr<legion::SecureChannel::Factory, std::__Cr::default_deletelegion::SecureChannel::Factory>, base::OnceCallback<void ()>) components/legion/connection_basic.cc:26:45 #3 0x5653945e61f3 in legion::(anonymous namespace)::CreateTokenAttestationConnection(GURL const&, legion::phosphor::TokenManager*, base::RepeatingCallback<void ()>, network::mojom::NetworkContext*) gen/third_party/libc++/src/include/__memory/unique_ptr.h:756:30 #4 0x5653945e5f14 in legion::TokenConnectionFactoryImpl::Create(base::RepeatingCallback<void ()>) components/legion/connection_factory_impl.cc:101:10 #5 0x5653945d9c96 in legion::ClientImpl::GetOrCreateConnection() components/legion/client_impl.cc:90:40 #6 0x5653945d98dd in legion::ClientImpl::EstablishSession(base::OnceCallback<void (base::expected<void, legion::ErrorCode>)>) components/legion/client_impl.cc:84:3 #7 0x56539ec13bc6 in TabStripActionContainer::OnGlicButtonHovered() chrome/browser/ui/views/tabs/tab_strip_action_container.cc:99:17 #8 0x56539ec1b8c2 in base::internal::Invoker<base::internal::FunctorTraits<void (TabStripActionContainer::* const&)(), TabStripActionContainer*>, base::internal::BindState<true, true, false, void (TabStripActionContainer::)(), base::internal::UnretainedWrapper<TabStripActionContainer, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, void ()>::Run(base::internal::BindStateBase) base/functional/bind_internal.h:740:12 #9 0x565391f2accf in base::RepeatingCallback<void ()>::Run() const & base/functional/callback.h:343:12 #10 0x565397089f4e in glic::TabStripGlicButton::StateChanged(views::Button::ButtonState) chrome/browser/ui/views/tabs/glic/tab_strip_glic_button.cc:475:25 #11 0x7f4fc1dfc1d9 in views::Button::SetState(views::Button::ButtonState) ui/views/controls/button/button.cc:263:3 #12 0x7f4feca86fd4 in ui::ScopedTargetHandler::OnEvent(ui::Event*) ui/events/scoped_target_handler.cc:30:24 #13 0x7f4feca6e308 in ui::EventDispatcher::DispatchEvent(ui::EventHandler*, ui::Event*) ui/events/event_dispatcher.cc:189:12 #14 0x7f4feca6ce6b in ui::EventDispatcher::ProcessEvent(ui::EventTarget*, ui::Event*) ui/events/event_dispatcher.cc:138:5 #15 0x7f4feca6c5c4 in ui::EventDispatcherDelegate::DispatchEventToTarget(ui::EventTarget*, ui::Event*) ui/events/event_dispatcher.cc:84:14 #16 0x7f4feca6c0fa in ui::EventDispatcherDelegate::DispatchEvent(ui::EventTarget*, ui::Event*) ui/events/event_dispatcher.cc:56:15 #17 0x7f4fc2100a96 in views::internal::RootView::HandleMouseEnteredOrMoved(ui::MouseEvent const&) ui/views/widget/root_view.cc:912:13 #18 0x7f4fc21320e0 in views::Widget::OnMouseEvent(ui::MouseEvent*) ui/views/widget/widget.cc #19 0x7f4fc2200b95 in views::DesktopNativeWidgetAura::OnMouseEvent(ui::MouseEvent*) ui/views/widget/desktop_aura/desktop_native_widget_aura.cc:1445:30 #20 0x7f4feca6e308 in ui::EventDispatcher::DispatchEvent(ui::EventHandler*, ui::Event*) ui/events/event_dispatcher.cc:189:12 #21 0x7f4feca6ce6b in ui::EventDispatcher::ProcessEvent(ui::EventTarget*, ui::Event*) ui/events/event_dispatcher.cc:138:5 #22 0x7f4feca6c5c4 in ui::EventDispatcherDelegate::DispatchEventToTarget(ui::EventTarget*, ui::Event*) ui/events/event_dispatcher.cc:84:14 #23 0x7f4feca6c0fa in ui::EventDispatcherDelegate::DispatchEvent(ui::EventTarget*, ui::Event*) ui/events/event_dispatcher.cc:56:15 #24 0x7f4feca74aaf in ui::EventProcessor::OnEventFromSource(ui::Event*) ui/events/event_processor.cc:72:19 #25 0x7f4feca78051 in ui::EventSource::DeliverEventToSink(ui::Event*) ui/events/event_source.cc:119:16 #26 0x7f4feca779f4 in ui::EventSource::SendEventToSinkFromRewriter(ui::Event const*, ui::EventRewriter const*) ui/events/event_source.cc:134:12 #27 0x7f4fd1706fbd in aura::WindowTreeHostPlatform::DispatchEvent(ui::Event*) ui/aura/window_tree_host_platform.cc:300:38 #28 0x7f4fc2208d38 in views::DesktopWindowTreeHostLinux::DispatchEvent(ui::Event*) ui/views/widget/desktop_aura/desktop_window_tree_host_linux.cc:250:29 #29 0x7f4ff2c31487 in base::internal::Invoker<base::internal::FunctorTraits<void (ui::PlatformWindowDelegate::&&)(ui::Event), ui::PlatformWindowDelegate*>, base::internal::BindState<true, true, false, void (ui::PlatformWindowDelegate::)(ui::Event), base::internal::UnretainedWrapper<ui::PlatformWindowDelegate, base::unretained_traits::MayNotDangle, (partition_alloc::internal::RawPtrTraits)0>>, void (ui::Event*)>::RunOnce(base::internal::BindStateBase*, ui::Event*) base/functional/bind_internal.h:740:12

SUMMARY: AddressSanitizer: heap-use-after-free components/legion/secure_channel_impl.cc:421:7 in legion::SecureChannelImpl::ProcessPendingEncryptionRequests() Shadow bytes around the buggy address: 0x7c1f73a6fa00: f7 fa fd fd fd fd fd fd fd fd fd fd fd fd fd fd 0x7c1f73a6fa80: fd fd fd fa fa fa fa fa fa fa f7 fa fd fd fd fd 0x7c1f73a6fb00: fd fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa 0x7c1f73a6fb80: fa fa fa fa f7 fa fd fd fd fd fd fd fd fd fd fd 0x7c1f73a6fc00: fd fd fd fd fd fd fd fa fa fa fa fa fa fa f7 fa =>0x7c1f73a6fc80: fd fd fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd 0x7c1f73a6fd00: fd fd fa fa fa fa fa fa f7 fa fd fd fd fd fd fd 0x7c1f73a6fd80: fd fd fd fd fd fd fd fd fd fd fd fd fa fa fa fa 0x7c1f73a6fe00: fa fa f7 fa fd fd fd fd fd fd fd fd fd fd fd fd 0x7c1f73a6fe80: fd fd fd fd fd fd fa fa fa fa fa fa f7 fa fd fd 0x7c1f73a6ff00: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb

==608920==ADDITIONAL INFO

==608920==Note: Please include this section with the ASan report. Task trace: #0 0x7f4ff076782a in mojo::SimpleWatcher::Context::Notify(unsigned int, MojoHandleSignalsState, unsigned int) mojo/public/cpp/system/simple_watcher.cc:103:13

Command line: /home/krace/fuzz/chromium/src/out/ui/chrome --user-data-dir=/tmp/noexist --enable-features=ZeroStateSuggestionsUseLegion,Legion --flag-switches-begin --flag-switches-end --ozone-platform=x11

MiraclePtr Status: NOT PROTECTED No raw_ptr<T> access to this region was detected prior to this crash. This crash is still exploitable with MiraclePtr. Refer to https://chromium.googlesource.com/chromium/src/+/main/base/memory/raw_ptr.md for details.

==608920==END OF ADDITIONAL INFO

==608920==ABORTING

Reporter credit:

Please only credit: Krace

Additional Data

Category: Security
Chrome Channel: Stable
Regression: N/A \

The original report as published on the Chromium issue tracker, by Krace. Images and videos are our own copies; raw HTML is shown as text. View it on Chromium issue tracker.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 6 min read.

Context

This is a heap use-after-free in Chrome's PrivateAI component, specifically in the Legion code that handles the secure channel to the Gemini backend. The affected class is SecureChannelImpl, which lives in components/legion/secure_channel_impl.cc. The bug was reported through the Chrome VRP by Krace, rated medium severity, and paid a bounty of 11,000 USD. It was disclosed on 7 April 2026 as CVE-2026-5874.

The allocation stack shows the path from hovering the "Ask Gemini" button in the tab strip: TabStripActionContainer::OnGlicButtonHovered() leads to ClientImpl::EstablishSession() and the creation of the connection chain. The Legion code wraps a secure channel in several layers of connection objects, and the bug is in how one of those layers tears itself down while a callback is still running.

Setup

No accounts or special roles are needed. The researcher built Chromium from source with AddressSanitizer and ran it with two feature flags enabled.

  1. Apply change.txt to the newest Chromium and compile chrome with ASAN.
  2. Run chrome with the following command:
Bash
./chrome  --user-data-dir=/tmp/noexist --enable-features=ZeroStateSuggestionsUseLegion,Legion
  1. Move the mouse to the "Ask Gemini" button. Clicking is not required.

The change.txt patch is not part of Chromium's normal logic. The researcher states that it only simulates a successful decryption operation to trigger the callback, and does not affect Chromium's original logic. The researcher states the patch only simulates a successful decryption to trigger the callback and does not affect Chromium's original logic.

Finding it

The researcher bisected the bug to a specific commit:

Text
https://chromium-review.googlesource.com/c/chromium/src/+/7139550

According to that commit, the use-after-free affects Chrome Stable 144.0.7559.59. The crash is a heap-use-after-free reported by ASan as a READ of size 4 in legion::SecureChannelImpl::ProcessPendingEncryptionRequests() at components/legion/secure_channel_impl.cc:421:7, reached from OnDecryptedResponse() at line 367.

The researcher notes that this UAF can be exploited to escape the sandbox without requiring a compromised renderer. The researcher notes the UAF can be exploited to escape the sandbox without requiring a compromised renderer.

Exploitation

Step 1: trigger the session

Hovering the "Ask Gemini" button is enough. The allocation stack shows the path from the UI event to the connection creation:

So a mouse-enter event on the button creates the SecureChannelImpl instance through the factory, wrapped inside ConnectionBasic.

Step 2: the decryption callback fires

The simulated successful decryption invokes SecureChannelImpl::OnDecryptedResponse(). That function runs response_callback_, which is bound to ConnectionBasic::OnResponseReceived. That handler calls ConnectionBasic::HandleDisconnect(), which runs the disconnect closure registered by ClientImpl, namely ClientImpl::OnConnectionDisconnected(). That function resets connection_, destroying the whole chain including the SecureChannelImpl that is currently executing.

Step 3: the freed object is used again

After the callback returns, OnDecryptedResponse() calls ProcessPendingEncryptionRequests() on this. The object has already been freed, so the state_ read at line 421 is a use-after-free. ASan reports:

The free stack confirms the ownership chain:

The allocation stack shows the object was created by SecureChannelImpl::FactoryImpl::Create() inside the ConnectionBasic constructor, which is consistent with the ownership chain described below.

Root cause

The vulnerable function is SecureChannelImpl::OnDecryptedResponse(). The researcher annotates the callback invocation as the point where this is deleted:

C++
void SecureChannelImpl::OnDecryptedResponse(
    const std::optional<Request>& decrypted_response) {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

  if (!decrypted_response.has_value()) {
    DLOG(ERROR) << "Failed to decrypt response.";
    FailAllRequestsAndClose(ErrorCode::kDecryptionFailed);
    return;
  }
  DVLOG(1) << "Response decrypted successfully.";

  CHECK(response_callback_);
   response_callback_.Run(base::ok(*decrypted_response)); //@audit: the response_callback_ will delete |this|

  ProcessPendingEncryptionRequests();
}

void SecureChannelImpl::ProcessPendingEncryptionRequests() {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

  DCHECK_EQ(state_, State::kEstablished);
  if (state_ != State::kEstablished) { //@audit: use after |this| hase been deleted
    return;
  }

The ownership chain is ClientImpl → ConnectionBasic → SecureChannelImpl. SecureChannelImpl is owned by a std::unique_ptr created by ConnectionBasic:

C++
ConnectionBasic::ConnectionBasic(
    std::unique_ptr<SecureChannel::Factory> secure_channel_factory,
    base::OnceClosure on_disconnect)
    : on_disconnect_(std::move(on_disconnect)) {
  CHECK(secure_channel_factory);
  CHECK(on_disconnect_);

  secure_channel_ = secure_channel_factory->Create(base::BindRepeating(
      &ConnectionBasic::OnResponseReceived, weak_factory_.GetWeakPtr()));
  CHECK(secure_channel_);
}

ConnectionBasic is itself owned by a std::unique_ptr in ClientImpl, created through the connection factory:

C++
std::unique_ptr<Connection> CreateBasicMetricsTimeoutConnection(
    const GURL& url,
    network::mojom::NetworkContext* network_context,
    LegionLogger* logger,
    base::OnceClosure on_disconnect) {
  auto connection_basic = std::make_unique<ConnectionBasic>(
      std::make_unique<SecureChannelImpl::FactoryImpl>(url, network_context,
                                                       logger),
      std::move(on_disconnect));

  auto connection_metrics =
      std::make_unique<ConnectionMetrics>(std::move(connection_basic));

  auto connection_timeout =
      std::make_unique<ConnectionTimeout>(std::move(connection_metrics));

  return connection_timeout;
}
C++
Connection* ClientImpl::GetOrCreateConnection() {
  if (!connection_) {
    connection_ = connection_factory_->Create(base::BindRepeating(
        &ClientImpl::OnConnectionDisconnected, base::Unretained(this)));
  }
  return connection_.get();
}

The disconnect closure is registered in ClientImpl and resets the connection:

C++
void ClientImpl::OnConnectionDisconnected() {
  logger_->LogInfo(FROM_HERE,
                   "Connection disconnected. Destroying connection.");
  connection_.reset();
}

ConnectionBasic passes ConnectionBasic::OnResponseReceived to SecureChannelImpl as the response callback. When that callback fires, it reaches HandleDisconnect(), which runs the ClientImpl::OnConnectionDisconnected() closure, which resets connection_. That destroys ConnectionBasic, which destroys SecureChannelImpl, while SecureChannelImpl::OnDecryptedResponse() is still on the stack. The subsequent call to ProcessPendingEncryptionRequests() then reads state_ from freed memory.

The source references cited in the report are:

  1. components/legion/secure_channel_impl.cc line 357
  2. components/legion/connection_basic.cc line 26
  3. components/legion/connection_factory_impl.cc line 33
  4. components/legion/client_impl.cc line 95
  5. components/legion/client_impl.cc line 183

The ASan report also notes that the crash is still exploitable with MiraclePtr, and that no raw_ptr<T> access to the region was detected prior to the crash. The freed region is 144 bytes, and the read is 32 bytes into it.

Impact

The researcher states that this UAF can be exploited to escape the sandbox without requiring a compromised renderer. The bug is triggered by a UI event (hovering the "Ask Gemini" button) rather than by renderer-controlled input. The report does not describe a full exploit chain, only the primitive and the reachability. The severity assigned by the program is medium, and the bounty was 11,000 USD.

Fix

The report does not describe the patch that was applied. The researcher's own change.txt is explicitly a test aid that simulates a successful decryption to trigger the callback, not a fix.

Variants to test

The report does not list variants. Based on the pattern shown, the general shape to look for elsewhere is a callback that can destroy the object it is invoked from, followed by any use of this after the callback returns. Concretely, on other Chromium components or similar callback-heavy C++ codebases:

  1. Look for member functions that run a OnceCallback or RepeatingCallback and then touch member state. A positive result is an ASan heap-use-after-free whose free stack passes through the callback and whose use stack is in the same method after the callback line.
  2. Look for ownership chains where a child object registers a callback that reaches a parent's reset() on a unique_ptr. A positive result is the child being freed while its own method is still executing.
  3. Look for base::Unretained(this) bindings in disconnect or teardown paths. A positive result is a callback that runs after the bound object has been destroyed.
  4. Look for UI-event-driven session creation (hover, focus, visibility) that starts network or crypto work. A positive result is a crash reachable without any renderer involvement, which is the property that makes this class of bug interesting for sandbox escape.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 18 min read.

What happened, in plain words

Chrome has a feature called PrivateAI, and one part of it is the "Ask Gemini" button that appears in the tab strip (the row of tabs at the top of the window). Just moving your mouse over that button is enough to make Chrome start setting up a session in the background. You do not have to click anything.

The code that builds and manages that secure conversation lives in a part of Chrome called Legion. Inside Legion there is a class (a blueprint for an object in the program) called SecureChannelImpl, which represents the secure channel itself. The bug is in that class: when a certain piece of work finishes, the code that runs as a result ends up throwing away the very object that is still busy running. The program then carries on and reads from memory that has already been given back to the system. That is called a use-after-free.

A use-after-free is dangerous because the memory may already have been handed to something else. Reading it can crash the browser, and in the right circumstances an attacker could arrange for that memory to contain values they control, which can turn a crash into something worse. The researcher who found this notes that it can be exploited to escape the sandbox (the security boundary that keeps a compromised web page from reaching the rest of your computer) without needing a compromised renderer (the part of Chrome that draws web pages).

The bug was reported through the Chrome VRP (Vulnerability Reward Program, Google's scheme that pays people for reporting security bugs), rated medium severity, and paid a bounty of 11,000 USD. It was disclosed on 7 April 2026 as CVE-2026-5874. The reporter asked to be credited only as Krace.

Context

This is a heap use-after-free (explained below) in Chrome's PrivateAI component, specifically in the Legion code that handles the secure channel to the Gemini backend. The affected class is SecureChannelImpl, which lives in components/legion/secure_channel_impl.cc.

The allocation stack shows the path from hovering the "Ask Gemini" button in the tab strip: TabStripActionContainer::OnGlicButtonHovered() leads to ClientImpl::EstablishSession() and the creation of the connection chain. The Legion code wraps a secure channel in several layers of connection objects, and the bug is in how one of those layers tears itself down while a callback is still running.

A few words before we go further:

  • A class is a blueprint in the code that describes an object and the things it can do. An object (or instance) is one actual copy of that blueprint in memory while the program runs.
  • A callback is a piece of code you hand to someone else and say "run this when the thing finishes". Think of leaving your phone number at a repair shop: you do not wait at the counter, you get a call when the job is done.
  • A heap is the area of memory a program uses for objects it creates while running, as opposed to fixed memory set aside when the program starts. A heap use-after-free means the program gave a chunk of heap memory back (freed it) and then read or wrote it again.
  • A sandbox is the cage Chrome puts around each web page's code so that a bug in a page cannot directly touch your files or other programs. A renderer is the process that runs a page's code inside that cage.
  • ASAN (AddressSanitizer) is a tool built into a special test version of a program that watches memory and shouts loudly the moment code touches memory it should not. Developers compile a special build with ASAN when hunting for memory bugs.

Setup

No accounts or special roles are needed. The researcher built Chromium (the open-source project Chrome is based on) from source with AddressSanitizer and ran it with two feature flags enabled. A feature flag is a switch inside Chrome that turns an experimental feature on or off; developers use them to test things before they are on for everyone.

  1. Apply change.txt to the newest Chromium and compile chrome with ASAN.
  2. Run chrome with the following command:
Bash
./chrome  --user-data-dir=/tmp/noexist --enable-features=ZeroStateSuggestionsUseLegion,Legion
  1. Move the mouse to the "Ask Gemini" button. Clicking is not required.

What the command does, piece by piece:

  • ./chrome means "run the program called chrome that sits in the current folder".
  • --user-data-dir=/tmp/noexist tells Chrome to keep its profile data (bookmarks, history, settings) in a folder called /tmp/noexist. Using a throwaway folder means the test starts from a clean, empty profile every time, so nothing left over from earlier runs can affect the result.
  • --enable-features=ZeroStateSuggestionsUseLegion,Legion switches on two experimental features by name. The second one, Legion, is the code that contains the bug; without it, that code would not run at all.

The change.txt patch is not part of Chromium's normal logic. The researcher states that it only simulates a successful decryption operation to trigger the callback, and does not affect Chromium's original logic. The researcher states the patch only simulates a successful decryption to trigger the callback and does not affect Chromium's original logic. A patch here means a small edit to the source code before compiling. Decryption is the process of turning scrambled (encrypted) data back into readable data; the secure channel normally receives an encrypted reply from the server and decrypts it, and the patch pretends that step succeeded so the follow-up code runs on demand.

Finding it

The researcher bisected the bug to a specific commit. A bisect is a search technique: you know an old version of the code was fine and a new one is broken, so you check the version halfway between them, then halfway again, and so on until you land on the single change that introduced the problem. A commit is one recorded change to the source code, with a message explaining it.

Text
https://chromium-review.googlesource.com/c/chromium/src/+/7139550

According to that commit, the use-after-free affects Chrome Stable 144.0.7559.59. The crash is a heap-use-after-free reported by ASan as a READ of size 4 in legion::SecureChannelImpl::ProcessPendingEncryptionRequests() at components/legion/secure_channel_impl.cc:421:7, reached from OnDecryptedResponse() at line 367. "READ of size 4" means the program tried to read four bytes of memory (about the size of a small integer) from the freed region.

The researcher notes that this UAF can be exploited to escape the sandbox without requiring a compromised renderer. The researcher notes the UAF can be exploited to escape the sandbox without requiring a compromised renderer.

Exploitation

Step 1: trigger the session

Hovering the "Ask Gemini" button is enough. The allocation stack shows the path from the UI event to the connection creation. An allocation stack is the list of function calls that were running at the moment a piece of memory was created; ASan records it so you can see where the object came from.

Read from the bottom up, because the lowest number is the innermost call:

  • #1 SecureChannelImpl::FactoryImpl::Create(...) actually creates the secure channel object. A factory is a function whose job is to build objects for you, so the rest of the code does not need to know the construction details.
  • #2 ConnectionBasic::ConnectionBasic(...) is the constructor (the setup routine that runs when an object is created) of ConnectionBasic, the wrapper that holds the secure channel.
  • #3 CreateTokenAttestationConnection(...) builds a connection that involves token attestation. A token here is a short-lived credential proving the client is genuine; attestation is the process of proving that.
  • #4 TokenConnectionFactoryImpl::Create(...) is the factory that produces that kind of connection.
  • #5 ClientImpl::GetOrCreateConnection() fetches the existing connection or makes a new one. ClientImpl is the top-level object that represents the client side of the conversation.
  • #6 ClientImpl::EstablishSession(...) starts a session, meaning it sets up the state needed to talk to the server.
  • #7 TabStripActionContainer::OnGlicButtonHovered() is the UI handler that runs when the mouse enters the button. This is the human action that kicks everything off.

So a mouse-enter event on the button creates the SecureChannelImpl instance through the factory, wrapped inside ConnectionBasic.

Step 2: the decryption callback fires

The simulated successful decryption invokes SecureChannelImpl::OnDecryptedResponse(). That function runs response_callback_, which is bound to ConnectionBasic::OnResponseReceived. That handler calls ConnectionBasic::HandleDisconnect(), which runs the disconnect closure registered by ClientImpl, namely ClientImpl::OnConnectionDisconnected(). That function resets connection_, destroying the whole chain including the SecureChannelImpl that is currently executing.

In plain terms: the secure channel receives a reply, calls the "here is the reply" callback, and that callback walks up the chain and says "we are done, throw the connection away". Throwing the connection away destroys the secure channel object, which is still in the middle of its own function. A closure is simply a callback that carries some saved context with it.

Step 3: the freed object is used again

After the callback returns, OnDecryptedResponse() calls ProcessPendingEncryptionRequests() on this. this is how C++ code refers to the object it is currently working inside. The object has already been freed, so the state_ read at line 421 is a use-after-free. ASan reports:

Line by line:

  • The first line is ASan announcing the error: a heap use-after-free at a particular memory address, on thread T0 (the main thread), in the chrome program.
  • READ of size 4 says the bad access was a read of four bytes.
  • #0 is the innermost frame: ProcessPendingEncryptionRequests() at line 421 of secure_channel_impl.cc. This is where the illegal read happened.
  • #1 is its caller: OnDecryptedResponse() at line 367. This is the function that called the one above after the callback had already destroyed the object.

The free stack confirms the ownership chain. A free stack is the list of calls that were running when the memory was released, so it tells you who destroyed the object.

A ~ in front of a name means a destructor, the routine that runs when an object is being destroyed. Reading from the bottom up again:

  • #12 SecureChannelImpl::OnDecryptedResponse(...) is where the chain starts, at line 365.
  • #8 ConnectionBasic::OnResponseReceived(...) is the callback that the secure channel invoked.
  • #7 ConnectionBasic::HandleDisconnect(...) is the handler that decides the connection is going away.
  • #5 ClientImpl::OnConnectionDisconnected() is the closure that resets the connection.
  • #4 to #1 are the destructors running in sequence: ConnectionTokenAttestation, ConnectionTimeout, ConnectionMetrics, and finally ConnectionBasic. Each layer destroys the one it owns, and ConnectionBasic's destructor is what frees the secure channel.

The allocation stack shows the object was created by SecureChannelImpl::FactoryImpl::Create() inside the ConnectionBasic constructor, which is consistent with the ownership chain described below.

Root cause

The vulnerable function is SecureChannelImpl::OnDecryptedResponse(). The researcher annotates the callback invocation as the point where this is deleted:

C++
void SecureChannelImpl::OnDecryptedResponse(
    const std::optional<Request>& decrypted_response) {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

  if (!decrypted_response.has_value()) {
    DLOG(ERROR) << "Failed to decrypt response.";
    FailAllRequestsAndClose(ErrorCode::kDecryptionFailed);
    return;
  }
  DVLOG(1) << "Response decrypted successfully.";

  CHECK(response_callback_);
   response_callback_.Run(base::ok(*decrypted_response)); //@audit: the response_callback_ will delete |this|

  ProcessPendingEncryptionRequests();
}

void SecureChannelImpl::ProcessPendingEncryptionRequests() {
  DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

  DCHECK_EQ(state_, State::kEstablished);
  if (state_ != State::kEstablished) { //@audit: use after |this| hase been deleted
    return;
  }

Line by line:

  • void SecureChannelImpl::OnDecryptedResponse(...) declares a function that returns nothing (void) and belongs to the SecureChannelImpl class. It takes the decrypted reply as its argument.
  • DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); is a debug-only check that the function is running on the thread it is supposed to run on. A sequence in Chromium is a queue of tasks that must run in order on one thread.
  • if (!decrypted_response.has_value()) asks whether the reply is missing. If decryption failed, there is no value.
  • DLOG(ERROR) << "Failed to decrypt response."; writes a debug log line saying decryption failed.
  • FailAllRequestsAndClose(ErrorCode::kDecryptionFailed); marks all waiting requests as failed and closes the channel.
  • return; leaves the function early, because there is nothing more to do.
  • DVLOG(1) << "Response decrypted successfully."; logs, in debug builds, that decryption worked.
  • CHECK(response_callback_); is a hard check that a callback has actually been set. If it has not, the program stops immediately rather than continuing in an unknown state.
  • response_callback_.Run(base::ok(*decrypted_response)); is the crucial line. It runs the stored callback and passes it the successful reply. The comment marks this as the audit point: running this callback will delete this, the very object we are inside.
  • ProcessPendingEncryptionRequests(); is called next, on the now-deleted object. This is the second audit point.
  • In ProcessPendingEncryptionRequests(), DCHECK_EQ(state_, State::kEstablished); checks in debug builds that the channel is in the established state.
  • if (state_ != State::kEstablished) reads state_, a member variable of the object. Reading a member variable means reading from the object's memory, and that memory has been freed. This is the use-after-free.
  • return; would leave the function if the state were wrong, but the damage is already done by the read itself.

The ownership chain is ClientImpl → ConnectionBasic → SecureChannelImpl. Ownership here means "this object is responsible for destroying that object". SecureChannelImpl is owned by a std::unique_ptr created by ConnectionBasic. A std::unique_ptr is a C++ smart pointer that holds exactly one owner for an object and automatically deletes it when the pointer itself goes away, so you cannot forget to free it.

C++
ConnectionBasic::ConnectionBasic(
    std::unique_ptr<SecureChannel::Factory> secure_channel_factory,
    base::OnceClosure on_disconnect)
    : on_disconnect_(std::move(on_disconnect)) {
  CHECK(secure_channel_factory);
  CHECK(on_disconnect_);

  secure_channel_ = secure_channel_factory->Create(base::BindRepeating(
      &ConnectionBasic::OnResponseReceived, weak_factory_.GetWeakPtr()));
  CHECK(secure_channel_);
}

Line by line:

  • The constructor takes two things: a factory for making secure channels, and a closure to run when the connection disconnects.
  • : on_disconnect_(std::move(on_disconnect)) stores the disconnect closure in a member variable. std::move transfers it in rather than copying it.
  • CHECK(secure_channel_factory); and CHECK(on_disconnect_); stop the program if either was not provided, because the object cannot work without them.
  • secure_channel_ = secure_channel_factory->Create(...) asks the factory to build the secure channel and stores it. The argument is a callback: base::BindRepeating(&ConnectionBasic::OnResponseReceived, weak_factory_.GetWeakPtr()). This means "when a response arrives, call ConnectionBasic::OnResponseReceived". base::BindRepeating makes a callback that can run more than once. weak_factory_.GetWeakPtr() produces a weak pointer, a reference that does not keep the object alive and that becomes invalid automatically if the object is destroyed. A weak pointer is like a name in a phone book rather than a guarantee the person still lives there: you can try to call, but you check first whether the line is still connected.
  • CHECK(secure_channel_); stops the program if the factory failed to produce a channel.

ConnectionBasic is itself owned by a std::unique_ptr in ClientImpl, created through the connection factory:

C++
std::unique_ptr<Connection> CreateBasicMetricsTimeoutConnection(
    const GURL& url,
    network::mojom::NetworkContext* network_context,
    LegionLogger* logger,
    base::OnceClosure on_disconnect) {
  auto connection_basic = std::make_unique<ConnectionBasic>(
      std::make_unique<SecureChannelImpl::FactoryImpl>(url, network_context,
                                                       logger),
      std::move(on_disconnect));

  auto connection_metrics =
      std::make_unique<ConnectionMetrics>(std::move(connection_basic));

  auto connection_timeout =
      std::make_unique<ConnectionTimeout>(std::move(connection_metrics));

  return connection_timeout;
}

Line by line:

  • The function takes the server URL, a network context (the object that provides network access), a logger, and the disconnect closure.
  • auto connection_basic = std::make_unique<ConnectionBasic>(...) creates the ConnectionBasic object, giving it a new secure channel factory and the disconnect closure. std::make_unique is the standard way to create an object owned by a unique_ptr.
  • auto connection_metrics = std::make_unique<ConnectionMetrics>(std::move(connection_basic)); wraps the basic connection in a metrics layer, which presumably records statistics. The inner object is moved inside, so the metrics layer now owns it.
  • auto connection_timeout = std::make_unique<ConnectionTimeout>(std::move(connection_metrics)); wraps that in a timeout layer.
  • return connection_timeout; hands the outermost layer back to the caller. This is why the free stack shows the destructors unwinding through ConnectionTokenAttestation, ConnectionTimeout, ConnectionMetrics and finally ConnectionBasic: each layer owns the next one inwards.
C++
Connection* ClientImpl::GetOrCreateConnection() {
  if (!connection_) {
    connection_ = connection_factory_->Create(base::BindRepeating(
        &ClientImpl::OnConnectionDisconnected, base::Unretained(this)));
  }
  return connection_.get();
}

Line by line:

  • if (!connection_) checks whether a connection already exists.
  • connection_ = connection_factory_->Create(...) creates one if not. The callback passed in is base::BindRepeating(&ClientImpl::OnConnectionDisconnected, base::Unretained(this)), meaning "when the connection disconnects, call ClientImpl::OnConnectionDisconnected on this object". base::Unretained(this) means the callback holds a plain pointer to the object without any safety net: it does not keep the object alive and it does not notice if the object is destroyed. That is a deliberate choice here, but it is exactly the kind of binding worth scrutinising in teardown paths.
  • return connection_.get(); returns a plain pointer to the connection without giving up ownership.

The disconnect closure is registered in ClientImpl and resets the connection:

C++
void ClientImpl::OnConnectionDisconnected() {
  logger_->LogInfo(FROM_HERE,
                   "Connection disconnected. Destroying connection.");
  connection_.reset();
}

Line by line:

  • logger_->LogInfo(FROM_HERE, "Connection disconnected. Destroying connection."); writes a log message saying the connection is being destroyed.
  • connection_.reset(); is the destructive line. Resetting a unique_ptr destroys the object it owns. Since connection_ is the outermost layer, this destroys the whole chain down to SecureChannelImpl.

ConnectionBasic passes ConnectionBasic::OnResponseReceived to SecureChannelImpl as the response callback. When that callback fires, it reaches HandleDisconnect(), which runs the ClientImpl::OnConnectionDisconnected() closure, which resets connection_. That destroys ConnectionBasic, which destroys SecureChannelImpl, while SecureChannelImpl::OnDecryptedResponse() is still on the stack. The subsequent call to ProcessPendingEncryptionRequests() then reads state_ from freed memory.

The source references cited in the report are:

  1. components/legion/secure_channel_impl.cc line 357
  2. components/legion/connection_basic.cc line 26
  3. components/legion/connection_factory_impl.cc line 33
  4. components/legion/client_impl.cc line 95
  5. components/legion/client_impl.cc line 183

The ASan report also notes that the crash is still exploitable with MiraclePtr, and that no raw_ptr<T> access to the region was detected prior to this crash. MiraclePtr is a Chromium defence that makes certain dangling pointers (pointers to objects that have already been freed) fail safely instead of silently reading freed memory; raw_ptr<T> is the pointer type that participates in that defence. The note says this particular crash does not go through that protection, so it remains exploitable. The freed region is 144 bytes, and the read is 32 bytes into it.

Impact

The researcher states that this UAF can be exploited to escape the sandbox without requiring a compromised renderer. The bug is triggered by a UI event (hovering the "Ask Gemini" button) rather than by renderer-controlled input. The report does not describe a full exploit chain, only the primitive and the reachability. A primitive here means the basic capability the bug gives an attacker, such as reading or writing memory they should not; turning a primitive into a full attack is a separate, harder step. The severity assigned by the program is medium, and the bounty was 11,000 USD.

Fix

The report does not describe the patch that was applied. The researcher's own change.txt is explicitly a test aid that simulates a successful decryption to trigger the callback, not a fix.

Variants to test

The report does not list variants. Based on the pattern shown, the general shape to look for elsewhere is a callback that can destroy the object it is invoked from, followed by any use of this after the callback returns. Concretely, on other Chromium components or similar callback-heavy C++ codebases:

  1. Look for member functions that run a OnceCallback or RepeatingCallback and then touch member state. A positive result is an ASan heap-use-after-free whose free stack passes through the callback and whose use stack is in the same method after the callback line.
  2. Look for ownership chains where a child object registers a callback that reaches a parent's reset() on a unique_ptr. A positive result is the child being freed while its own method is still executing.
  3. Look for base::Unretained(this) bindings in disconnect or teardown paths. A positive result is a callback that runs after the bound object has been destroyed.
  4. Look for UI-event-driven session creation (hover, focus, visibility) that starts network or crypto work. A positive result is a crash reachable without any renderer involvement, which is the property that makes this class of bug interesting for sandbox escape.

Glossary

  • ASAN (AddressSanitizer): a tool built into a special test build of a program that detects illegal memory access, such as reading memory that has already been freed, and prints a detailed report.
  • Allocation stack: the list of function calls that were running when a piece of memory was created, recorded so you can trace where an object came from.
  • Attestation: the process of proving that a client or device is genuine.
  • Bisect: a search technique that repeatedly halves the range of candidate versions to find the single change that introduced a bug.
  • Bounty: money paid by a company to someone who reports a security bug through its programme.
  • Browser process: the main Chrome process that manages tabs, settings and the user interface, outside the sandbox.
  • Callback: a piece of code handed to another part of the program to be run later, when something finishes.
  • Class: a blueprint in code describing an object and what it can do.
  • Closure: a callback that carries saved context with it.
  • Commit: one recorded change to source code, with a message explaining it.
  • Constructor: the setup routine that runs when an object is created.
  • CVE: a public identifier for a known security vulnerability.
  • Decryption: turning scrambled (encrypted) data back into readable data.
  • Destructor: the routine that runs when an object is destroyed, written with a ~ before the class name.
  • Factory: a function whose job is to create objects for other code.
  • Feature flag: a switch inside a program that turns an experimental feature on or off.
  • Free stack: the list of function calls that were running when a piece of memory was released, showing who destroyed an object.
  • Heap: the area of memory a program uses for objects it creates while running.
  • Heap use-after-free: a bug where a program frees a chunk of heap memory and then reads or writes it again.
  • Instance: one actual copy of a class in memory while the program runs.
  • MiraclePtr: a Chromium defence that makes certain dangling pointers fail safely instead of silently reading freed memory.
  • Object: an instance of a class in memory.
  • Ownership: the rule that one object is responsible for destroying another.
  • Patch: a small edit to source code, often applied before compiling.
  • Primitive: the basic capability a bug gives an attacker, such as reading or writing memory they should not.
  • PrivateAI: the Chrome component involved, which includes the "Ask Gemini" feature.
  • raw_ptr<T>: a Chromium pointer type that participates in the MiraclePtr defence.
  • Renderer: the process that runs a web page's code inside the sandbox.
  • Sandbox: the security boundary that keeps a web page's code from directly touching your files or other programs.
  • Sequence: in Chromium, a queue of tasks that must run in order on one thread.
  • Severity: a rating of how serious a vulnerability is, often low, medium, high or critical.
  • Smart pointer: a C++ object that behaves like a pointer but manages the lifetime of what it points to.
  • std::unique_ptr: a C++ smart pointer that holds exactly one owner for an object and deletes it automatically when the pointer goes away.
  • Thread: a sequence of instructions a program runs; the UI thread handles what you see and click.
  • Token: a short-lived credential proving the client is genuine.
  • UI thread: the thread that handles the user interface, including mouse and keyboard events.
  • Use-after-free: reading or writing memory after it has been freed.
  • VRP (Vulnerability Reward Program): a company scheme that pays people for reporting security bugs.
  • Weak pointer: a reference that does not keep an object alive and becomes invalid automatically if the object is destroyed.

More by Weipeng Jiang

View all

8 more disclosed reports, best first.

More from Google Chrome

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.