All projects with patches now have outreach docs. 276 new docs covering CWE-407, CWE-312, CWE-362 across C, C++, Java, Python, Go, Rust, C#, PHP, Ruby, JavaScript, Dart, Erlang, R, and more. Outreach gap: 276 -> 0.
2.3 KiB
FreeCAD — CWE-407 Disclosure Brief (freecad-0004)
2026-04-13 · Patch available — awaiting upstream merge
Finding
One O(C * M^2) defect in FreeCAD's Sketcher equality constraint detection. Patched. Patch ready for upstream review.
The Defects
freecad-0004 (PATCHED — MEDIUM-HIGH): src/Mod/Sketcher/App/SketchAnalysis.cpp:747
// In detectMissingEqualityConstraints() — fires during sketch validation:
auto pos = std::find_if(equallines.begin(), equallines.end(),
Constraint_Equal(id));
if (pos != equallines.end())
equallines.erase(pos);
For each of C existing Equal constraints, std::find_if linearly scans the equallines and equalradius lists. These lists contain O(M^2) entries (all pairs of equal-length/radius geometries). Total: O(C * M^2).
Complexity Proof
At C=100 constraints, M=50 equal-length lines (2,500 pair entries):
- Defective: 100 x 2,500 = 250,000 comparisons
- Fixed: 100 x 1 = 100 lookups (unordered_multimap)
- 2,500x op reduction.
Impact
FreeCAD's Sketcher validates equality constraints during sketch analysis and auto-constraint suggestions. Parametric models with many equal-length lines (regular patterns, mesh approximations) generate large candidate lists, making constraint validation increasingly slow.
The Fix
Index candidates by canonical (GeoId, GeoId) keys in an unordered_multimap:
// Before
std::find_if(equallines.begin(), equallines.end(), Constraint_Equal(id))
// After
auto range = lineMap.equal_range(key);
if (range.first != range.second) lineMap.erase(range.first);
Patch
Fix available: defects/freecad-0004/patch/freecad-0004-sketch-analysis-equality-hashmap.patch
Single-file patch on src/Mod/Sketcher/App/SketchAnalysis.cpp. 2,500x speedup at C=100, M=50.
What We Ask
A patch is ready for review.
- Confirm receipt and assign a GitHub issue reference (FreeCAD/FreeCAD).
- Assess severity — fires during sketch validation; scales with constraint and geometry count.
- Coordinate a disclosure date — we are targeting 90 days from first contact.
- We will credit the FreeCAD team in the public disclosure. Preferred acknowledgment format welcome.
Contact: see cover email. This brief is confidential until coordinated disclosure.