You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A critical security vulnerability has been identified in the dlrover project, specifically within the Python module python/common/grpc.py. The function deserialize_message is susceptible to a deserialization flaw when handling gRPC messages. This issue can be exploited by an attacker with access to the dlrover-master gRPC service running on port 50001, potentially allowing for arbitrary code execution and unauthorized system access.
Affected Components
dlrover version(s) affected: All versions up until the date of this report.
Component: python/common/grpc.py
Function: deserialize_message
Impact
The dlrover-master exposes a gRPC endpoint on port 50001 for worker nodes to connect. When this service is deployed in a Kubernetes cluster, the port is exposed as a service, making it accessible by any container within the cluster under default configurations. An attacker could exploit this vulnerability by sending a maliciously crafted pickle data through the Message's data field, leading to remote code execution upon deserialization.
Technical Details
The Message protocol buffer message includes a bytes field named data, which is intended to carry serialized Python objects using the pickle format. However, pickle is known to be unsafe for deserializing untrusted data as it can execute arbitrary code during the deserialization process.
Proof of Concept (PoC)
Below is a simplified PoC demonstrating how an attacker might exploit this vulnerability:
elastic_training.proto
By executing the above scripts, an attacker can create a payload that, when deserialized by the dlrover-master, will execute the command touch /tmp/pwned, creating a file at /tmp/pwned on the master.
Recommendations
To mitigate this risk, it is recommended that:
Implementation of RestrictedUnpickler
By implementing a custom unpickler that overrides the find_class method, you can enforce a whitelist of classes that are allowed to be instantiated during the deserialization process. This approach ensures that only trusted classes can be created, thereby reducing the attack surface.
authentication
The dlrover-master gRPC service should implement authentication and authorization mechanisms to restrict access only to trusted entities.
Best regards,
12end@cyberkl
The text was updated successfully, but these errors were encountered:
Replacing GRPC and pickle with HTTP and JSON can reduce the risk associated with pickle deserialization vulnerabilities. JSON is indeed generally safer as it doesn't have the same built-in ability to execute arbitrary code like pickle. However, it's not a silver bullet.Proper input validation and sanitization still need to be implemented carefully to prevent other types of attacks. Also, the overall security architecture, including access controls and authentication, needs to be reevaluated and strengthened. If the security of the master cannot be guaranteed, companies using dlrover may encounter the "insider" problem that Bytedance had before.
Of course, I don't intend to exaggerate the dangers and add workload to you or your team. I just raise the issue. It is up to you to decide whether to add various security measures. After all, this will consume some human resources and time.
Summary
A critical security vulnerability has been identified in the dlrover project, specifically within the Python module python/common/grpc.py. The function deserialize_message is susceptible to a deserialization flaw when handling gRPC messages. This issue can be exploited by an attacker with access to the dlrover-master gRPC service running on port 50001, potentially allowing for arbitrary code execution and unauthorized system access.
Affected Components
dlrover version(s) affected: All versions up until the date of this report.
Component: python/common/grpc.py
Function: deserialize_message
Impact
The dlrover-master exposes a gRPC endpoint on port 50001 for worker nodes to connect. When this service is deployed in a Kubernetes cluster, the port is exposed as a service, making it accessible by any container within the cluster under default configurations. An attacker could exploit this vulnerability by sending a maliciously crafted pickle data through the Message's data field, leading to remote code execution upon deserialization.
Technical Details
The Message protocol buffer message includes a bytes field named data, which is intended to carry serialized Python objects using the pickle format. However, pickle is known to be unsafe for deserializing untrusted data as it can execute arbitrary code during the deserialization process.
Proof of Concept (PoC)
Below is a simplified PoC demonstrating how an attacker might exploit this vulnerability:
elastic_training.proto
exp.py
gen_pickle.py
command:
By executing the above scripts, an attacker can create a payload that, when deserialized by the dlrover-master, will execute the command touch /tmp/pwned, creating a file at /tmp/pwned on the master.
Recommendations
To mitigate this risk, it is recommended that:
Implementation of RestrictedUnpickler
By implementing a custom unpickler that overrides the find_class method, you can enforce a whitelist of classes that are allowed to be instantiated during the deserialization process. This approach ensures that only trusted classes can be created, thereby reducing the attack surface.
authentication
The dlrover-master gRPC service should implement authentication and authorization mechanisms to restrict access only to trusted entities.
Best regards,
12end@cyberkl
The text was updated successfully, but these errors were encountered: