Fix heap buffer overflow in Table_map_log_event via unbounded m_colcnt #5846
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.32) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.32 · 121 lines diff across 1 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.287
Real PR Conversation Timeline
1 comments
"Review active on #5846"
general
weight: 0.35
gkodinov
Summary
Table_map_log_event::Table_map_log_eventdoes not boundm_colcnt(a 64-bit attacker-controlled value). The fix for MDEV-40644 boundedm_dblen/m_tbllenbut left this field; the range checks from MDEV-39689 are bypassable via 64-bit wrap-around.Details
my_multi_malloc(..., (uint) m_colcnt, ...)truncates to 32 bits for the allocation, whilememcpy(m_coltype, src, m_colcnt)uses the full 64-bit value. Withm_colcnt = 2^64 - k, the guardptr_after_colcnt + m_colcnt > buf + event_lenwraps around, bypassing the check. Result: heap buffer overflow → crash of the slave SQL/IO thread.The fix rejects
m_colcnt > event_lenbefore allocating (same pattern as MDEV-40644), sois_valid()returns false and the event is refused gracefully.Testing
Arithmetic replica under ASan confirms the overflow without the fix and clean rejection with it.
---
AI tool use disclosure: AI was used in part for code audit and patch drafting.