Blog Post

Microsoft Defender for Cloud Blog
4 MIN READ

High severity curl vulnerability: prepare with Microsoft Defender for Cloud

Lara_Goldstein's avatar
Oct 10, 2023

On October 3rd, high severity vulnerabilities in curl were preannounced. The curl project has announced that curl8.4.0 has now been released, earlier than expected. Two vulnerabilities have now been disclosed: high-severity CVE-2023-38545 and low-severity CVE-2023-38546.   

  

curl is a popular command-line tool and library (libcurl) used to transfer data across network protocols using URL syntax. The library is one of the most widely used open-source projects across most operating systems, including Windows and Linux, and is one of the most popular OSS packages present in clients, embedded systems, and cloud-native applications/containers.   

  

CVE-2023-38545 refers to a heap overflow vulnerability associated with the SOCKS5 proxy handshake in both libcurl and curl. When curl receives a hostname exceeding 255 bytes to relay to a SOCKS5 proxy, it defaults to local name resolution to determine the address before transferring it to the SOCKS5 proxy. A 2020 bug makes this local resolution potentially fail if the SOCKS5 handshake is delayed. As a result, curl might forward the oversized hostname to the intended buffer, triggering a heap overflow. 

 

CVE-2023-38546 pertains to a cookie injection vulnerability in curl_easy_duphandle(), a libcurl function responsible for duplicating easy handles. If cookies are active when an easy handle is duplicated, the resulting duplicate doesn't copy the actual cookies. Instead, it sets the filename to 'none.' As a consequence, when this duplicated easy handle is later utilized and no source is defined for the cookies, libcurl tries to load them from a file titled 'none' located on the storage.  

  

What is the impact and how do I identify risk? 

As a widely used OSS component in cloud-native applications, curl is very likely present in many resources, including Virtual Machines and Container Images. We strongly recommend that you collect an inventory of affected resources to ease the remediation process once the update is released. 

  

Microsoft Defender for Cloud has multiple ways to quickly determine where in your environment you are vulnerable that are covered in this blog. 

 

Method 1: Hunt for all impacted resources using the cloud security explorer

Note: To hunt for impacted resources, first enable Defender CSPM in Microsoft Defender for Cloud and ensure that the agentless scanning, container registry scanning, and agentless discovery for Kubernetes are enabled. For more details on enabling these services, click here for Defender CSPM. 

 

To query the cloud security graph for affected servers: 

  1. Sign in to the Azure portal.
  2. Use the following links to pre-populate Cloud Security Explorer queries:

 

Figure 1. Cloud security explorer query for Virtual Machines containing vulnerable curl packages.

 

To query the cloud security graph for affected container images: 

  1. Sign in to the Azure portal. 
  2. Use the following links to pre-populate Cloud Security Explorer queries: 

Learn more about cloud security explorer and other Defender CSPM capabilities. 

 

Method 2: Identify VMs where the application installed contains curl using Inventory

Note: To hunt for impacted resources, first enable Defender CSPM or Defender for Servers P1 or P2 in Microsoft Defender for Cloud and ensure that agentless scanning is enabled or that vulnerability scanning with Microsoft Defender Vulnerability Management is enabled. For more details on enabling these services, click here for Defender CSPM and here for Defender for Servers. 

 

  1. Sign in to the Azure portal.
  2. Filter for Installed applications contains curl. 
  3. Sort based on the number of unhealthy recommendations.
  4. Remediate the unhealthy recommendations to ensure that your attack surface is reduced.

 

Figure 2. Filter Inventory for security findings with CVE-2023-38545.

 

Method 3: Identify resources containing curl using Azure Resource Graph

  1. Follow the above steps. Within the Inventory blade select Open Query.  
  2. Run the sample queries below. 

 

Figure 3. Open Azure Resource Graph query from Inventory.

 

 

Sample query for retrieving virtual machines running curl: 

securityresources 
| where type == "microsoft.security/softwareinventories"
| where name has "curl"
| extend deviceId = tostring(properties.deviceId),
subscriptionId = tostring(properties.azureSubscriptionId),
osPlatform = tostring(properties.osPlatform),
version = tostring(properties.version),
softwareName = tostring(properties.softwareName),
azureVMId = tostring(properties.azureVmId)
| where not(version has ("8.4"))
| extend vmId = iff(azureVMId has "securityconnectors", split(azureVMId, '/')[10], split(azureVMId, '/')[8])
| extend environment = iff(id has "Microsoft.HybridCompute", "arc", iff(id has "microsoft.security/securityconnectors", "multicloud", "azure"))
| project id, subscriptionId, vmId, softwareName, version, osPlatform, environment

Sample query for retrieving container images with a curl vulnerability:

securityresources  
| where type =~ "microsoft.security/assessments/subassessments"
| extend assessmentKey=extract(@"(?i)providers/Microsoft.Security/assessments/([^/]*)", 1, id), subAssessmentId=tostring(properties.id), parentResourceId= extract("(.+)/providers/Microsoft.Security", 1, id)
| extend resourceId = tostring(properties.resourceDetails.id)
| extend subAssessmentName=tostring(properties.displayName),
    subAssessmentDescription=tostring(properties.description),
    subAssessmentRemediation=tostring(properties.remediation),
    severity=tostring(properties.status.severity),
    status=tostring(properties.status.code),
    cause=tostring(properties.status.cause),
    statusDescription=tostring(properties.status.description),
    additionalData=tostring(properties.additionalData)
| where assessmentKey == "c0b7cfc6-3172-465a-b378-53c7ff2cc0d5"
| where status == "Unhealthy"
| where subAssessmentId in ("CVE-2023-38545","CVE-2023-38546")
| extend repositoryName = tostring(properties.additionalData.artifactDetails.repositoryName), 
registry = tostring(properties.additionalData.artifactDetails.registryHost)
| distinct repositoryName, registry 

 

Identify other curl usage patterns 

Depending on your use case, it might be worth monitoring certain curl usage patterns. For example, you might have inadvertently hardcoded a curl release for download in a Dockerfile or a CI workflow definition. 

 

For GitHub Repos, you can leverage GitHub Code Search with a query like: (path:.github AND path:.yml) OR (path:Dockerfile) AND (curl.se/download OR github.com/curl/curl/releases) AND (org:<your org>).

 

You might encounter a hardcoded release number in this URL, or a parameter pointing to a hardcoded value. The screenshot below shows both patterns: 

 

Figure 4. Hardcoded curl release

  

 

Authors

  • Lara Goldstein, Product Manager 2
  • Charles Oxyer, Product Manager
  • Jose Miguel Parrella, Principal Architect
Updated Nov 09, 2023
Version 4.0

8 Comments

  • Bruce Bading's avatar
    Bruce Bading
    Copper Contributor

    Bruce Bading (President of BFB Security) has been in constant touch and has been pressing Microsoft for a suitable answer to which we have received the following responses. As an IBM and Microsoft Business Partner we implement the CIS controls. One of which is to report vulnerabilities to the proper vendor or the CISC. At this time, we are satisfied that Microsoft is actively addressing the problem and we are reporting any new findings to Microsoft. IBM where I was an Executive CyberSecurity Architect for over 25 years is also tracking the issue. We would also encourage anyone who has additional observations to report directly to Microsoft at https://msrc.microsoft.com/report/vulnerability where you can either reference MSRC Case 83266 or open a new case. Additional CVEs have been discovered and posted and we expect that Microsoft is taking this issue seriously.

    Hello Bruce,

    thank you for your report to the MSRC.

    You may find the following relevant:

    https://msrc.microsoft.com/update-guide/vulnerability/CVE-2023-38545
    https://msrc.microsoft.com/update-guide/vulnerability/CVE-2023-38039

    As noted there, Microsoft is planning to update these open-source components in Windows. Please watch these two sites for updates.

    Thank you again for working with MSRC.

    Regards,
    MSRC


    Hi Bruce,

    Here's an update on your case:

    MSRC Case 83266

    We confirmed the behavior you reported. We'll continue our investigation and determine how to address this issue.

    Please let me know if you have additional information that could aid our investigation, or if you have questions.

    Thanks!

    Duncan
    MSRC

  • Bruce Bading's avatar
    Bruce Bading
    Copper Contributor

    c:\windows\system32\curl.exe is at version 8.0.1.0 and needs to be updated regularly. BFB Security has contacted the Microsoft Security Response Center and is awaiting a response back as to Microsoft's update cadence for curl.exe, an integral part of the Windows OS on prem and cloud. The CSA where BFB Security is also a member along with the CIS have joined forces to secure the cloud and we are looking for all vendors to quickly patch known vulnerabilities which this is. We encourage all to notify the Microsoft Security Response Center https://msrc.microsoft.com/report/vulnerability and promote a quick patch cadence. This is the first time in our long history as an IBM Business Partner and IBM Security Advisor that we have seen a major OS leave an integral part of the OS unpatched.

  • adamm1955's avatar
    adamm1955
    Copper Contributor

    Is anyone aware of any new or upcoming updates for curl from Microsoft? Thank you.

  • NickAtHome's avatar
    NickAtHome
    Copper Contributor

    So will Microsoft finally be implementing the cUrl update to fix this vulnerability?  

  • DS1802's avatar
    DS1802
    Copper Contributor

    Is there an update from MSFT to resolve this vulnerability?

  • FPLSL's avatar
    FPLSL
    Copper Contributor

    Another alternative and simpler KQL query for Defender Advanced Hunting

     

    DeviceTvmSoftwareInventory
    | where SoftwareName contains "curl"