Prevent SQL injection in message metadata column search #361
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.39) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.39 · 247 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 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
Diff Size
diff_size
0.330
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #361"
general
weight: 0.35
gibson9583
Problem
Custom metadata column names in message search are interpolated into SQL as identifiers (MyBatis
${}) across all database dialects —${element.columnName}(metaDataSearch) and${column}(textSearchMetaDataColumns) — and arrive from the REST parameters with no validation, so an authenticatedMESSAGES_VIEWuser can inject arbitrary SQL. The search value (#{...}) and operator (enum-constrained) were already safe; only the column name is affected. Ref GHSA-mf46-33w3-84j6.Fix
Validate every referenced metadata column name against the channel's own defined columns before the filter reaches the data layer:
MetaDataColumnValidator(new,server/util): pure check, lazy channel-column lookup, returns the first unknown column name (or null).MessageServlet: primary gate at the REST boundary; an unknown column returns400. Applied to all message-search entry points, in both the parameter andMessageFilter-body forms (getMessages,getMessageCount,reprocessMessages,removeMessages,exportMessagesServer).DonkeyMessageController: defense-in-depth backstop for callers that reach the controller directly (e.g. plugins viaMessageController.getInstance()), throwing on an unknown column.Column names are matched exactly against the channel's (upper-cased) defined columns. No SQL/mapper changes; the value and operator are untouched.
Tests
MetaDataColumnValidatorTest— unit tests the check: unknown/known/non-uppercase/null column, and that the channel lookup is skipped when the filter references no custom column.MessageServletTest— REST-boundary reject/allow paths.:serverbuild green (unit tests included).Verifying
Verified against a running server (Derby) with a channel that has a custom metadata column:
metaDataSearch=<definedColumn> = foo→200(search runs normally).metaDataSearch=<undefinedColumn> = foo→400(rejected before reaching SQL).