zeekayandHanzo Dev cc111f0630 security: quote the field name, which is caller text, wherever it becomes SQL
A telemetry field key name arrives as JSON on /api/v5/query_range and is
replayed out of stored dashboards and alert rules. It lands in two syntactic
positions and a bound parameter can occupy NEITHER:

  - a backtick-quoted IDENTIFIER — the SELECT alias, the GROUP BY term, the
    ORDER BY term;
  - a single-quoted LITERAL — the accessors that read one attribute out of a
    column, JSONExtractString(labels, '<name>') and friends.

Nothing quoted it. The rendering was written inline about forty times, always
as "`"+name+"`" or '%s', and the one call that sat next to a name —
sqlbuilder.Escape — replaces "$" with "$$" for the builder's own placeholder
syntax and is not SQL escaping. Measured against the real builder, a group-by
name of

  le`,(select/**/grouparray(name)/**/from/**/system.tables)/**/as/**/`x

emitted that subquery as an ADDITIONAL SELECT COLUMN, whose rows come back in
the response body; "/**/" stands in for the spaces the builder strips and the
payload is all-lowercase so nothing folds it. A name carrying "'" breaks the
labels accessor the same way, and one ending in "\" eats whichever delimiter
closes it.

The request validator is not where this can be fixed. The rule evaluator builds
a QueryRangeRequest and calls the querier directly, so a stored rule's name
never meets it; and validateOrderBy, which does gate the DIRECTION strictly to
asc|desc, gates the sibling key NAME against an allowlist it builds out of the
caller's own GroupBy — so a name repeated in both fields validates itself.
Metrics settles it: a metric label is free-form, an unrecognised name falls back
to the labels column BY DESIGN, and there is no key allowlist to fail against.

So the guard goes where the name becomes text. QuoteIdent and EscapeLiteral are
the one renderer, in querybuilder, which every signal package already imports;
the ~40 inline spellings now call them. Both escape the backslash BEFORE the
delimiter, or a trailing backslash would consume the delimiter being added. A
name with none of those characters — every real attribute key, which is a dotted
identifier — renders byte for byte as it did, which is why the golden-SQL suites
in all six signal packages are unchanged.

The test asserts on emitted SQL and structurally rather than textually: the
payload MAY appear, quoted, as the inert name of a label nobody has, but it must
never appear in the executable skeleton — the text left once every quoted region
is removed. That is the property an injection breaks, so it fails if any layer
underneath stops escaping.

Co-authored-by: Hanzo Dev <[email protected]>
2026-08-02 21:34:46 -07:00
2021-01-24 13:09:49 +05:30
2026-04-23 19:24:27 -07:00
2021-01-03 18:15:44 +05:30
2026-04-23 19:24:27 -07:00
2026-08-01 20:24:32 -07:00
2026-08-01 20:24:32 -07:00

o11y

o11y

Metrics, traces and logs for the Hanzo platform, in one place. OpenTelemetry on the wire, Hanzo Datastore — an OLAP column store — on disk.

License

Run it

cd deploy/docker
docker compose up -d

Open http://localhost:8080. deploy/install.sh does the same thing with a few more checks, and deploy/docker/docker-compose.ha.yaml is the multi-replica variant.

Send it data

The collector listens for OTLP on 4317 (gRPC) and 4318 (HTTP). Point any OpenTelemetry SDK or the OTel Collector at it:

export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318

Traces, metrics and logs land in Datastore and show up under APM, Logs, Traces, Metrics and Exceptions in the UI. Dashboards and alerting are built on the same queries.

What it is for

Every Hanzo service emits here. It is multi-tenant by design: queries scope by org from the X-Org-Id claim in the JWT, on every panel. It sits behind gateway like the other Hanzo subsystems, and mounts under the unified cloud binary per HIP-0106.

   instrumented app  ->  OTLP  ->  o11y collector
                                       |
                                 Hanzo Datastore
                                       |
                             APM | logs | traces | metrics
                                       |
                          queries scoped by X-Org-Id from JWT
                                       |
                          dashboards | alerting | exceptions

Docs

Lineage

Forked from SigNoz (MIT Expat, copyright 2020–present SigNoz Inc.), synced to upstream main at commit 3e6339019. The import history was squashed, so the root commit here is a Hanzo branding commit rather than upstream's history. See NOTICE.

License

MIT — see LICENSE.

S
Description
Hanzo o11y — OpenTelemetry-native observability (metrics, traces, logs) for the Hanzo platform, backed by Hanzo Datastore.
Readme MIT
128 MiB
Languages
TypeScript 49.3%
Go 42.3%
SCSS 4%
Python 3.4%
JavaScript 0.6%
Other 0.2%