java-topology/whitepaper/outreach/bullet.md

3.1 KiB
Raw Blame History

Bullet Physics — CWE-407 Disclosure Brief

2026-03-27 · Patch available — awaiting upstream merge

Finding

Three O(n²) defects in Bullet Physics's broadphase collision detection. All use findLinearSearch — a linear scan — in per-frame hot paths: ghost object pair tracking, collision override checking, and sorted pair cache removal. Measured up to 5,000× overhead. Patches ready for upstream review.

The Defects

bullet-0001 (PATCHED — HIGH): btGhostObject.cpp:37,49

// Inside btGhostObject::addOverlappingObjectInternal():
int index = m_overlappingObjects.findLinearSearch(otherObject);
// O(P) scan per broadphase pair per physics step

findLinearSearch performs a linear scan over P overlapping objects on every broadphase pair check per physics step. O(P²) per step. Measured ratio: 500×.

bullet-0002 (PATCHED — HIGH): btCollisionObject.h:268

// Inside checkCollideWithOverride():
int index = m_objectsWithoutCollisionResponse.findLinearSearch(co);
// O(M) per pair per step

Linear scan over M no-response objects per collision pair check. O(M × E) per step. Measured ratio: 50×.

bullet-0003 (PATCHED — HIGH): btOverlappingPairCache.h

// Inside btSortedOverlappingPairCache::removeOverlappingPair():
int findIndex = m_overlappingPairArray.findLinearSearch(pair);
// O(P) per removal; O(P²) bulk teardown

O(P) linear scan per pair removal. During bulk scene teardown: O(P²) total. Measured ratio: 5,000×.

Complexity Proof

bullet-0001: For P=500 overlapping objects per ghost object per step at 60Hz:

  • 500 comparisons per pair per frame
  • Fixed: btHashMap for O(1) lookup
  • 500× measured ratio.

bullet-0002: For M=50 no-response objects:

  • O(M×E) per step — 50× measured ratio.

bullet-0003: For P=5000 pairs, bulk teardown:

  • O(P²) = 12.5M comparisons
  • Fixed: btHashMap
  • 5,000× measured ratio.

Impact

All Bullet Physics applications using ghost objects (triggers, sensors, area detection), collision filtering, or large scenes with many physics objects. Bullet is used in AAA games, robotics simulation (ROS), and scientific simulation. Physics engines run at 60-120Hz, making per-frame overhead critical. Games with many physics bodies hitting bullet-0003 on level unload freeze for noticeable durations.

The Fix

Replace findLinearSearch with btHashMap equivalents:

// Before
int index = m_overlappingObjects.findLinearSearch(otherObject);

// After
// CWE-407 fix: btHashMap for O(1) lookup instead of O(P) findLinearSearch scan.
btCollisionObject** found = m_overlappingObjectsMap.find(otherObject);

Patch

defects/bullet/patch/bullet-0001-0002-0003-hashmap-pairs.patch

What We Ask

  1. Confirm receipt and assign a GitHub Security Advisory or issue reference.
  2. Validate the patch against your broadphase and collision test suites.
  3. Assess CVE eligibility — bullet-0003 measured at 5,000× on bulk scene teardown.
  4. Coordinate a disclosure date — we are targeting 90 days from first contact.

Contact: see cover email. This brief is confidential until coordinated disclosure.