Skip to content

fix: escape iterator pk/id values and remove sparse vector stdout dump - #622

Merged
sre-ci-robot merged 1 commit into
milvus-io:2.6from
yhmo:2.6
Oct 23, 2026
Merged

sre-ci-robot merged 1 commit into
milvus-io:2.6from
yhmo:2.6

Conversation

@yhmo

@yhmo yhmo commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two security fixes for the 2.6 line:

  1. Escape VARCHAR PK/ID values in iterator filter expressions (expression injection)

    QueryIteratorImpl::setupNextFilter and SearchIteratorImpl::filteredDuplicatedResultFilter interpolated VARCHAR primary-key / ID values into filter-expression string literals without escaping. Since Milvus VARCHAR PKs accept arbitrary UTF-8 (including quotes and backslashes) and the server's expression grammar terminates a string literal on an unescaped quote, a crafted PK value could break out of the literal and inject expression clauses (e.g. or 1==1) that are evaluated under the requesting user's identity — bypassing client-side filters and enabling cross-scope data reads.

    Fix: add EscapeExprStringValue (escapes \\, ", ', CR, LF, TAB per the Milvus expression grammar) and apply it before interpolation. Benign values are byte-identical, so paging semantics are unchanged. The server parser unescapes these sequences back to the raw value (convertEscapeSingle + strconv.Unquote), so comparisons stay correct.

  2. Stop printing raw sparse-vector JSON to stdout on parse failure (DmlUtils::ParseSparseFloatVector).

Tests

  • DqlUtilsTest.EscapeExprStringValueTest — escaping unit coverage.
  • MilvusMockedTest.QueryIteratorEscapesVarcharPkInPagingExpression — mocked test proving an injected PK produces the fully-escaped expression on subsequent pages.
  • Existing iterator tests (QueryIterator, SearchIteratorV1/V2, etc.) pass unchanged; full testing-ut passes (694/694).

Signed-off-by: yhmo yihua.mo@zilliz.com

@sre-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: yhmo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mergify

mergify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

Comment thread src/impl/types/SearchIteratorImpl.cpp
Comment thread src/impl/types/QueryIteratorImpl.cpp
Comment thread test/it/v1/TestQueryIterator.cpp Outdated
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (2.6@f16d654). Learn more about missing BASE report.

Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff           @@
##             2.6     #622   +/-   ##
======================================
  Coverage       ?   86.77%           
======================================
  Files          ?      321           
  Lines          ?    12694           
  Branches       ?     1315           
======================================
  Hits           ?    11015           
  Misses         ?     1679           
  Partials       ?        0           
Files with missing lines Coverage Δ
src/impl/types/QueryIteratorImpl.cpp 89.79% <100.00%> (ø)
src/impl/types/SearchIteratorImpl.cpp 81.04% <100.00%> (ø)
src/impl/utils/DmlUtils.cpp 87.15% <ø> (ø)
src/impl/utils/DqlUtils.h 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The query and search iterators interpolated VARCHAR primary-key and ID
values into filter-expression string literals without escaping. A crafted
value containing quotes or backslashes could break out of the literal and
inject expression clauses that the server evaluates under the requesting
user identity, bypassing client-side filters and enabling cross-scope data
reads. Escape backslash, single/double quote, CR, LF and TAB per the Milvus
expression grammar before interpolation, keeping benign values unchanged.

Also stop printing raw sparse-vector JSON to stdout when parsing fails.

Signed-off-by: yhmo <yihua.mo@zilliz.com>
@sre-ci-robot

Copy link
Copy Markdown

New changes are detected. LGTM label has been removed.

@yhmo yhmo added the lgtm label Oct 23, 2026
@mergify mergify Bot added the ci-passed label Oct 23, 2026
@sre-ci-robot
sre-ci-robot merged commit 5ae46d8 into milvus-io:2.6 Oct 23, 2026
12 checks passed
@yhmo
yhmo deleted the 2.6 branch October 26, 2026 02:33
@yhmo yhmo mentioned this pull request Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants