Potential curl CVE-2023-38545 Exploitation

Detects potential exploitation of curl CVE-2023-38545 by monitoring for vulnerable command line arguments in conjunction with an unusual command line length. A flaw in curl version <= 8.3 makes curl vulnerable to a heap based buffer overflow during the SOCKS5 proxy handshake. Upgrade to curl version >= 8.4 to patch this vulnerability. This exploit can be executed with and without the use of environment variables. For increased visibility, enable the collection of http_proxy, HTTPS_PROXY and ALL_PROXY environment variables based on the instructions provided in the setup guide of this rule.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2023/10/11"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/05/21"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Detects potential exploitation of curl CVE-2023-38545 by monitoring for vulnerable command line arguments in conjunction
 11with an unusual command line length. A flaw in curl version <= 8.3 makes curl vulnerable to a heap based buffer overflow
 12during the SOCKS5 proxy handshake. Upgrade to curl version >= 8.4 to patch this vulnerability. This exploit can be
 13executed with and without the use of environment variables. For increased visibility, enable the collection of
 14http_proxy, HTTPS_PROXY and ALL_PROXY environment variables based on the instructions provided in the setup guide of
 15this rule.
 16"""
 17from = "now-9m"
 18index = ["logs-endpoint.events.*"]
 19language = "eql"
 20license = "Elastic License v2"
 21name = "Potential curl CVE-2023-38545 Exploitation"
 22references = [
 23    "https://curl.se/docs/CVE-2023-38545.html",
 24    "https://daniel.haxx.se/blog/2023/10/11/curl-8-4-0/",
 25    "https://twitter.com/_JohnHammond/status/1711986412554531015",
 26]
 27risk_score = 47
 28rule_id = "f41296b4-9975-44d6-9486-514c6f635b2d"
 29setup = """## Setup
 30
 31This rule requires data coming in from Elastic Defend.
 32
 33### Elastic Defend Integration Setup
 34Elastic Defend is integrated into the Elastic Agent using Fleet. Upon configuration, the integration allows the Elastic Agent to monitor events on your host and send data to the Elastic Security app.
 35
 36#### Prerequisite Requirements:
 37- Fleet is required for Elastic Defend.
 38- To configure Fleet Server refer to the [documentation](https://www.elastic.co/guide/en/fleet/current/fleet-server.html).
 39
 40#### The following steps should be executed in order to add the Elastic Defend integration on a Linux System:
 41- Go to the Kibana home page and click "Add integrations".
 42- In the query bar, search for "Elastic Defend" and select the integration to see more details about it.
 43- Click "Add Elastic Defend".
 44- Configure the integration name and optionally add a description.
 45- Select the type of environment you want to protect, either "Traditional Endpoints" or "Cloud Workloads".
 46- Select a configuration preset. Each preset comes with different default settings for Elastic Agent, you can further customize these later by configuring the Elastic Defend integration policy. [Helper guide](https://www.elastic.co/guide/en/security/current/configure-endpoint-integration-policy.html).
 47- We suggest selecting "Complete EDR (Endpoint Detection and Response)" as a configuration setting, that provides "All events; all preventions"
 48- Enter a name for the agent policy in "New agent policy name". If other agent policies already exist, you can click the "Existing hosts" tab and select an existing policy instead.
 49For more details on Elastic Agent configuration settings, refer to the [helper guide](https://www.elastic.co/guide/en/fleet/8.10/agent-policy.html).
 50- Click "Save and Continue".
 51- To complete the integration, select "Add Elastic Agent to your hosts" and continue to the next section to install the Elastic Agent on your hosts.
 52For more details on Elastic Defend refer to the [helper guide](https://www.elastic.co/guide/en/security/current/install-endpoint.html).
 53
 54Elastic Defend integration does not collect environment variable logging by default.
 55In order to capture this behavior, this rule requires a specific configuration option set within the advanced settings of the Elastic Defend integration.
 56 #### To set up environment variable capture for an Elastic Agent policy:
 57- Go to “Security → Manage → Policies”.
 58- Select an “Elastic Agent policy”.
 59- Click “Show advanced settings”.
 60- Scroll down or search for “linux.advanced.capture_env_vars”.
 61- Enter the names of environment variables you want to capture, separated by commas.
 62- For this rule the linux.advanced.capture_env_vars variable should be set to "http_proxy,HTTPS_PROXY,ALL_PROXY".
 63- Click “Save”.
 64After saving the integration change, the Elastic Agents running this policy will be updated and the rule will function properly.
 65For more information on capturing environment variables refer to the [helper guide](https://www.elastic.co/guide/en/security/current/environment-variable-capture.html).
 66"""
 67severity = "medium"
 68tags = [
 69    "Domain: Endpoint",
 70    "OS: Linux",
 71    "Use Case: Threat Detection",
 72    "Use Case: Vulnerability",
 73    "Tactic: Execution",
 74    "Data Source: Elastic Defend",
 75]
 76timestamp_override = "event.ingested"
 77type = "eql"
 78
 79query = '''
 80process where host.os.type == "linux" and event.type == "start" and event.action == "exec" and process.name == "curl" 
 81and (
 82  process.args : ("--socks5-hostname", "--proxy", "--preproxy", "socks5*") or 
 83  process.env_vars: ("http_proxy=socks5h://*", "HTTPS_PROXY=socks5h://*", "ALL_PROXY=socks5h://*")
 84) and length(process.command_line) > 255 and 
 85not process.parent.name in ("cf-agent", "agent-run", "agent-check", "rudder", "agent-inventory", "cf-execd") and
 86not process.args == "/opt/rudder/bin/curl"
 87'''
 88
 89
 90[[rule.threat]]
 91framework = "MITRE ATT&CK"
 92[[rule.threat.technique]]
 93id = "T1203"
 94name = "Exploitation for Client Execution"
 95reference = "https://attack.mitre.org/techniques/T1203/"
 96
 97
 98[rule.threat.tactic]
 99id = "TA0002"
100name = "Execution"
101reference = "https://attack.mitre.org/tactics/TA0002/"

References

Related rules

to-top