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

References

Related rules

to-top