Skip to content
Memory corruption Advisory Advanced CVE-2024-6994

Heap buffer overflow in Layout (CVE-2024-6994)

A heap buffer overflow occurs in Chromium's grid layout code when the number of grid items exceeds the cached placement data, causing an out-of-bounds read. An attacker could trigger a tab crash by serving a crafted HTML page.

Huang Xilin Follow

Originally disclosed on Chrome VRP

Bounty$8,000 Medium View original
  • Fix shipped in 2 months

Steps to reproduce the problem

  1. Serve poc.html on port 8080
  2. Launch chrome and then access http://127.0.0.1:8080/poc.html

Problem Description

C++
GridItems GridNode::ConstructGridItems(
    const GridLineResolver& line_resolver,
    const ComputedStyle& root_grid_style,
    const ComputedStyle& parent_grid_style,
    bool must_consider_grid_items_for_column_sizing,
    bool must_consider_grid_items_for_row_sizing,
    bool* must_invalidate_placement_cache,
    HeapVector<Member<LayoutBox>>* opt_oof_children,
    bool* opt_has_nested_subgrid) const {
  DCHECK(must_invalidate_placement_cache);

  if (opt_has_nested_subgrid) {
    *opt_has_nested_subgrid = false;
  }

  GridItems grid_items;
  auto* layout_grid = To<LayoutGrid>(box_.Get());
  const GridPlacementData* cached_placement_data = nullptr;

  if (layout_grid->HasCachedPlacementData()) {
    cached_placement_data = &layout_grid->CachedPlacementData();

    // Even if the cached placement data is incorrect, as long as the grid is
    // not marked as dirty, the grid item count should be the same.
    grid_items.ReserveInitialCapacity(
        cached_placement_data->grid_item_positions.size());

    if (*must_invalidate_placement_cache ||
        line_resolver != cached_placement_data->line_resolver) {
      // We need to recompute grid item placement if the automatic column/row
      // repetitions changed due to updates in the container's style or if any
      // grid in the ancestor chain invalidated its subtree's placement cache.
      cached_placement_data = nullptr;
    }
  }

  // Placement cache gets invalidated when there are significant changes in this
  // grid's computed style. However, these changes might alter the placement of
  // subgridded items, so this flag is used to signal that we need to recurse
  // into subgrids to recompute their placement.
  *must_invalidate_placement_cache |= !cached_placement_data;

  {
    bool should_sort_grid_items_by_order_property = false;
    const int initial_order = ComputedStyleInitialValues::InitialOrder();

    for (auto child = FirstChild(); child; child = child.NextSibling()) {
      if (child.IsOutOfFlowPositioned()) {
        if (opt_oof_children) {
          opt_oof_children->emplace_back(child.GetLayoutBox());
        }
        continue;
      }

      auto grid_item = std::make_unique<GridItemData>(
          To<BlockNode>(child), parent_grid_style, root_grid_style,
          must_consider_grid_items_for_column_sizing,
          must_consider_grid_items_for_row_sizing);

      // We'll need to sort when we encounter a non-initial order property.
      should_sort_grid_items_by_order_property |=
          child.Style().Order() != initial_order;

      // Check whether we'll need to further append subgridded items.
      if (opt_has_nested_subgrid) {
        *opt_has_nested_subgrid |= grid_item->IsSubgrid();
      }
      grid_items.Append(std::move(grid_item));
    }

    if (should_sort_grid_items_by_order_property)
      grid_items.SortByOrderProperty();
  }

#if DCHECK_IS_ON()
  if (cached_placement_data) {
    GridPlacement grid_placement(Style(), line_resolver);
    DCHECK(*cached_placement_data ==
           grid_placement.RunAutoPlacementAlgorithm(grid_items));
  }
#endif

  if (!cached_placement_data) {
    GridPlacement grid_placement(Style(), line_resolver);
    layout_grid->SetCachedPlacementData(
        grid_placement.RunAutoPlacementAlgorithm(grid_items));
    cached_placement_data = &layout_grid->CachedPlacementData();
  }

  // Copy each resolved position to its respective grid item data.
  auto* resolved_position = cached_placement_data->grid_item_positions.begin();
  for (auto& grid_item : grid_items) {
    grid_item.resolved_position = *(resolved_position++);   <----------- [1]
  }
  return grid_items;
}

[1] The iterator was not checked to see if it has reached the end of the container.

Summary

HeapBufferOverflow in GridNode::ConstructGridItems

Custom Questions

Type of crash:

tab

Crash state:

================================================================= ==1==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x50300008e2e8 at pc 0x560075f4c57b bp 0x7fff77509670 sp 0x7fff77508e30 READ of size 24 at 0x50300008e2e8 thread T0 (chrome) ==1==WARNING: invalid path to external symbolizer! ==1==WARNING: Failed to use and restart external symbolizer! #0 0x560075f4c57a in __asan_memcpy asan_rtl:3 #1 0x560095d78a73 in blink::GridNode::ConstructGridItems(blink::GridLineResolver const&, blink::ComputedStyle const&, blink::ComputedStyle const&, bool, bool, bool*, blink::HeapVector<cppgc::internal::BasicMember<blink::LayoutBox, cppgc::internal::StrongMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer>, 0u>, bool) const ./../../third_party/blink/renderer/core/layout/grid/grid_node.cc:118:33 #2 0x560095d7787c in blink::GridNode::ConstructGridItems(blink::GridLineResolver const&, bool*, blink::HeapVector<cppgc::internal::BasicMember<blink::LayoutBox, cppgc::internal::StrongMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer>, 0u>, bool) const ./../../third_party/blink/renderer/core/layout/grid/grid_node.cc:18:10 #3 0x560095d1fdd4 in blink::GridLayoutAlgorithm::BuildGridSizingSubtree(blink::GridSizingTree*, blink::HeapVector<cppgc::internal::BasicMember<blink::LayoutBox, cppgc::internal::StrongMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer>, 0u>, blink::SubgriddedItemData const&, blink::GridLineResolver const, bool, bool) const ./../../third_party/blink/renderer/core/layout/grid/grid_layout_algorithm.cc:543:14 #4 0x560095d15ca5 in blink::GridLayoutAlgorithm::BuildGridSizingTree(blink::HeapVector<cppgc::internal::BasicMember<blink::LayoutBox, cppgc::internal::StrongMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer>, 0u>) const ./../../third_party/blink/renderer/core/layout/grid/grid_layout_algorithm.cc:696:5 #5 0x560095d1eb0d in blink::GridLayoutAlgorithm::ComputeMinMaxSizes(blink::MinMaxSizesFloatInput const&) ./../../third_party/blink/renderer/core/layout/grid/grid_layout_algorithm.cc:380:33 #6 0x560095c0048f in operator()blink::GridLayoutAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:221:25 #7 0x560095c0048f in void blink::(anonymous namespace)::CreateAlgorithmAndRun<blink::GridLayoutAlgorithm, blink::(anonymous namespace)::ComputeMinMaxSizesWithAlgorithm(blink::LayoutAlgorithmParams const&, blink::MinMaxSizesFloatInput const&)::'lambda'<typename $T>($T)>(blink::LayoutAlgorithmParams const&, blink::(anonymous namespace)::ComputeMinMaxSizesWithAlgorithm(blink::LayoutAlgorithmParams const&, blink::MinMaxSizesFloatInput const&)::'lambda'<typename $T>($T*) const&) ./../../third_party/blink/renderer/core/layout/block_node.cc:118:3 #8 0x560095bea596 in ComputeMinMaxSizesWithAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:219:3 #9 0x560095bea596 in blink::BlockNode::ComputeMinMaxSizes(blink::WritingMode, blink::MinMaxSizesType, blink::ConstraintSpace const&, blink::MinMaxSizesFloatInput) const ./../../third_party/blink/renderer/core/layout/block_node.cc:972:30 #10 0x560096044d2c in operator() ./../../third_party/abseil-cpp/absl/functional/function_ref.h:132:12 #11 0x560096044d2c in operator() ./../../base/functional/function_ref.h:124:12 #12 0x560096044d2c in blink::ResolveInlineLengthInternal(blink::ConstraintSpace const&, blink::ComputedStyle const&, blink::BoxStrut const&, base::FunctionRef<blink::MinMaxSizesResult (blink::MinMaxSizesType)>, blink::Length const&, blink::Length const*, blink::LayoutUnit, blink::LayoutUnit) ./../../third_party/blink/renderer/core/layout/length_utils.cc:87:11 #13 0x56009604a4a0 in ResolveMainInlineLength ./../../third_party/blink/renderer/core/layout/length_utils.h:131:10 #14 0x56009604a4a0 in blink::ComputeInlineSizeForFragmentInternal(blink::ConstraintSpace const&, blink::BlockNode const&, blink::BoxStrut const&, base::FunctionRef<blink::MinMaxSizesResult (blink::MinMaxSizesType)>) ./../../third_party/blink/renderer/core/layout/length_utils.cc:479:14 #15 0x56009604b3a8 in blink::ComputeInlineSizeForFragment(blink::ConstraintSpace const&, blink::BlockNode const&, blink::BoxStrut const&, base::FunctionRef<blink::MinMaxSizesResult (blink::MinMaxSizesType)>) ./../../third_party/blink/renderer/core/layout/length_utils.cc:507:10 #16 0x560096054cf9 in blink::CalculateInitialFragmentGeometry(blink::ConstraintSpace const&, blink::BlockNode const&, blink::BlockBreakToken const*, base::FunctionRef<blink::MinMaxSizesResult (blink::MinMaxSizesType)>, bool) ./../../third_party/blink/renderer/core/layout/length_utils.cc:1460:22 #17 0x56009605590b in blink::CalculateInitialFragmentGeometry(blink::ConstraintSpace const&, blink::BlockNode const&, blink::BlockBreakToken const*, bool) ./../../third_party/blink/renderer/core/layout/length_utils.cc:1501:10 #18 0x560095be056e in blink::BlockNode::Layout(blink::ConstraintSpace const&, blink::BlockBreakToken const*, blink::EarlyBreak const*, blink::ColumnSpannerPath const*) const ./../../third_party/blink/renderer/core/layout/block_node.cc:395:9 #19 0x560095bf3e92 in blink::BlockNode::LayoutAtomicInline(blink::ConstraintSpace const&, blink::ComputedStyle const&, bool, blink::BaselineAlgorithmType) ./../../third_party/blink/renderer/core/layout/block_node.cc:1536:32 #20 0x560095de9e3f in blink::LineBreaker::HandleAtomicInline(blink::InlineItem const&, blink::LineInfo*) ./../../third_party/blink/renderer/core/layout/inline/line_breaker.cc:3000:14 #21 0x560095de0e4f in blink::LineBreaker::BreakLine(blink::LineInfo*) ./../../third_party/blink/renderer/core/layout/inline/line_breaker.cc:0:7 #22 0x560095ddcfb0 in blink::LineBreaker::NextLine(blink::LineInfo*) ./../../third_party/blink/renderer/core/layout/inline/line_breaker.cc:840:3 #23 0x560095b4f075 in blink::InlineLayoutAlgorithm::Layout() ./../../third_party/blink/renderer/core/layout/inline/inline_layout_algorithm.cc:1129:20 #24 0x560095af0080 in blink::InlineNode::Layout(blink::ConstraintSpace const&, blink::BreakToken const*, blink::ColumnSpannerPath const*, blink::InlineChildLayoutContext*) const ./../../third_party/blink/renderer/core/layout/inline/inline_node.cc:1658:20 #25 0x560095cf5ee8 in blink::(anonymous namespace)::LayoutInflow(blink::ConstraintSpace const&, blink::BreakToken const*, blink::EarlyBreak const*, blink::ColumnSpannerPath const*, blink::LayoutInputNode*, blink::InlineChildLayoutContext*) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:125:25 #26 0x560095cf535b in blink::BlockLayoutAlgorithm::HandleInflow(blink::LayoutInputNode, blink::BreakToken const*, blink::PreviousInflowPosition*, blink::InlineChildLayoutContext*, blink::InlineBreakToken const**) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:1998:7 #27 0x560095cd9576 in blink::BlockLayoutAlgorithm::Layout(blink::InlineChildLayoutContext*) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:878:18 #28 0x560095cdd71d in blink::BlockLayoutAlgorithm::LayoutWithSimpleInlineChildLayoutContext(blink::InlineNode const&) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:566:32 #29 0x560095cd789c in blink::BlockLayoutAlgorithm::Layout() ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:499:14 #30 0x560095bf7ffa in operator()blink::BlockLayoutAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:210:50 #31 0x560095bf7ffa in void blink::(anonymous namespace)::CreateAlgorithmAndRun<blink::BlockLayoutAlgorithm, blink::(anonymous namespace)::LayoutWithAlgorithm(blink::LayoutAlgorithmParams const&)::'lambda'<typename $T>($T*)>(blink::LayoutAlgorithmParams const&, blink::(anonymous namespace)::LayoutWithAlgorithm(blink::LayoutAlgorithmParams const&)::'lambda'<typename $T>($T*) const&) ./../../third_party/blink/renderer/core/layout/block_node.cc:118:3 #32 0x560095be1143 in LayoutWithAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:208:3 #33 0x560095be1143 in blink::BlockNode::Layout(blink::ConstraintSpace const&, blink::BlockBreakToken const*, blink::EarlyBreak const*, blink::ColumnSpannerPath const*) const ./../../third_party/blink/renderer/core/layout/block_node.cc:465:21 #34 0x560095cf5f84 in LayoutBlockChild ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:113:16 #35 0x560095cf5f84 in blink::(anonymous namespace)::LayoutInflow(blink::ConstraintSpace const&, blink::BreakToken const*, blink::EarlyBreak const*, blink::ColumnSpannerPath const*, blink::LayoutInputNode*, blink::InlineChildLayoutContext*) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:128:10 #36 0x560095cf535b in blink::BlockLayoutAlgorithm::HandleInflow(blink::LayoutInputNode, blink::BreakToken const*, blink::PreviousInflowPosition*, blink::InlineChildLayoutContext*, blink::InlineBreakToken const**) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:1998:7 #37 0x560095cd9576 in blink::BlockLayoutAlgorithm::Layout(blink::InlineChildLayoutContext*) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:878:18 #38 0x560095cd78ae in blink::BlockLayoutAlgorithm::Layout() ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:501:14 #39 0x560095bf7ffa in operator()blink::BlockLayoutAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:210:50 #40 0x560095bf7ffa in void blink::(anonymous namespace)::CreateAlgorithmAndRun<blink::BlockLayoutAlgorithm, blink::(anonymous namespace)::LayoutWithAlgorithm(blink::LayoutAlgorithmParams const&)::'lambda'<typename $T>($T*)>(blink::LayoutAlgorithmParams const&, blink::(anonymous namespace)::LayoutWithAlgorithm(blink::LayoutAlgorithmParams const&)::'lambda'<typename $T>($T*) const&) ./../../third_party/blink/renderer/core/layout/block_node.cc:118:3 #41 0x560095be1143 in LayoutWithAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:208:3 #42 0x560095be1143 in blink::BlockNode::Layout(blink::ConstraintSpace const&, blink::BlockBreakToken const*, blink::EarlyBreak const*, blink::ColumnSpannerPath const*) const ./../../third_party/blink/renderer/core/layout/block_node.cc:465:21 #43 0x560095cf5f84 in LayoutBlockChild ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:113:16 #44 0x560095cf5f84 in blink::(anonymous namespace)::LayoutInflow(blink::ConstraintSpace const&, blink::BreakToken const*, blink::EarlyBreak const*, blink::ColumnSpannerPath const*, blink::LayoutInputNode*, blink::InlineChildLayoutContext*) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:128:10 #45 0x560095cf535b in blink::BlockLayoutAlgorithm::HandleInflow(blink::LayoutInputNode, blink::BreakToken const*, blink::PreviousInflowPosition*, blink::InlineChildLayoutContext*, blink::InlineBreakToken const**) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:1998:7 #46 0x560095cd9576 in blink::BlockLayoutAlgorithm::Layout(blink::InlineChildLayoutContext*) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:878:18 #47 0x560095cd78ae in blink::BlockLayoutAlgorithm::Layout() ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:501:14 #48 0x560095bf7ffa in operator()blink::BlockLayoutAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:210:50 #49 0x560095bf7ffa in void blink::(anonymous namespace)::CreateAlgorithmAndRun<blink::BlockLayoutAlgorithm, blink::(anonymous namespace)::LayoutWithAlgorithm(blink::LayoutAlgorithmParams const&)::'lambda'<typename $T>($T*)>(blink::LayoutAlgorithmParams const&, blink::(anonymous namespace)::LayoutWithAlgorithm(blink::LayoutAlgorithmParams const&)::'lambda'<typename $T>($T*) const&) ./../../third_party/blink/renderer/core/layout/block_node.cc:118:3 #50 0x560095be1143 in LayoutWithAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:208:3 #51 0x560095be1143 in blink::BlockNode::Layout(blink::ConstraintSpace const&, blink::BlockBreakToken const*, blink::EarlyBreak const*, blink::ColumnSpannerPath const*) const ./../../third_party/blink/renderer/core/layout/block_node.cc:465:21 #52 0x560095ce9d64 in LayoutBlockChild ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:113:16 #53 0x560095ce9d64 in blink::BlockLayoutAlgorithm::LayoutNewFormattingContext(blink::LayoutInputNode, blink::BlockBreakToken const*, blink::InflowChildData const&, blink::BfcOffset, bool, blink::BfcOffset*, blink::BoxStrut*) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:1812:41 #54 0x560095ce7334 in blink::BlockLayoutAlgorithm::HandleNewFormattingContext(blink::LayoutInputNode, blink::BlockBreakToken const*, blink::PreviousInflowPosition*) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:1604:39 #55 0x560095cd9668 in blink::BlockLayoutAlgorithm::Layout(blink::InlineChildLayoutContext*) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:873:18 #56 0x560095cd78ae in blink::BlockLayoutAlgorithm::Layout() ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:501:14 #57 0x560095bf7ffa in operator()blink::BlockLayoutAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:210:50 #58 0x560095bf7ffa in void blink::(anonymous namespace)::CreateAlgorithmAndRun<blink::BlockLayoutAlgorithm, blink::(anonymous namespace)::LayoutWithAlgorithm(blink::LayoutAlgorithmParams const&)::'lambda'<typename $T>($T*)>(blink::LayoutAlgorithmParams const&, blink::(anonymous namespace)::LayoutWithAlgorithm(blink::LayoutAlgorithmParams const&)::'lambda'<typename $T>($T*) const&) ./../../third_party/blink/renderer/core/layout/block_node.cc:118:3 #59 0x560095be1143 in LayoutWithAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:208:3 #60 0x560095be1143 in blink::BlockNode::Layout(blink::ConstraintSpace const&, blink::BlockBreakToken const*, blink::EarlyBreak const*, blink::ColumnSpannerPath const*) const ./../../third_party/blink/renderer/core/layout/block_node.cc:465:21 #61 0x560096036117 in blink::LayoutView::LayoutRoot() ./../../third_party/blink/renderer/core/layout/layout_view.cc:863:19 #62 0x560094e4e3de in blink::LocalFrameView::PerformLayout() ./../../third_party/blink/renderer/core/frame/local_frame_view.cc:782:24 #63 0x560094e505c8 in blink::LocalFrameView::UpdateLayout() ./../../third_party/blink/renderer/core/frame/local_frame_view.cc:841:3 #64 0x560094e6d0a2 in blink::LocalFrameView::UpdateStyleAndLayoutInternal() ./../../third_party/blink/renderer/core/frame/local_frame_view.cc:3166:7 #65 0x560094e5934f in blink::LocalFrameView::UpdateStyleAndLayout() ./../../third_party/blink/renderer/core/frame/local_frame_view.cc:3096:18 #66 0x560094e669ee in blink::LocalFrameView::UpdateStyleAndLayoutIfNeededRecursive() ./../../third_party/blink/renderer/core/frame/local_frame_view.cc:3019:3 #67 0x560094e63fa9 in blink::LocalFrameView::RunStyleAndLayoutLifecyclePhases(blink::DocumentLifecycle::LifecycleState) ./../../third_party/blink/renderer/core/frame/local_frame_view.cc:2475:3 #68 0x560094e63330 in blink::LocalFrameView::UpdateLifecyclePhasesInternal(blink::DocumentLifecycle::LifecycleState) ./../../third_party/blink/renderer/core/frame/local_frame_view.cc:2235:9 #69 0x560094e6100a in blink::LocalFrameView::UpdateLifecyclePhases(blink::DocumentLifecycle::LifecycleState, blink::DocumentUpdateReason) ./../../third_party/blink/renderer/core/frame/local_frame_view.cc:2167:3 #70 0x560094e60779 in blink::LocalFrameView::UpdateAllLifecyclePhases(blink::DocumentUpdateReason) ./../../third_party/blink/renderer/core/frame/local_frame_view.cc:1903:54 #71 0x5600966ab3ec in blink::PageAnimator::UpdateAllLifecyclePhases(blink::LocalFrame&, blink::DocumentUpdateReason) ./../../third_party/blink/renderer/core/page/page_animator.cc:397:9 #72 0x560094fa3e26 in blink::WebFrameWidgetImpl::UpdateLifecycle(blink::WebLifecycleUpdate, blink::DocumentUpdateReason) ./../../third_party/blink/renderer/core/frame/web_frame_widget_impl.cc:1584:14 #73 0x560097865e55 in UpdateVisualState ./../../third_party/blink/renderer/platform/widget/widget_base.cc:1017:12 #74 0x560097865e55 in non-virtual thunk to blink::WidgetBase::UpdateVisualState() ./../../third_party/blink/renderer/platform/widget/widget_base.cc:0:0 #75 0x56008cf5cdac in cc::LayerTreeHost::RequestMainFrameUpdate(bool) ./../../cc/trees/layer_tree_host.cc:376:12 #76 0x56008d20f822 in cc::ProxyMain::BeginMainFrame(std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState>) ./../../cc/trees/proxy_main.cc:283:21 #77 0x56008d2338c9 in Invoke<void (cc::ProxyMain::)(std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState >), const base::WeakPtrcc::ProxyMain &, std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState > > ./../../base/functional/bind_internal.h:738:12 #78 0x56008d2338c9 in MakeItSo<void (cc::ProxyMain::)(std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState >), std::__Cr::tuple<base::WeakPtrcc::ProxyMain, std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState > > > ./../../base/functional/bind_internal.h:954:5 #79 0x56008d2338c9 in void base::internal::Invoker<base::internal::FunctorTraits<void (cc::ProxyMain::&&)(std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState>), base::WeakPtrcc::ProxyMain&&, std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState>&&>, base::internal::BindState<true, true, false, void (cc::ProxyMain::)(std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState>), base::WeakPtrcc::ProxyMain, std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState>>, void ()>::RunImpl<void (cc::ProxyMain::)(std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState>), std::__Cr::tuple<base::WeakPtrcc::ProxyMain, std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState>>, 0ul, 1ul>(void (cc::ProxyMain::&&)(std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState>), std::__Cr::tuple<base::WeakPtrcc::ProxyMain, std::__Cr::unique_ptr<cc::BeginMainFrameAndCommitState, std::__Cr::default_deletecc::BeginMainFrameAndCommitState>>&&, std::__Cr::integer_sequence<unsigned long, 0ul, 1ul>) ./../../base/functional/bind_internal.h:1067:14 #80 0x56008824aaa4 in Run ./../../base/functional/callback.h:156:12 #81 0x56008824aaa4 in base::TaskAnnotator::RunTaskImpl(base::PendingTask&) ./../../base/task/common/task_annotator.cc:203:34 #82 0x5600882ab324 in RunTask<(lambda at ../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:475:11)> ./../../base/task/common/task_annotator.h:90:5 #83 0x5600882ab324 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl(base::LazyNow*) ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:473:23 #84 0x5600882aa23d in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:338:40 #85 0x5600882ac05a in non-virtual thunk to base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork() ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:0:0 #86 0x56008814390d in base::MessagePumpDefault::Run(base::MessagePump::Delegate*) ./../../base/message_loop/message_pump_default.cc:40:55 #87 0x5600882accd6 in base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run(bool, base::TimeDelta) ./../../base/task/sequence_manager/thread_controller_with_message_pump_impl.cc:645:12 #88 0x5600881dd35f in base::RunLoop::Run(base::Location const&) ./../../base/run_loop.cc:134:14 #89 0x56009f692673 in content::RendererMain(content::MainFunctionParams) ./../../content/renderer/renderer_main.cc:368:16 #90 0x56008591d9a9 in content::RunZygote(content::ContentMainDelegate*) ./../../content/app/content_main_runner_impl.cc:678:14 #91 0x56008591eefe in content::RunOtherNamedProcessTypeMain(std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char>> const&, content::MainFunctionParams, content::ContentMainDelegate*) ./../../content/app/content_main_runner_impl.cc:782:12 #92 0x560085921a91 in content::ContentMainRunnerImpl::Run() ./../../content/app/content_main_runner_impl.cc:1155:10 #93 0x56008591bcc0 in content::RunContentProcess(content::ContentMainParams, content::ContentMainRunner*) ./../../content/app/content_main.cc:332:36 #94 0x56008591c34b in content::ContentMain(content::ContentMainParams) ./../../content/app/content_main.cc:345:10 #95 0x560075f87408 in ChromeMain ./../../chrome/app/chrome_main.cc:192:12 #96 0x7f923b1b4d8f in __libc_init_first ??:?

