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

Toby Thain commented on THRIFT-1205:
------------------------------------

@Bryan - yes, I inferred that from the nature of the crash.

I agree that (apart from a default limit, which should be a decent workaround), 
solving this is tricky. I haven't looked at the code yet, but it might be 
possible to guard against this by simply not allocating the entire buffer 
immediately, but rather a smaller interim buffer, and waiting to see if a valid 
message is forthcoming. This would work best if the rest of the unmarshalling 
code had thorough validity checks. This should avoid the attempt to allocate a 
meaninglessly large buffer in the case that the message can be rejected on 
other grounds. Of course, an attacker who's willing to craft a valid, extremely 
large Thrift message can still eat up server resources :)

I can look at this approach if you think it has merit.

> port server unduly fragile with arbitrary input
> -----------------------------------------------
>
>                 Key: THRIFT-1205
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1205
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Library
>    Affects Versions: 0.6.1
>         Environment: javac 1.5.0_19, OS X 10.4.11
>            Reporter: Toby Thain
>            Priority: Critical
>              Labels: security
>
> Telnetting to the port and type a couple of arbitrary characters crashes the 
> server almost immediately as follows. I haven't glanced at the relevant code. 
> Is this reproducible on other platforms?
> {noformat}
> $ ./run-server.sh 
> Starting the simple server...
> Exception in thread "Thread-0" java.lang.OutOfMemoryError: Java heap space
>         at 
> org.apache.thrift.protocol.TBinaryProtocol.readStringBody(TBinaryProtocol.java:353)
>         at 
> org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:215)
>         at SimonSays$Processor.process(Unknown Source)
>         at org.apache.thrift.server.TSimpleServer.serve(TSimpleServer.java:70)
>         at JavaServer.simple(Unknown Source)
>         at JavaServer$1.run(Unknown Source)
>         at java.lang.Thread.run(Thread.java:613)
> {noformat}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to