-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unikernels crash on receipt of malformed TCP options #56
Comments
This is a really interesting bug. A quick code review in
We don't respect the length of the MSS field here, and so assume that we can read a length of 2 bytes from the Cstruct. Ordinarily, this should result in a bounds check failure since the Cstruct view has a smaller size. So why didn't we get a bounds check failure in this case? The This is a relatively benign bug (without type safety, it could easily be possible to corrupt memory allocator data structures, but is "just" a denial of service as-is), but it's extremely bad practise to read memory locations that we should not have access to. Things it would be good to verify and/or fix in the code:
The actual packet used in this report isn't a valid TCP packet, so I'm not too worried about just rejecting it. Ideally without a crash :-) |
+1*several billion concur this is an excellent case for a unit/regression test in |
On 07/02/2014 07:56 AM, Anil Madhavapeddy wrote:
I have a fix for the length checking in Options.ml - in implementing I'm checking now to see whether this behavior occurs with a 4.00.1 compiler.
-Mindy |
A unikernel compiled in a 4.00.1 environment (via
|
@avsm our use of cstruct is encapsulated in try .. with (which then produces a monadic fail -- thus we don't do length checks in code, but we catch the exceptions https://github.com/mirleft/ocaml-tls/blob/master/lib/reader.mli and https://github.com/mirleft/ocaml-tls/blob/master/lib/reader.ml#L21 ) |
The bug is due to the Cstruct.BE and LE modules not checking that the length of their view has been exceeded. There's a bound check error if the overall buffer is violated. In the case here, we are reading into the rest of the tcp packet
|
Started fixing the underlying issue in mirage/ocaml-cstruct#25 |
Cstruct 1.3.0 is now in ocaml/opam-repository#2322 |
One of the series of posts described at: mirage/mirage#257
Unikernels running with the
direct
stack crash upon receipt of a TCP packet that contains a variable-length TCP option, when the length is set to 0. For example, setting the TCP options bytefield to 01 02 00 00 (padding, MSS with length 0, end-of-options) and sending a SYN packet to an open port on a unikernel running the exampleservices
code results in the following console output:The unikernel then exits.
I'm looking into the root cause, which I expect is somewhere in
Options.unmarshal
.The text was updated successfully, but these errors were encountered: