diff --git a/content/browser/interest_group/interest_group_auction.cc b/content/browser/interest_group/interest_group_auction.cc index 04f467fa75449..51eb0ede0d074 100644 --- a/content/browser/interest_group/interest_group_auction.cc +++ b/content/browser/interest_group/interest_group_auction.cc @@ -1628,6 +1628,17 @@ class InterestGroupAuction::BuyerHelper base::TimeDelta trusted_signals_fetch_latency, std::optional update_if_older_than, base::OnceClosure resume_generate_bid_callback) override { + // Reject non-finite values. The worklet code should prevent this, but the + // process may be compromised. A NaN that reaches `calculated_priority` + // breaks the strict-weak-ordering invariant of the comparators used in + // ApplySizeLimitAndSort(), which can cause out-of-bounds iterator walks. + if (std::ranges::any_of(priority_vector, [](const auto& pair) { + return !std::isfinite(pair.second); + })) { + generate_bid_client_receiver_set_.ReportBadMessage( + "Invalid priority vector"); + return; + } BidState* state = generate_bid_client_receiver_set_.current_context(); const blink::InterestGroup& interest_group = state->bidder->interest_group; state->pa_timings(PrivateAggregationPhase::kBidder).signals_fetch_time =