0x50300008e2e8 is located 0 bytes after 24-byte region [0x50300008e2d0,0x50300008e2e8) allocated by thread T0 (chrome) here: #0 0x560075f4e78f in __interceptor_malloc asan_rtl:3 #1 0x5600884925bb in AllocInternal<(partition_alloc::internal::AllocFlags)0> ./../../base/allocator/partition_allocator/src/partition_alloc/partition_root.h:2072:51 #2 0x5600884925bb in AllocInline<(partition_alloc::internal::AllocFlags)0> ./../../base/allocator/partition_allocator/src/partition_alloc/partition_root.h:511:12 #3 0x5600884925bb in void* partition_alloc::PartitionRoot::Alloc<(partition_alloc::internal::AllocFlags)0>(unsigned long, char const*) ./../../base/allocator/partition_allocator/src/partition_alloc/partition_root.h:505:12 #4 0x560095d69b88 in AllocateVectorBackingblink::GridArea ./../../third_party/blink/renderer/platform/wtf/allocator/partition_allocator.h:40:9 #5 0x560095d69b88 in AllocateBufferNoBarrier ./../../third_party/blink/renderer/platform/wtf/vector.h:518:9 #6 0x560095d69b88 in AllocateBuffer ./../../third_party/blink/renderer/platform/wtf/vector.h:415:5 #7 0x560095d69b88 in ReserveInitialCapacity ./../../third_party/blink/renderer/platform/wtf/vector.h:1940:11 #8 0x560095d69b88 in blink::GridPlacement::PlaceNonAutoGridItems(blink::GridItems const&, blink::GridPlacement::PlacedGridItemsList*, WTF::Vector<blink::GridArea*, 16u, WTF::PartitionAllocator>, WTF::Vector<blink::GridArea, 16u, WTF::PartitionAllocator>) ./../../third_party/blink/renderer/core/layout/grid/grid_placement.cc:126:39 #9 0x560095d6880b in blink::GridPlacement::RunAutoPlacementAlgorithm(blink::GridItems const&) ./../../third_party/blink/renderer/core/layout/grid/grid_placement.cc:72:8 #10 0x560095d7894a in blink::GridNode::ConstructGridItems(blink::GridLineResolver const&, blink::ComputedStyle const&, blink::ComputedStyle const&, bool, bool, bool, blink::HeapVector<cppgc::internal::BasicMember<blink::LayoutBox, cppgc::internal::StrongMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer>, 0u>, bool) const ./../../third_party/blink/renderer/core/layout/grid/grid_node.cc:111:24 #11 0x560095d7787c in blink::GridNode::ConstructGridItems(blink::GridLineResolver const&, bool*, blink::HeapVector<cppgc::internal::BasicMember<blink::LayoutBox, cppgc::internal::StrongMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer>, 0u>, bool) const ./../../third_party/blink/renderer/core/layout/grid/grid_node.cc:18:10 #12 0x560095d1fdd4 in blink::GridLayoutAlgorithm::BuildGridSizingSubtree(blink::GridSizingTree*, blink::HeapVector<cppgc::internal::BasicMember<blink::LayoutBox, cppgc::internal::StrongMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer>, 0u>, blink::SubgriddedItemData const&, blink::GridLineResolver const, bool, bool) const ./../../third_party/blink/renderer/core/layout/grid/grid_layout_algorithm.cc:543:14 #13 0x560095d15ca5 in blink::GridLayoutAlgorithm::BuildGridSizingTree(blink::HeapVector<cppgc::internal::BasicMember<blink::LayoutBox, cppgc::internal::StrongMemberTag, cppgc::internal::DijkstraWriteBarrierPolicy, cppgc::internal::DisabledCheckingPolicy, cppgc::internal::CompressedPointer>, 0u>) const ./../../third_party/blink/renderer/core/layout/grid/grid_layout_algorithm.cc:696:5 #14 0x560095d1eb0d in blink::GridLayoutAlgorithm::ComputeMinMaxSizes(blink::MinMaxSizesFloatInput const&) ./../../third_party/blink/renderer/core/layout/grid/grid_layout_algorithm.cc:380:33 #15 0x560095c0048f in operator()blink::GridLayoutAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:221:25 #16 0x560095c0048f in void blink::(anonymous namespace)::CreateAlgorithmAndRun<blink::GridLayoutAlgorithm, blink::(anonymous namespace)::ComputeMinMaxSizesWithAlgorithm(blink::LayoutAlgorithmParams const&, blink::MinMaxSizesFloatInput const&)::'lambda'<typename $T>($T)>(blink::LayoutAlgorithmParams const&, blink::(anonymous namespace)::ComputeMinMaxSizesWithAlgorithm(blink::LayoutAlgorithmParams const&, blink::MinMaxSizesFloatInput const&)::'lambda'<typename $T>($T*) const&) ./../../third_party/blink/renderer/core/layout/block_node.cc:118:3 #17 0x560095bea596 in ComputeMinMaxSizesWithAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:219:3 #18 0x560095bea596 in blink::BlockNode::ComputeMinMaxSizes(blink::WritingMode, blink::MinMaxSizesType, blink::ConstraintSpace const&, blink::MinMaxSizesFloatInput) const ./../../third_party/blink/renderer/core/layout/block_node.cc:972:30 #19 0x560096044d2c in operator() ./../../third_party/abseil-cpp/absl/functional/function_ref.h:132:12 #20 0x560096044d2c in operator() ./../../base/functional/function_ref.h:124:12 #21 0x560096044d2c in blink::ResolveInlineLengthInternal(blink::ConstraintSpace const&, blink::ComputedStyle const&, blink::BoxStrut const&, base::FunctionRef<blink::MinMaxSizesResult (blink::MinMaxSizesType)>, blink::Length const&, blink::Length const*, blink::LayoutUnit, blink::LayoutUnit) ./../../third_party/blink/renderer/core/layout/length_utils.cc:87:11 #22 0x56009604a4a0 in ResolveMainInlineLength ./../../third_party/blink/renderer/core/layout/length_utils.h:131:10 #23 0x56009604a4a0 in blink::ComputeInlineSizeForFragmentInternal(blink::ConstraintSpace const&, blink::BlockNode const&, blink::BoxStrut const&, base::FunctionRef<blink::MinMaxSizesResult (blink::MinMaxSizesType)>) ./../../third_party/blink/renderer/core/layout/length_utils.cc:479:14 #24 0x56009604b3a8 in blink::ComputeInlineSizeForFragment(blink::ConstraintSpace const&, blink::BlockNode const&, blink::BoxStrut const&, base::FunctionRef<blink::MinMaxSizesResult (blink::MinMaxSizesType)>) ./../../third_party/blink/renderer/core/layout/length_utils.cc:507:10 #25 0x560096054cf9 in blink::CalculateInitialFragmentGeometry(blink::ConstraintSpace const&, blink::BlockNode const&, blink::BlockBreakToken const*, base::FunctionRef<blink::MinMaxSizesResult (blink::MinMaxSizesType)>, bool) ./../../third_party/blink/renderer/core/layout/length_utils.cc:1460:22 #26 0x56009605590b in blink::CalculateInitialFragmentGeometry(blink::ConstraintSpace const&, blink::BlockNode const&, blink::BlockBreakToken const*, bool) ./../../third_party/blink/renderer/core/layout/length_utils.cc:1501:10 #27 0x560095be056e in blink::BlockNode::Layout(blink::ConstraintSpace const&, blink::BlockBreakToken const*, blink::EarlyBreak const*, blink::ColumnSpannerPath const*) const ./../../third_party/blink/renderer/core/layout/block_node.cc:395:9 #28 0x560095bf3e92 in blink::BlockNode::LayoutAtomicInline(blink::ConstraintSpace const&, blink::ComputedStyle const&, bool, blink::BaselineAlgorithmType) ./../../third_party/blink/renderer/core/layout/block_node.cc:1536:32 #29 0x560095de9e3f in blink::LineBreaker::HandleAtomicInline(blink::InlineItem const&, blink::LineInfo*) ./../../third_party/blink/renderer/core/layout/inline/line_breaker.cc:3000:14 #30 0x560095de0e4f in blink::LineBreaker::BreakLine(blink::LineInfo*) ./../../third_party/blink/renderer/core/layout/inline/line_breaker.cc:0:7 #31 0x560095ddcfb0 in blink::LineBreaker::NextLine(blink::LineInfo*) ./../../third_party/blink/renderer/core/layout/inline/line_breaker.cc:840:3 #32 0x560095b4f075 in blink::InlineLayoutAlgorithm::Layout() ./../../third_party/blink/renderer/core/layout/inline/inline_layout_algorithm.cc:1129:20 #33 0x560095af0080 in blink::InlineNode::Layout(blink::ConstraintSpace const&, blink::BreakToken const*, blink::ColumnSpannerPath const*, blink::InlineChildLayoutContext*) const ./../../third_party/blink/renderer/core/layout/inline/inline_node.cc:1658:20 #34 0x560095cf5ee8 in blink::(anonymous namespace)::LayoutInflow(blink::ConstraintSpace const&, blink::BreakToken const*, blink::EarlyBreak const*, blink::ColumnSpannerPath const*, blink::LayoutInputNode*, blink::InlineChildLayoutContext*) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:125:25 #35 0x560095cf535b in blink::BlockLayoutAlgorithm::HandleInflow(blink::LayoutInputNode, blink::BreakToken const*, blink::PreviousInflowPosition*, blink::InlineChildLayoutContext*, blink::InlineBreakToken const**) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:1998:7 #36 0x560095cd9576 in blink::BlockLayoutAlgorithm::Layout(blink::InlineChildLayoutContext*) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:878:18 #37 0x560095cdd71d in blink::BlockLayoutAlgorithm::LayoutWithSimpleInlineChildLayoutContext(blink::InlineNode const&) ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:566:32 #38 0x560095cd789c in blink::BlockLayoutAlgorithm::Layout() ./../../third_party/blink/renderer/core/layout/block_layout_algorithm.cc:499:14 #39 0x560095bf7ffa in operator()blink::BlockLayoutAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:210:50 #40 0x560095bf7ffa in void blink::(anonymous namespace)::CreateAlgorithmAndRun<blink::BlockLayoutAlgorithm, blink::(anonymous namespace)::LayoutWithAlgorithm(blink::LayoutAlgorithmParams const&)::'lambda'<typename $T>($T*)>(blink::LayoutAlgorithmParams const&, blink::(anonymous namespace)::LayoutWithAlgorithm(blink::LayoutAlgorithmParams const&)::'lambda'<typename $T>($T*) const&) ./../../third_party/blink/renderer/core/layout/block_node.cc:118:3 #41 0x560095be1143 in LayoutWithAlgorithm ./../../third_party/blink/renderer/core/layout/block_node.cc:208:3 #42 0x560095be1143 in blink::BlockNode::Layout(blink::ConstraintSpace const&, blink::BlockBreakToken const*, blink::EarlyBreak const*, blink::ColumnSpannerPath const*) const ./../../third_party/blink/renderer/core/layout/block_node.cc:465:21

