Skip to content

[SECURITY] Bind request encodings in analytics cache freshness queries #822

Closed

Description

@jeffreyaven

Constituent of #769. Reviewed current main at 1de4135 on 2026-10-08; this issue proposes work, no implementation is included.

CWEs: CWE-89.

Finding and evidence

Both backend implementations interpolate requestEncoding into a single-quoted SQL literal: internal/stackql/sql_system/sqlite.go and internal/stackql/sql_system/postgres.go. any-sdk's HTTP parameter encoding concatenates raw values rather than making them SQL-safe (internal/anysdk/http.go).

A current-code test called SQLite TableOldestUpdateUTC against a disposable cache-shaped table. An ordinary missing request returned no counters; missing' OR 1=1 -- returned counters for a different request. This confirms a query boundary failure without needing raw native SQL. PostgreSQL's matching interpolation was source-reviewed, not runtime-tested here.

Required outcome

  • Bind requestEncoding using the existing backend parameter conventions, as IsTablePresent and QueryNamespaced already do.
  • Quote table/control identifiers using the shared safe identifier mechanism.
  • Preserve cache matching semantics and error visibility; syntax errors must not silently disguise a security-relevant cache mismatch.

Validation and acceptance

Add unit coverage for both dialects and black-box cached-provider queries using apostrophes, comment-like strings and backslashes in request parameters. Distinct encodings must never reuse another request's counters/results; repeated identical encodings should still hit cache.

Scope and related work

This is a cache freshness lookup, not the residual WHERE expression rendering issue. Both are CWE-89 but have different call sites and regression tests.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions