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

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

GumpacG opened a new pull request, #3610:
URL: https://github.com/apache/tinkerpop/pull/3610

   GraphBinary sized heap allocations from an unvalidated 4-byte length prefix 
before reading the payload, so a tiny
   pre-auth frame (~6-21 bytes) could demand gigabytes and OOM Gremlin Server 
or a connecting driver.
   
   ## What changed
   
   - Validate each length/count against the bytes actually remaining before it 
sizes an allocation or bounds a loop;
     reject negative or oversized with `IOException`.
   - Cap eager pre-sizing of growable collections/maps (grow on demand instead).
   - Reject truncated length prefixes and negative `BulkSet` bulk values.
   - Covers `String`, `ByteBuffer`, `BigInteger`, `InetAddress`, list, set, 
map, `Tree`, `BulkSet`, `Bytecode`, `P`
     and graph. Well-formed messages are unaffected.
   
   ## Testing
   
   `GraphBinaryLengthPrefixTest` (rejection + large round-trip cases); full 
GraphBinary compatibility suite green.
   
    <br>
   See: https://issues.apache.org/jira/browse/TINKERPOP-3281
   
   Assisted-by: Kiro: Claude Opus 4.8




> 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
>
> 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
(v8.20.10#820010)

Reply via email to