SUMMARY: AddressSanitizer: heap-buffer-overflow (/home/sunburst/projects/fuzzframe/gen/browser/chromium/asan-linux-release-1294836/chrome+0xea6b57a) (BuildId: 5f8cdd7791bb830a) Shadow bytes around the buggy address: 0x50300008e000: 00 00 00 00 f7 fa fd fd fd fa f7 fa fd fd fd fd 0x50300008e080: f7 fa 00 00 00 fa f7 fa fd fd fd fa f7 fa fd fd 0x50300008e100: fd fa f7 fa fd fd fd fd f7 fa fd fd fd fa f7 fa 0x50300008e180: fd fd fd fa f7 fa fd fd fd fd f7 fa fd fd fd fd 0x50300008e200: f7 fa fd fd fd fa f7 fa 00 00 00 00 f7 fa 00 00 =>0x50300008e280: 00 00 f7 fa fd fd fd fd f7 fa 00 00 00[fa]f7 fa 0x50300008e300: fd fd fd fd f7 fa fd fd fd fd f7 fa fd fd fd fd 0x50300008e380: f7 fa fd fd fd fa f7 fa fd fd fd fd f7 fa fd fd 0x50300008e400: fd fd f7 fa fd fd fd fa f7 fa fd fd fd fa f7 fa 0x50300008e480: fd fd fd fd f7 fa fd fd fd fd f7 fa fd fd fd fa 0x50300008e500: f7 fa fd fd fd fd f7 fa fd fd fd fd f7 fa 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

