litert/xnnpack: add rank guards to AveragePool2D, MaxPool2D, Conv2D, DepthwiseConv2D, and TransposeConv2D ToXnnpack() before shape subscripts - #11057
Merged
copybara-service[bot] merged 1 commit intoSep 1, 2026
Conversation
qukhan
approved these changes
Aug 26, 2026
This was referenced Aug 26, 2026
… subscripts AveragePool2D, MaxPool2D, Conv2D, DepthwiseConv2D, and TransposeConv2D all access fixed shape indices (shape[0]..shape[3]) on input, filter, and output tensors without first checking that the shape vector is large enough. A crafted TFLite model with a wrong-rank tensor triggers a null pointer dereference during XNNPACK subgraph compilation at model load time. Add rank size checks before the first shape subscript access in each function, following the pattern already present in TransposeConvOperation::ToXnnpack() (lines 1649-1653).
destro4evr-rgb
force-pushed
the
fix/litert-conv-pool-missing-rank-checks
branch
from
August 31, 2026 16:09
0f72007 to
4013867
Compare
copybara-service Bot
pushed a commit
to google-ai-edge/LiteRT
that referenced
this pull request
Aug 31, 2026
-- 40138679e845958508e9dfcf4710c81948b8ed15 by destro4evr-rgb <destro4evr@proton.me>: litert/xnnpack: add rank guards to Conv/Pool ToXnnpack() before shape subscripts AveragePool2D, MaxPool2D, Conv2D, DepthwiseConv2D, and TransposeConv2D all access fixed shape indices (shape[0]..shape[3]) on input, filter, and output tensors without first checking that the shape vector is large enough. A crafted TFLite model with a wrong-rank tensor triggers a null pointer dereference during XNNPACK subgraph compilation at model load time. Add rank size checks before the first shape subscript access in each function, following the pattern already present in TransposeConvOperation::ToXnnpack() (lines 1649-1653). FUTURE_COPYBARA_INTEGRATE_REVIEW=google/XNNPACK#11057 from destro4evr-rgb:fix/litert-conv-pool-missing-rank-checks 40138679e845958508e9dfcf4710c81948b8ed15 LiteRT-PiperOrigin-RevId: 971399026
copybara-service Bot
pushed a commit
to google-ai-edge/LiteRT
that referenced
this pull request
Aug 31, 2026
-- 40138679e845958508e9dfcf4710c81948b8ed15 by destro4evr-rgb <destro4evr@proton.me>: litert/xnnpack: add rank guards to Conv/Pool ToXnnpack() before shape subscripts AveragePool2D, MaxPool2D, Conv2D, DepthwiseConv2D, and TransposeConv2D all access fixed shape indices (shape[0]..shape[3]) on input, filter, and output tensors without first checking that the shape vector is large enough. A crafted TFLite model with a wrong-rank tensor triggers a null pointer dereference during XNNPACK subgraph compilation at model load time. Add rank size checks before the first shape subscript access in each function, following the pattern already present in TransposeConvOperation::ToXnnpack() (lines 1649-1653). FUTURE_COPYBARA_INTEGRATE_REVIEW=google/XNNPACK#11057 from destro4evr-rgb:fix/litert-conv-pool-missing-rank-checks 40138679e845958508e9dfcf4710c81948b8ed15 LiteRT-PiperOrigin-RevId: 971399026
copybara-service Bot
pushed a commit
that referenced
this pull request
Sep 1, 2026
-- 4013867 by destro4evr-rgb <destro4evr@proton.me>: litert/xnnpack: add rank guards to Conv/Pool ToXnnpack() before shape subscripts AveragePool2D, MaxPool2D, Conv2D, DepthwiseConv2D, and TransposeConv2D all access fixed shape indices (shape[0]..shape[3]) on input, filter, and output tensors without first checking that the shape vector is large enough. A crafted TFLite model with a wrong-rank tensor triggers a null pointer dereference during XNNPACK subgraph compilation at model load time. Add rank size checks before the first shape subscript access in each function, following the pattern already present in TransposeConvOperation::ToXnnpack() (lines 1649-1653). FUTURE_COPYBARA_INTEGRATE_REVIEW=#11057 from destro4evr-rgb:fix/litert-conv-pool-missing-rank-checks 4013867 PiperOrigin-RevId: 971399026
copybara-service Bot
pushed a commit
to google-ai-edge/LiteRT
that referenced
this pull request
Sep 1, 2026
-- 40138679e845958508e9dfcf4710c81948b8ed15 by destro4evr-rgb <destro4evr@proton.me>: litert/xnnpack: add rank guards to Conv/Pool ToXnnpack() before shape subscripts AveragePool2D, MaxPool2D, Conv2D, DepthwiseConv2D, and TransposeConv2D all access fixed shape indices (shape[0]..shape[3]) on input, filter, and output tensors without first checking that the shape vector is large enough. A crafted TFLite model with a wrong-rank tensor triggers a null pointer dereference during XNNPACK subgraph compilation at model load time. Add rank size checks before the first shape subscript access in each function, following the pattern already present in TransposeConvOperation::ToXnnpack() (lines 1649-1653). Reverts 71dd844 FUTURE_COPYBARA_INTEGRATE_REVIEW=google/XNNPACK#11057 from destro4evr-rgb:fix/litert-conv-pool-missing-rank-checks 40138679e845958508e9dfcf4710c81948b8ed15 LiteRT-PiperOrigin-RevId: 971399026
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.
Five
ToXnnpack()implementations access fixed shape indices (shape[1],shape[2],shape[3]) on input, filter, and output tensor shape vectors without first validating that the vector has enough elements. A crafted TFLite model that declares a wrong-rank tensor for any of these operations triggers a null pointer dereference during XNNPACK subgraph compilation at model load time, before any inference runs.TransposeConvOperation::ToXnnpack()(lines 1649–1653) performs the same shape subscripts and already includes the explicit rank guard that the five affected functions are missing:Fix: add equivalent rank size checks before the first shape subscript in each affected function —
size() < 3for AveragePool2D and MaxPool2D (which only need indices 1 and 2),size() != 4for Conv2D and DepthwiseConv2D (input + filter), andsize() != 4for all three tensors in TransposeConv2D.