CVE-2024-45258: Github.com/imroc/req/v3 Req May Send An Unintended Vulnerability

MODERATE
Advisory Identifier: GHSA-cj55-gc7m-wvcq
CVSS 7.2
CWE-94 CWE-20 CWE-918
Published
Advisory Summary

CVE-2024-45258 is a MODERATE (CVSS 7.2) req may send an unintended vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Github.com/imroc/req/v3 libraries in the Go ecosystem. The issue involves req may send an unintended request when a malformed url is provided. Remediation is available by upgrading affected packages to version 3.43.4.

CVE-2024-45258 at a Glance

CVE Identifier CVE-2024-45258
GHSA Identifier GHSA-cj55-gc7m-wvcq
Severity MODERATE
CVSS v3.1 Base Score 7.2
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Github.com/imroc/req/v3
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.2

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2024-45258

To remediate this vulnerability, upgrade all affected Github.com/imroc/req/v3 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/imroc/req/v3 fixed: 3.43.4
Upgrade github.com/imroc/req/v3 to 3.43.4
github.com/imroc/req fixed: 3.43.4
Upgrade github.com/imroc/req to 3.43.4
github.com/imroc/req/v2 fixed: 3.43.4
Upgrade github.com/imroc/req/v2 to 3.43.4
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/imroc/req/v3

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-45258, inspect your project dependencies for Github.com/imroc/req/v3:

inspect dependencies for github.com/imroc/req/v3

Analyze the terminal output to locate any version of Github.com/imroc/req/v3 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.43.4), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Github.com/imroc/req/v3, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

The `req` library is a widely used HTTP library in Go. However, it does not handle malformed URLs effectively. As a result, after parsing a malformed URL, the library may send HTTP requests to unexpected destinations, potentially leading to security vulnerabilities or unintended behavior in applications relying on this library for handling HTTP requests. Despite developers potentially utilizing the `net/url` library to parse malformed URLs and implement blocklists to prevent HTTP requests to listed URLs, inconsistencies exist between how the `net/url` and `req` libraries parse URLs. These discrepancies can lead to the failure of defensive strategies, resulting in potential security threats such as Server-Side Request Forgery (SSRF) and Remote Code Execution (RCE).

CVE-2024-45258 Affected Github.com/imroc/req/v3 Versions

3 component(s)
Fixed Versions:
3.43.4
Product / Package Ecosystem Affected Versions Fixed Version
github.com/imroc/req/v3
Go
< 3.43.4
3.43.4
github.com/imroc/req
Go
< 3.43.4
3.43.4
github.com/imroc/req/v2
Go
< 3.43.4
3.43.4

References

Frequently Asked Questions

What is CVE-2024-45258?
CVE-2024-45258 is a security vulnerability in Github.com/imroc/req/v3 involving req may send an unintended request when a malformed URL is provided under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Github.com/imroc/req/v3 versions are affected?
Affected versions include releases prior to 3.43.4 across affected packages: github.com/imroc/req/v3, github.com/imroc/req, github.com/imroc/req/v2.
What version fixes CVE-2024-45258?
Upgrading to 3.43.4 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/imroc/req/v3 affected?
Yes, github.com/imroc/req/v3 is affected in releases prior to 3.43.4. Upgrade your dependency to 3.43.4 or later.
Is github.com/imroc/req affected?
Yes, github.com/imroc/req is affected in releases prior to 3.43.4. Upgrade your dependency to 3.43.4 or later.
What is the CVSS score of CVE-2024-45258?
CVE-2024-45258 has a CVSS v3.1 base score of 7.2 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2024-45258?
CVE-2024-45258 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check Go dependencies for CVE-2024-45258?
Run the dependency tree command: 'inspect dependencies for github.com/imroc/req/v3'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-cj55-gc7m-wvcq",
  "modified" : "2024-11-18T16:27:07Z",
  "published" : "2024-08-26T00:30:54Z",
  "aliases" : [ "CVE-2024-45258" ],
  "summary" : "req may send an unintended request when a malformed URL is provided",
  "details" : "The `req` library is a widely used HTTP library in Go. However, it does not handle malformed URLs effectively. As a result, after parsing a malformed URL, the library may send HTTP requests to unexpected destinations, potentially leading to security vulnerabilities or unintended behavior in applications relying on this library for handling HTTP requests.\n\nDespite developers potentially utilizing the `net/url` library to parse malformed URLs and implement blocklists to prevent HTTP requests to listed URLs, inconsistencies exist between how the `net/url` and `req` libraries parse URLs. These discrepancies can lead to the failure of defensive strategies, resulting in potential security threats such as Server-Side Request Forgery (SSRF) and Remote Code Execution (RCE).",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/imroc/req/v3"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.43.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/imroc/req"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.43.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/imroc/req/v2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.43.4"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-45258"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/imroc/req/commit/04e3ece5b380ecad9da3551c449f1b8a9aa76d3d"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/imroc/req"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/imroc/req/compare/v3.43.3...v3.43.4"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2024-3098"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20", "CWE-918", "CWE-94" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-08-26T15:54:18Z",
    "nvd_published_at" : "2024-08-25T22:15:05Z"
  }
}