CVE-2026-58988 AI-generated analysis
platform/packages/modules/NeuralNetworks, shim_and_sl (NNAPI shim/support-library converter); platform/hardware/interfaces, neuralnetworks AIDL VTS (tests only)
Adds explicit bounds checks in isValid() of the NNAPI shim converter (shim_and_sl/ShimConverter.cpp), so that operation input/output operand indexes and subgraph input/output indexes that are >= the operand count are rejected instead of being used to index vectors. It also adds new VTS tests that require AIDL NeuralNetworks devices to reject models with out-of-bounds model input/output indexes.
Root cause
In shim_and_sl/ShimConverter.cpp, isValid(const Subgraph&) builds a std::vector<bool> operandValueKnown sized to subgraph.operands.size(). It then indexes that vector with k = operation.inputs[j] and k = operation.outputs[j] from the model, without checking that k < operandValueKnown.size(). Likewise, the input/output lifetime loop indexes subgraph.operands[index] with each value of subgraph.inputIndexes and subgraph.outputIndexes, without checking that index < subgraph.operands.size(). A model carrying an operand index equal to or larger than the operand count therefore caused out-of-bounds vector reads during validation.
How the fix works
- packages/modules/NeuralNetworks ea11759c1785, shim_and_sl/ShimConverter.cpp:isValid(const Subgraph&): in the operation loop, before reading operandValueKnown[k] for each operation input, adds 'if (k >= operandValueKnown.size())', which logs 'Operation i input j operand index out of bounds' and returns false.
- Same function, operation outputs loop: adds the identical 'k >= operandValueKnown.size()' check before 'if (operandValueKnown[k])'; it logs and returns false.
- Same function, 'Validate input and output lifetime' section: for each index in subgraph.inputIndexes, adds 'if (index >= subgraph.operands.size())', which returns false before subgraph.operands[index].lifetime is read. The same check is added for subgraph.outputIndexes.
- hardware/interfaces 0922a9731594, neuralnetworks/aidl/vts/functional/ValidateModel.cpp: adds mutateModelInputOperandIndexTest and mutateModelOutputOperandIndexTest. They set each model.main.inputIndexes[input] / model.main.outputIndexes[output] to model.main.operands.size() and call validate(), expecting rejection. Both tests are registered in validateModel(). This commit contains no production code.
Completeness
- Covers all four index uses inside isValid(): operation inputs, operation outputs, subgraph inputIndexes and subgraph outputIndexes. Each is checked against the operand vector size before use.
- For operation inputs/outputs, k is uint32_t, so the check is an unsigned comparison. The element type of inputIndexes/outputIndexes is not shown.
- The fix only hardens isValid(). The material does not show whether other conversion code in ShimConverter.cpp dereferences operand indexes before isValid() runs, or whether referenced (non-main) subgraphs are passed through isValid().
- The new VTS tests only mutate model.main.inputIndexes and model.main.outputIndexes. They do not add tests for out-of-bounds operation input/output indexes; mutateOperationInputOperandIndexTest and mutateOperationOutputOperandIndexTest already exist in the file per the diff context.
Behavior changes
- isValid() now returns false with a LOG(ERROR) message ('operand index out of bounds', 'Input index out of bounds' or 'Output index out of bounds') for models with an operand index >= operands.size(). Such models are rejected rather than validated through an out-of-bounds read.
- VtsHalNeuralnetworksTargetTest gains new cases (mutateModelInputOperandIndexTest, mutateModelOutputOperandIndexTest). AIDL NN drivers that accept such models will now fail VTS.
Per major
- Android 14: Resolved by bug_id at android-security-14.0.0_r31 with hardware/interfaces 86465ac0d6a5 (the same VTS test commit, identical diff). The material does not show the NeuralNetworks ShimConverter.cpp fix for this branch.
- Android 15: Same fix: hardware/interfaces 0922a9731594 (VTS tests) plus packages/modules/NeuralNetworks ea11759c1785 (ShimConverter.cpp bounds checks) at android-security-15.0.0_r19. 8/8 lines of the patched region are present.
- Android 16: Resolved by bug_id at android-security-16.0.0_r10 with hardware/interfaces fd82052d2c13 (identical VTS test diff). The material does not show the NeuralNetworks ShimConverter.cpp fix for this branch.
- Android 17: Resolved by bug_id at android-security-17.0.0_r3 with hardware/interfaces b02791acf0b9 (identical VTS test diff). The material does not show the NeuralNetworks ShimConverter.cpp fix for this branch.
Unknowns
- Whether the packages/modules/NeuralNetworks ShimConverter.cpp fix was applied to the Android 14, 16 and 17 security tags or ships only through a module release. For those branches the material only shows the VTS test commit.
- Which callers invoke isValid(), and whether any code converts or dereferences operand indexes before isValid() runs.
- Whether validateOperations() (referenced in a code comment) does any index bounds checking of its own.
- The element type of subgraph.inputIndexes/outputIndexes in the shim Subgraph type, and how negative values are handled.