Server admin port still vulnerable to DOS
There are 128 connections allowed where each is limited to 512mb, this leaves 64GB of memory that can be acquired by a mal actor.
There is also still the issue where it is not checking if the socket is closed.
If I understand the idea of that port, the only data sent through it are some json files? I don't think it justifies such a large max size.
I think this is a larger problem though. Why is the the socket being accessed directly? There are many similar gotchas need to be considered when programming directly on a TCP socket and there are many libraries that have already done the hard work of solving those problems.
gRPC is an option since its already in your stack, Flask is an option but it doesn't match the use case too well, zeromq is an option
The admin was taken from a different project from the past. We may change to use other communication mechanism in future.
As to the volume of data, it could be very large, even though examples only show small json files. For example, some users include model weights (> 300MB) in the app to be uploaded.
@Nintorac , thanks so much for such a thorough review and analysis - we really appreciate it!
Just to let you know that NVIDIA takes security issues very seriously. We have a dedicated team for this, and you can report any findings directly to them, if you like: https://www.nvidia.com/en-us/security/report-vulnerability/
We are currently working on a fix based on your findings - another PR is coming soon. When the PR is ready, we'll invite you to review.
We also think your general comment about not directly using TCP but instead using a well-established framework like http/gRPC is a good one. We actually have a plan to do just that in later releases!
We are following industry best practice and company process to address this issue. We will assign a CVE ID and publish a security advisory after the fix is merged. We'd like to mention your name in the Advisory, let us know your preferred name and if this is okay with you.
@Nintorac To address the memory issue, we lowered the admin connections to 16. Can you elaborate on this issue?
>There is also still the issue where it is not checking if the socket is closed.
Currently, the closed connections are handled by the timeout or exception handling.
We also think your general comment about not directly using TCP but instead using a well-established framework like http/gRPC is a good one. We actually have a plan to do just that in later releases!
Awesome!
We will assign a CVE ID and publish a security advisory after the fix is merged. We'd like to mention your name in the Advisory, let us know your preferred name and if this is okay with you.
My first :) Is Nintorac ok?
To address the memory issue, we lowered the admin connections to 16
Still seems like a lot of overhead to me but I'll leave the numbers up to you. Especially since no authorization is required on the endpoint to enable this attack.
the closed connections are handled by the timeout or exception handling.
Closed connections consume 100% CPU while they are still running for the 10 seconds before timeout. So would held connections that aren't being sent data. Or open connections that send 500mb and then hold/close.
Another thing, will the timeout potentially affect real users who cant upload >300mb in 10 seconds?
IMO it's not worth chasing a solutions for this and all releases are likely to have some form of DOS until the move to an established framework is complete.
Still seems like a lot of overhead to me but I'll leave the numbers up to you. Especially since no authorization is required on the endpoint to enable this attack.
All the tests were done in POC mode, which is not supposed to be used in a production environment with open ports. In provisioned mode, mutual-authenticated (2-way) TLS is required. That's a pretty strong authorization method.
Closed connections consume 100% CPU while they are still running for the 10 seconds before timeout. So would held connections that aren't being sent data. Or open connections that send 500mb and then hold/close.
The socket lifecycle is managed by TPCServer class. As soon as the handler returns, socket is closed. There shouldn't be more than 16 open connections at any moment on this port.
Another thing, will the timeout potentially affect real users who cant upload 300mb in 10 seconds?
The 10 second timeout is for each recv() call. As long as data flows in with no big gaps, there is no total time limit (only a size limit).
Thanks for your feedback.
@Nintorac , thanks again for the detailed discussion on the solution. Reviews from people like you make the system strong!
We could use Nintorac in the Advisory as your name. However, since the Advisory is a formal document and will be publicly and independently available, I wonder whether you want to use your formal first/last name instead. This is basically for your credits. Please confirm your preference. Thanks!
That's a pretty strong authorization method
Depends how well you keep your CA :laughing: Long term I think we will be using a mesh networking layer which abstracts mTLS away from the application via sidecar proxy (in a k8s environment), so the port will lack auth within the pod. Unlikely to matter really so I'll take your point but good to consider that there are multiple ways to deploy things
As soon as the handler returns, socket is closed
The point is the handler does not return if the client closes it's side of the connection without sending the terminate byte.
When the client closes the connection without sending the terminate byte the recieve_till_end function becomes a busy wait consuming 100% CPU. Try it something like telnet localhost:8003 and then ctrl + c, and then observe CPU spike for the 10 seconds to timeout
The 10 second timeout is for each recv() call
Ah nice, I did not know :+1:
@yanchengnv yes fair enough, I will email you
Thanks all for the discussion, I learned a lot from these.
Hi @Nintorac for your suggestion:
The point is the handler does not return if the client closes it's side of the connection without sending the terminate byte.
What would you suggest if we want to fix this problem?
Thanks!
No problems, glad to help out :)
Checking if the socket is closed is a good start, I included some code in this comment.
https://github.com/NVIDIA/NVFlare/issues/258#issuecomment-1062299673
..but I did just pull it from Stack Overflow so I don't know if it's actually prod ready