==1==ADDITIONAL INFO

==1==Note: Please include this section with the ASan report. Task trace: #0 0x56008d229a07 in cc::ProxyImpl::ScheduledActionSendBeginMainFrame(viz::BeginFrameArgs const&) ./../../cc/trees/proxy_impl.cc:731:7 #1 0x5600899be967 in mojo::SimpleWatcher::Context::Notify(unsigned int, MojoHandleSignalsState, unsigned int) ./../../mojo/public/cpp/system/simple_watcher.cc:102:13

==1==END OF ADDITIONAL INFO ==1==ABORTING

Reporter credit:

Huang Xilin of Ant Group Light-Year Security Lab

Additional Data

Category: Security
Chrome Channel: Dev
Regression: N/A

The original report as published on the Chromium issue tracker, by Huang Xilin of Ant Group Light-Year Security Lab. 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. 4 min read.

Context

This report covers a heap buffer overflow in Chrome's Blink layout engine, specifically in the grid layout code path. The affected component is GridNode::ConstructGridItems, which builds the list of grid items for a grid container and assigns each item its resolved position from a placement cache. The bug was reported through the Chrome VRP by Huang Xilin of Ant Group Light-Year Security Lab, rated medium severity, and disclosed on 2024-07-23 with a bounty of 8000.00 USD. The crash type is a tab crash, and the crash state is an AddressSanitizer heap-buffer-overflow.

