Skip to content

Commit 5ecec9c

Browse files
Prevent use after free.
A very old version of the code used `result` as a simple pointer to a resource. Two years later, the pointer got changed to a `unique_ptr` but author forgot to remove the call to `Unref`. Three years after that, we finally uncover the UAF. PiperOrigin-RevId: 387924872 Change-Id: I70fb6f199164de49fac20c168132a07b84903f9b
1 parent d8a39f2 commit 5ecec9c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tensorflow/core/kernels/boosted_trees/resource_ops.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class BoostedTreesCreateEnsembleOp : public OpKernel {
5353
if (!result->InitFromSerialized(
5454
tree_ensemble_serialized_t->scalar<tstring>()(), stamp_token)) {
5555
result->Unref();
56+
result.release(); // Needed due to the `->Unref` above, to prevent UAF
5657
OP_REQUIRES(
5758
context, false,
5859
errors::InvalidArgument("Unable to parse tree ensemble proto."));

0 commit comments

Comments
 (0)