[ 
https://issues.apache.org/jira/browse/TINKERPOP-3281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146376#comment-18146376
 ] 

ASF GitHub Bot commented on TINKERPOP-3281:
-------------------------------------------

kenhuuu commented on code in PR #3703:
URL: https://github.com/apache/tinkerpop/pull/3703#discussion_r4604179186


##########
gremlin-util/src/test/java/org/apache/tinkerpop/gremlin/util/ser/binary/types/PSerializerTest.java:
##########
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.util.ser.binary.types;
+
+import io.netty.buffer.ByteBufAllocator;
+import org.apache.tinkerpop.gremlin.process.traversal.P;
+import org.apache.tinkerpop.gremlin.structure.io.Buffer;
+import org.apache.tinkerpop.gremlin.structure.io.binary.DataType;
+import org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader;
+import org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter;
+import org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry;
+import org.apache.tinkerpop.gremlin.structure.io.binary.types.PSerializer;
+import org.apache.tinkerpop.gremlin.util.ser.NettyBufferFactory;
+import org.junit.Test;
+
+import java.io.IOException;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+/**
+ * {@code PSerializer} is not currently wired into {@link 
TypeSerializerRegistry}'s default entries on master, so

Review Comment:
   This actually reveals a cleanup issue. `PSerializer` should probably have 
been deleted as its no longer part of GraphBinary4. This means 
`maxGraphBinaryArrayLength` and `readFixedArrayCount` would be unused.
   
   So remove `maxGraphBinaryArrayLength` and `readFixedArrayCount` and then 
make a follow-up Jira to cleanup `PSerializer`.





> GraphBinary deserializer unbounded pre-allocation from length prefixes
> ----------------------------------------------------------------------
>
>                 Key: TINKERPOP-3281
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP-3281
>             Project: TinkerPop
>          Issue Type: Bug
>          Components: io
>    Affects Versions: 4.0.0, 3.7.7, 3.8.2
>            Reporter: Guian Gumpac
>            Priority: Major
>             Fix For: 3.7.7, 3.8.2
>
>
> GraphBinary value types size a heap allocation (or bound a read loop) from a 
> 4-byte length/count prefix before the payload is read or checked against the 
> bytes actually remaining. Because GraphBinary is deserialized 
> pre-authentication on the default wire path, a tiny malformed frame (~6-21 
> bytes) can declare a multi-hundred-megabyte to multi-gigabyte allocation and 
> drive Gremlin Server to OutOfMemoryError. maxContentLength bounds the frame, 
> not a single declared length, and the binary decoder catches only 
> SerializationException, so the OOM escapes. The surface is symmetric: a 
> malicious or on-path server can OOM a connecting driver the same way. The 
> same shape recurs across String, Collection (list/set), Map, BigInteger, 
> InetAddress, ByteBuffer, Bytecode, P, Tree, graph and BulkSet.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to