Skip to content

fix: DH-22165: Validate AggSpecFormula through ColumnExpressionValidator.#7933

Open
cpwright wants to merge 10 commits intodeephaven:mainfrom
cpwright:nightly/cpw/DH-22165
Open

fix: DH-22165: Validate AggSpecFormula through ColumnExpressionValidator.#7933
cpwright wants to merge 10 commits intodeephaven:mainfrom
cpwright:nightly/cpw/DH-22165

Conversation

@cpwright
Copy link
Copy Markdown
Contributor

No description provided.

cpwright and others added 2 commits April 23, 2026 19:25
AggregateAllGrpcImpl passed AggSpec directly to aggAllBy without invoking
ColumnExpressionValidator, and AggregateGrpcImpl.validateFormulas did not
inspect AggregationColumns whose inner AggSpec was AggSpecFormula. Both
paths let an arbitrary formula string reach the engine's compiler, enabling
remote code execution (e.g. Runtime.getRuntime().exec(...)) via gRPC.

Add a shared AggSpecFormulaValidator that substitutes the paramToken with
each target column name using the same FormulaUtil.replaceFormulaTokens
helper the engine uses at runtime, then runs the result through
ColumnExpressionValidator.validateColumnExpressions against a grouped
prototype table.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
translateAndValidateFormatViews read from request.getUpdateViewsList()
instead of request.getFormatViewsList(), so format view expressions were
never validated. A client sending malicious format_views with an empty
update_views list would pass the validator (on a zero-length array) and
have the real format expressions compiled and executed by the engine —
the same RCE class as the AggSpecFormula gap.

No regression test is included: there is no existing gRPC test harness
for HierarchicalTableServiceGrpcImpl, and the minimum viable fixture
(rollup/tree source, HierarchicalTable export wiring, apply response
plumbing) is materially more work than the fix itself. The fix is a
single-line swap that reads identically to the adjacent, correctly
implemented translateAndValidateUpdateViews method.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cpwright cpwright requested a review from Copilot April 24, 2026 01:15
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 24, 2026

No docs changes detected for b2f2a55

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds server-side validation for AggSpecFormula aggregations by running the formula through ColumnExpressionValidator (covering both aggregate and aggregateAll paths) and adds regression tests for allowed vs disallowed expressions.

Changes:

  • Validate AggSpecFormula expressions for AggregateRequest (columns aggregation) and AggregateAllRequest before execution.
  • Add tests asserting disallowed expressions are rejected and benign expressions succeed.
  • Fix HierarchicalTableServiceGrpcImpl to validate formatViews using the correct request list.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
server/src/test/java/io/deephaven/server/table/ops/AggregateGrpcTest.java Adds tests for formula spec validation in aggregate column aggregations.
server/src/test/java/io/deephaven/server/table/ops/AggregateAllGrpcTest.java Adds tests for formula spec validation in aggregateAll.
server/src/main/java/io/deephaven/server/table/ops/AggregateGrpcImpl.java Validates AggSpecFormula for AggregationColumns by extracting input columns and invoking validator.
server/src/main/java/io/deephaven/server/table/ops/AggregateAllGrpcImpl.java Injects ColumnExpressionValidator and validates formula specs for aggAllBy.
server/src/main/java/io/deephaven/server/table/ops/AggSpecFormulaValidator.java New shared helper to validate substituted formulas against grouped-table prototypes.
server/src/main/java/io/deephaven/server/hierarchicaltable/HierarchicalTableServiceGrpcImpl.java Uses getFormatViewsList() when translating/validating format views.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/src/main/java/io/deephaven/server/table/ops/AggSpecFormulaValidator.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server/src/main/java/io/deephaven/server/table/ops/SortTableGrpcImpl.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@cpwright cpwright marked this pull request as ready for review April 24, 2026 15:21
@cpwright cpwright requested a review from niloc132 April 24, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants