Skip to content

MCP query_metrics accepts embedded NUL prefixes in time_group #24371

Open

Description

@ktsaou

The MCP query_metrics handler reads time_group through json_object_get_string() and compares/parses the resulting C string. An embedded NUL therefore hides the suffix: "time_group": "max\u0000junk" reaches the same grouping selection as "max" when the other query arguments are valid.

Source trace checked against netdata/netdata @ b97c83c and PR #23281 head 6e5d82d:

  • src/web/mcp/mcp-tools-query-metrics.c: JSON string extraction and C-string comparisons in the grouping-validation block; grouping conversion later passes that same string to time_grouping_parse() (current lines 396-409 and 543-544).
  • The behavior already exists on master. PR api: fleet time-aggregations - percentage-of-time, number-of-flaps, number-of-times #23281 validates complete condition/numeric option strings, but does not introduce identifier truncation.

Reproduction input: use any valid existing query_metrics request with time_group set to "max\u0000junk"; the encoded JSON string is longer than the method name accepted by the C-string parser. This report is based on the source trace, not a captured live-server response.

Expected: validate the complete JSON method identifier and return a structured parameter error for an embedded NUL. Add regression coverage for NUL before, inside and after a valid name, with an ordinary valid-name control. Check other enum parameters separately before expanding the scope.

Discovered while reviewing #23281 (review comment 4307885353). This is independent of that PR's expression/options contract and is not a merge dependency.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions