fix: add parameter validation to GobDecode for all DP aggregation types#412
Open
AndyBurecovics wants to merge 1 commit intogoogle:mainfrom
Open
fix: add parameter validation to GobDecode for all DP aggregation types#412AndyBurecovics wants to merge 1 commit intogoogle:mainfrom
AndyBurecovics wants to merge 1 commit intogoogle:mainfrom
Conversation
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every aggregation type in
go/dpagg(Count, BoundedSumInt64, BoundedSumFloat64, BoundedQuantiles, PreAggSelectPartition) implements GobDecode without validating deserialized parameters. The constructors run 20+ checks fromchecks/checks.gobefore accepting parameters. GobDecode runs zero of them.This opens three specific issues:
Nil Noise dereference:
noise.ToNoise()returns nil for any NoiseKind other than 0 or 1. GobDecode feeds the deserialized NoiseKind straight into ToNoise without checking the return. An invalid NoiseKind causes a nil pointer panic whenResult()is called.Division by zero: BoundedQuantiles accepts
branchingFactor=0from the payload.getParent()does(index - 1) / bq.branchingFactor, which panics on integer division by zero.Invalid sensitivity parameters: GobDecode restores
lInfSensitivityand bounds as independent fields without verifying consistency or basic validity (e.g. positive, finite).Composite types (BoundedMean, BoundedVariance, BoundedStandardDeviation) are protected transitively because Gob calls GobDecode on their embedded Count and BoundedSumFloat64 fields during deserialization.
Fix
noise.ToNoise(noiseKind)returns non-nil before assignment.l0SensitivityandlInfSensitivityusing existing check functions.branchingFactor >= 2andtreeHeightin BoundedQuantiles.Related: https://issuetracker.google.com/issues/501920784