Setup

The report gives only a minimal setup. The proof of concept is a file named poc.html, served locally on port 8080, and loaded in Chrome. The report lists the Chrome channel as Dev. The report lists regression as N/A. The ASan build path in the crash output is asan-linux-release-1294836, and the crash occurs in the renderer process (chrome thread T0).

Finding it

The researcher points at one line in GridNode::ConstructGridItems. After the placement data is obtained (either from the cache or by running the auto-placement algorithm), the code copies each resolved position into the corresponding grid item:

C++
  // Copy each resolved position to its respective grid item data.
  auto* resolved_position = cached_placement_data->grid_item_positions.begin();
  for (auto& grid_item : grid_items) {
    grid_item.resolved_position = *(resolved_position++);   <----------- [1]
  }
  return grid_items;

The annotation in the report is explicit: the iterator was not checked to see if it had reached the end of the container. The loop is driven by grid_items, but the source of the reads is cached_placement_data->grid_item_positions. If the number of grid items exceeds the number of stored positions, the loop reads past the end of the positions buffer.

Exploitation

Step 1: serve the proof of concept

Text
Serve poc.html on port 8080

The report does not include the contents of poc.html, so the exact HTML and CSS that trigger the mismatch are not shown.

Step 2: load it in Chrome

Text
Launch chrome and then access http://[redacted]:8080/poc.html

Step 3: observe the crash

Loading the page produces an AddressSanitizer heap-buffer-overflow in the renderer. The top of the stack is a READ of size 24 inside __asan_memcpy, called from blink::GridNode::ConstructGridItems at grid_node.cc:118:33, which is the copy loop shown above. The faulting address is described as 0 bytes after 24-byte region, and the allocation stack shows where that 24-byte region came from:

So the positions vector was sized during RunAutoPlacementAlgorithm, and the later copy loop walked past it. The stack shows the read occurring during layout of an atomic inline, with BlockNode::LayoutAtomicInline, LineBreaker::HandleAtomicInline and GridLayoutAlgorithm::ComputeMinMaxSizes further down the stack. with the whole chain rooted in LayoutView::LayoutRoot during a normal style and layout lifecycle update.

Root cause

The placement cache stores a vector of resolved positions (grid_item_positions). The copy loop iterates over grid_items and advances a raw iterator into that vector without a bounds check. The report's own comment in the code notes that even if the cached placement data is incorrect, as long as the grid is not marked dirty the grid item count should be the same, and the code reserves capacity based on cached_placement_data->grid_item_positions.size(). The crash shows that this assumption does not always hold, and the unchecked *(resolved_position++) reads past the end of the allocation. and the unchecked *(resolved_position++) then reads past the end of the allocation. The report does not state which specific style or DOM condition breaks the count invariant.

Impact

The immediate effect is a renderer crash (tab crash) triggered by loading a page. The report does not describe any path to memory disclosure or code execution beyond the out-of-bounds read, and does not state which Chrome versions or configurations are affected beyond the Dev channel observation.

Fix

Based on the root cause, the copy loop needs a bounds check against grid_item_positions.size() (or the two counts need to be kept consistent), so that a mismatch between the cached positions and the current grid items cannot produce an out-of-bounds read.

Variants to test

  1. Grid containers whose item count changes between placement runs, for example by adding or removing children or toggling display on descendants, then forcing a relayout. A positive result is an ASan heap-buffer-overflow in ConstructGridItems at the copy loop.
  2. Grids nested inside subgrids, since the code recurses into subgrids to recompute placement when the cache is invalidated. A positive result is the same crash with BuildGridSizingSubtree in the stack.
  3. Grids used as atomic inlines (for example display: inline-grid inside text), which is the path shown in the crash stack through LayoutAtomicInline and HandleAtomicInline. A positive result is the crash reproduced during min/max size computation.
  4. Items with a non-initial order property, which triggers SortByOrderProperty on the item list before the copy loop. A positive result is a mismatch between sorted item count and cached positions leading to the same out-of-bounds read.

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. 11 min read.

What happened, in plain words

Chrome draws every web page by working out where each box of content goes on the screen. This process is called layout. One of the ways a page can arrange boxes is a grid: a set of rows and columns, like a spreadsheet, into which the page's elements are placed. Chrome's code for grids lives in a part of the browser engine called Blink.

When Chrome lays out a grid, it first decides which cell each element belongs in, and it remembers those decisions in a small store called a placement cache. Later it copies each remembered position onto the matching element. The bug in this report is in that copying step: the code walks through the list of elements and, for each one, reads the next remembered position, but it never checks whether it has run out of remembered positions. If there are more elements than remembered positions, the code reads past the end of the memory that holds the positions. Reading memory you do not own is called a buffer overflow, and because the memory in question sits on the heap (the general-purpose pool of memory a program allocates at runtime), this is a heap buffer overflow.

The practical result described here is a crash of the tab: the page dies, but the rest of the browser is not described as affected. The report was filed through Chrome's Vulnerability Reward Program (VRP), the scheme Google runs to pay people who report security bugs. It was rated medium severity, credited to Huang Xilin of Ant Group Light-Year Security Lab, disclosed on 2024-07-23, and paid a bounty of 8000.00 USD. The report lists the Chrome channel as Dev, the edition of Chrome that receives unfinished changes first. The report lists regression as N/A, meaning it does not say whether an earlier version of Chrome behaved correctly.

A few words you will meet throughout, explained once here:

  • Renderer process: Chrome runs each tab in its own sandboxed program, separate from the rest of the browser. A crash there usually takes down only that tab.
  • AddressSanitizer (ASan): a debugging tool built into special test versions of a program. It watches every memory access and shouts when the program reads or writes outside the memory it was given. The shout is the long report shown later.
  • Proof of concept (PoC): a small file or set of steps that reliably makes the bug happen, so others can confirm it.

Context

This report covers a heap buffer overflow in Chrome's Blink layout engine, specifically in the grid layout code path. The affected component is GridNode::ConstructGridItems, which builds the list of grid items for a grid container and assigns each item its resolved position from a placement cache. The bug was reported through the Chrome VRP by Huang Xilin of Ant Group Light-Year Security Lab, rated medium severity, and disclosed on 2024-07-23 with a bounty of 8000.00 USD. The crash type is a tab crash, and the crash state is an AddressSanitizer heap-buffer-overflow.

To unpack that: a grid container is the element that declares display: grid (or inline-grid); its grid items are its direct children. A resolved position is the row and column a given item ended up in. The placement cache is the browser's memory of those decisions, kept so that a later layout pass does not have to recompute them. The function named here is the piece of code that assembles the item list and stamps each item with its position.

Setup

The report gives only a minimal setup. The proof of concept is a file named poc.html, served locally on port 8080, and loaded in Chrome. The crash was observed on the Dev channel. The report lists regression as N/A. The ASan build path in the crash output is asan-linux-release-1294836, and the crash occurs in the renderer process (chrome thread T0).

Serving a file locally means running a tiny web server on your own machine so that the browser fetches the page over HTTP, exactly as it would from a real website, instead of opening it from disk. Port 8080 is simply the numbered door on which that little server listens. The build path is the folder name of the instrumented Chrome build that produced the crash; the T0 in the output means thread zero, the main thread of the renderer.

Finding it

The researcher points at one line in GridNode::ConstructGridItems. After the placement data is obtained (either from the cache or by running the auto-placement algorithm), the code copies each resolved position into the corresponding grid item:

C++
  // Copy each resolved position to its respective grid item data.
  auto* resolved_position = cached_placement_data->grid_item_positions.begin();
  for (auto& grid_item : grid_items) {
    grid_item.resolved_position = *(resolved_position++);   <----------- [1]
  }
  return grid_items;

Line by line:

  1. The comment says what the block is for: copying each resolved position onto the matching item's data.
  2. resolved_position is set to point at the first entry of the stored list of positions (grid_item_positions). Think of it as a finger placed on the first line of a list.
  3. The for loop walks over every element in grid_items, the freshly built list of items.
  4. For each item, the code reads the entry the finger is on, stores it on the item, and moves the finger one entry forward (resolved_position++). The arrow marked [1] is where the report says the problem is.
  5. Finally the assembled list is returned to the caller.

The annotation in the report is explicit: the iterator was not checked to see if it had reached the end of the container. The loop is driven by grid_items, but the source of the reads is cached_placement_data->grid_item_positions. If the number of grid items exceeds the number of stored positions, the loop reads past the end of the positions buffer.

An iterator is just a cursor into a collection, the finger on the list. The loop's stopping condition comes from one list (the items) while the finger moves through a different list (the positions). Nothing compares the two lengths, so when the items list is longer, the finger keeps moving past the last stored position and into memory that belongs to something else.

Exploitation

Step 1: serve the proof of concept

Text
Serve poc.html on port 8080

This step puts the proof-of-concept page somewhere Chrome can fetch it from. The report does not include the contents of poc.html, so the exact HTML and CSS that trigger the mismatch are not shown.

Step 2: load it in Chrome

Text
Launch chrome and then access http://[redacted]:8080/poc.html

[redacted] is the address a computer uses to talk to itself (often called localhost), so this URL asks the browser to fetch the page from the little server started in step 1. No internet connection or external site is involved.

Step 3: observe the crash

Loading the page produces an AddressSanitizer heap-buffer-overflow in the renderer. The top of the stack is a READ of size 24 inside __asan_memcpy, called from blink::GridNode::ConstructGridItems at grid_node.cc:118:33, which is the copy loop shown above. The faulting address is described as 0 bytes after 24-byte region, and the allocation stack shows where that 24-byte region came from:

What this block says, line by line:

  1. The numbered lines are a call stack, read from the innermost call at the top to the outermost at the bottom. Each line names a function, a source file and a line number.
  2. AllocateVectorBacking<blink::GridArea> is where memory for a list of grid areas was reserved. A vector is a growable list; its backing is the block of memory that actually holds the entries.
  3. AllocateBufferNoBarrier and AllocateBuffer are the lower-level helpers that obtain that block.
  4. ReserveInitialCapacity is the call that asks for room up front, before anything is stored.
  5. PlaceNonAutoGridItems and RunAutoPlacementAlgorithm are the placement routines: the first handles items whose position was given explicitly, the second runs the automatic placement that fills the grid. This is where the positions list was sized.
  6. The last line is the same ConstructGridItems function, at an earlier line, calling into the placement code.

So the positions vector was sized during RunAutoPlacementAlgorithm, and the later copy loop walked past it. The stack shows the read occurring during layout of an atomic inline, with BlockNode::LayoutAtomicInline, LineBreaker::HandleAtomicInline and GridLayoutAlgorithm::ComputeMinMaxSizes further down the stack. with the whole chain rooted in LayoutView::LayoutRoot during a normal style and layout lifecycle update.

An atomic inline is an element that sits inside a line of text but is laid out as a single indivisible box, like an image in a sentence. ComputeMinMaxSizes is the step where the browser asks how narrow and how wide a box is allowed to be before it commits to a final size. LayoutView::LayoutRoot is the entry point for laying out the whole page. In other words, the crash happens during ordinary page drawing, not through any special API or user gesture.

Root cause

The placement cache stores a vector of resolved positions (grid_item_positions). The copy loop iterates over grid_items and advances a raw iterator into that vector without a bounds check. The report's own comment in the code notes that even if the cached placement data is incorrect, as long as the grid is not marked as dirty the grid item count should be the same, and the code reserves capacity based on cached_placement_data->grid_item_positions.size(). The crash shows that this assumption does not always hold, and the unchecked *(resolved_position++) reads past the end of the allocation. and the unchecked *(resolved_position++) then reads past the end of the allocation. The report does not state which specific style or DOM condition breaks the count invariant.

In everyday terms: the code assumes the old shopping list and the new shopping list have the same number of lines, so it reads the old list while walking down the new one. When the new list is longer, it reaches for a line that is not there. A bounds check is simply a test of whether the cursor has reached the end before reading; there is none here.

Impact

The immediate effect is a renderer crash (tab crash) triggered by loading a page.

Memory disclosure would mean the browser handing back bytes it should not, and code execution would mean an attacker getting their own instructions to run. Neither is claimed here; what is claimed is that a page can kill its own tab.

Fix

Based on the root cause, the copy loop needs a bounds check against grid_item_positions.size() (or the two counts need to be kept consistent), so that a mismatch between the cached positions and the current grid items cannot produce an out-of-bounds read.

Variants to test

  1. Grid containers whose item count changes between placement runs, for example by adding or removing children or toggling display on descendants, then forcing a relayout. A positive result is an ASan heap-buffer-overflow in ConstructGridItems at the copy loop.
  2. Grids nested inside subgrids, since the code recurses into subgrids to recompute placement when the cache is invalidated. A positive result is the same crash with BuildGridSizingSubtree in the stack.
  3. Grids used as atomic inlines (for example display: inline-grid inside text), which is the path shown in the crash stack through LayoutAtomicInline and HandleAtomicInline. A positive result is the crash reproduced during min/max size computation.
  4. Items with a non-initial order property, which triggers SortByOrderProperty on the item list before the copy loop. A positive result is a mismatch between sorted item count and cached positions leading to the same out-of-bounds read.

A subgrid is a grid that borrows its rows or columns from a parent grid. The order property is a CSS knob that changes the sequence in which items are considered, without changing the document. Each variant is a different way of making the two counts drift apart, and each is confirmed by the same signature: an ASan report pointing at the copy loop.

Glossary

  • AddressSanitizer (ASan): a tool in special test builds that detects reads and writes outside allocated memory and prints a detailed report.
  • Atomic inline: an element laid out as one indivisible box inside a line of text, such as an inline image.
  • Auto-placement algorithm: the grid routine that decides which cells items occupy when the page does not say explicitly.
  • Blink: the rendering engine inside Chrome that turns HTML and CSS into pixels.
  • Bounds check: a test that a cursor or index has not gone past the end of a collection before it is used.
  • Buffer overflow: reading or writing memory outside the region a program was given.
  • Bounty: the money a vendor pays for a valid security report.
  • Call stack: the list of function calls currently in progress, innermost first, as printed in a crash report.
  • Chrome VRP: Google's Vulnerability Reward Program for Chrome.
  • Dev channel: the Chrome release edition that gets unfinished changes first.
  • DOM: the tree of elements a page is made of.
  • Grid container / grid item: the element declaring a grid layout, and its direct children placed into its cells.
  • Heap: the pool of memory a program allocates at runtime, as opposed to memory fixed at compile time.
  • Iterator: a cursor that walks through a collection one entry at a time.
  • Layout: the browser step that computes the size and position of every box on the page.
  • Placement cache: stored decisions about which grid cell each item occupies, reused on later layout passes.
  • Proof of concept (PoC): a minimal file or set of steps that reliably triggers a bug.
  • Regression: whether an earlier version of the software behaved correctly, used to tell a new bug from an old one.
  • Renderer process: the sandboxed program Chrome runs for a tab.
  • Resolved position: the row and column an item was finally assigned.
  • Severity: the rating of how serious a bug is, here medium.
  • Subgrid: a grid that inherits rows or columns from a parent grid.
  • Tab crash: the renderer for one tab terminating, usually taking only that tab down.
  • Vector: a growable list of values stored in contiguous memory.
  • [redacted]: the address a computer uses to reach itself, also called localhost.

More by Huang Xilin

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.