CVE-2024-39687: @fedify/fedify Server Side Request Forgery (SSRF) Vulnerability

MODERATE
Advisory Identifier: GHSA-p9cg-vqcc-grcx
CVSS 7.2
CWE-918
Published
Advisory Summary

CVE-2024-39687 is a MODERATE (CVSS 7.2) server side request forgery (ssrf) vulnerability (CWE-918: Server-Side Request Forgery (SSRF)) affecting @fedify/fedify libraries in the npm ecosystem. The issue involves server side request forgery (ssrf) attack in fedify. Remediation is available by upgrading affected packages to version 0.9.2, 0.10.2, 0.11.2.

CVE-2024-39687 at a Glance

CVE Identifier CVE-2024-39687
GHSA Identifier GHSA-p9cg-vqcc-grcx
Severity MODERATE
CVSS v3.1 Base Score 7.2
CWE Classification CWE-918: Server-Side Request Forgery (SSRF)
Affected Product @fedify/fedify
Package Ecosystem npm
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:N/A:L).

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 None (I:N)
Availability Low (A:L)

How to Fix CVE-2024-39687

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

@fedify/fedify fixed: 0.9.2
npm install @fedify/fedify@0.9.2
@fedify/fedify fixed: 0.10.2
npm install @fedify/fedify@0.10.2
@fedify/fedify fixed: 0.11.2
npm install @fedify/fedify@0.11.2
Verify Direct and Transitive Dependencies

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

npm ls @fedify/fedify

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2024-39687, inspect your project dependencies using npm:

npm ls @fedify/fedify

Analyze the terminal output to locate any version of @fedify/fedify in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.9.2), your application is affected.

Note: The npm ls @fedify/fedify command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-918: Server-Side Request Forgery (SSRF), where the web server receives a url or similar request from an upstream component and retrieves the contents of this url, but it does not sufficiently ensure that the request is being sent to the expected destination. In @fedify/fedify, 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

### Summary At present, when Fedify needs to retrieve an object or activity from a remote activitypub server, it makes a HTTP request to the `@id` or other resources present within the activity it has received from the web. This activity could reference an `@id` that points to an internal IP address, allowing an attacker to send request to resources internal to the fedify server's network. This applies to not just resolution of documents containing activities or objects, but also to media URLs as well. Specifically this is a [Server Side Request Forgery attack](https://owasp.org/www-community/attacks/Server_Side_Request_Forgery). You can learn more about SSRF attacks via [CWE-918](https://cwe.mitre.org/data/definitions/918.html) ### Details When Fedify makes a request at runtime via the DocLoader [1] [2], the `fetch` API does not first check the URI's to assert that it resolve to a public IP address. Additionally, any downstream software of Fedify that may fetch data from URIs contained within Activities or Objects maybe be at risk of requesting non-public resources, and storing those, exposing non-public information to the public. Additionally, in many cases the URIs are not asserted to be either strictly HTTPS or HTTP protocols, which could lead to further attacks, and there is no check that the URI contains a `hostname` part. Whilst the [`fetch()` specification](https://fetch.spec.whatwg.org/) may provide some safety here, along with underlying fetch implementations, there is still potential for attacks through using `data:` URIs, or just attacking some other protocol entirely, e.g., FTP or CalDav. [1] https://github.com/dahlia/fedify/blob/main/runtime/docloader.ts#L141 [2] https://github.com/dahlia/fedify/blob/main/runtime/docloader.ts#L175 #### Deno-specific Attack Vectors In Deno specifically, the `fetch()` API allows [accessing local filesystem](https://docs.deno.com/deploy/api/runtime-fetch/), I'm not sure how Deno's [Permissions model](https://docs.deno.com/runtime/manual/runtime/permission_apis/) may prevent attacks utilising `file:` URIs. > Fetch also supports fetching from file URLs to retrieve static files. For more info on static files, see the [filesystem API documentation](https://docs.deno.com/deploy/api/runtime-fs). #### ActivityPub Security Considerations This is also noted in the ActivityPub spec in [Section B.3 Security Considerations](https://www.w3.org/TR/activitypub/#security-localhost), however, there it is more limited in scope. #### Other Implementations It may be acceptable to allow a server operator to allow access to given non-public IP addresses, for instance [in Mastodon](https://github.com/mastodon/mastodon/blob/092bb8a27af9ee87ff9ebabaf354477470ea3a94/app/lib/request.rb#L330) they allow requests to non-public IP addresses, i.e., localhost in development and those in the `ALLOWED_PRIVATE_ADDRESSES` environment variable. ### PoC I'm not sure a PoC is necessary given this is a reasonably well known vulnerability vector. ### Impact This impacts server operates, as resources that are internal to their network may find themselves being improperly accessed or potentially even attacked or exposed to the public. ### Notes for resolution: When implementing public IP address validation, be careful of [CWE-1389](https://cwe.mitre.org/data/definitions/1389.html) and [CWE-1286](https://cwe.mitre.org/data/definitions/1286.html) both of which [recently](https://github.com/advisories/GHSA-78xj-cgh5-2h22) caused a CVE to be filed against the popular node.js `ip` package, although this package was not originally intended for security purposes.

CVE-2024-39687 Affected @fedify/fedify Versions

3 component(s)
Fixed Versions:
0.9.20.10.20.11.2
Product / Package Ecosystem Affected Versions Fixed Version
@fedify/fedify
npm
< 0.9.2
0.9.2
@fedify/fedify
npm
≥ 0.10.0
< 0.10.2
0.10.2
@fedify/fedify
npm
≥ 0.11.0
< 0.11.2
0.11.2

References

Frequently Asked Questions

What is CVE-2024-39687?
CVE-2024-39687 is a security vulnerability in @fedify/fedify involving Server Side Request Forgery (SSRF) attack in Fedify under CWE-918: Server-Side Request Forgery (SSRF).
Which @fedify/fedify versions are affected?
Affected versions include releases prior to 0.9.2, 0.10.2, 0.11.2 across affected packages: @fedify/fedify.
What version fixes CVE-2024-39687?
Upgrading to 0.9.2, 0.10.2, 0.11.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @fedify/fedify affected?
Yes, @fedify/fedify is affected in releases prior to 0.9.2, 0.10.2, 0.11.2. Upgrade your dependency to 0.9.2, 0.10.2, 0.11.2 or later.
What is the CVSS score of CVE-2024-39687?
CVE-2024-39687 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:N/A:L.
What CWE is associated with CVE-2024-39687?
CVE-2024-39687 is classified under CWE-918: Server-Side Request Forgery (SSRF) (The web server receives a URL or similar request from an upstream component and retrieves the contents of this URL, but it does not sufficiently ensure that the request is being sent to the expected destination.).
How can I check npm dependencies for CVE-2024-39687?
Run the dependency tree command: 'npm ls @fedify/fedify'. 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-p9cg-vqcc-grcx",
  "modified" : "2024-11-18T16:26:49Z",
  "published" : "2024-07-05T20:07:54Z",
  "aliases" : [ "CVE-2024-39687" ],
  "summary" : "Server Side Request Forgery (SSRF) attack in Fedify",
  "details" : "### Summary\n \nAt present, when Fedify needs to retrieve an object or activity from a remote activitypub server, it makes a HTTP request to the `@id` or other resources present within the activity it has received from the web. This activity could reference an `@id` that points to an internal IP address, allowing an attacker to send request to resources internal to the fedify server's network.\n\nThis applies to not just resolution of documents containing activities or objects, but also to media URLs as well.\n\nSpecifically this is a [Server Side Request Forgery attack](https://owasp.org/www-community/attacks/Server_Side_Request_Forgery). You can learn more about SSRF attacks via [CWE-918](https://cwe.mitre.org/data/definitions/918.html)\n\n### Details\n\nWhen Fedify makes a request at runtime via the DocLoader [1] [2], the `fetch` API does not first check the URI's to assert that it resolve to a public IP address. Additionally, any downstream software of Fedify that may fetch data from URIs contained within Activities or Objects maybe be at risk of requesting non-public resources, and storing those, exposing non-public information to the public.\n\nAdditionally, in many cases the URIs are not asserted to be either strictly HTTPS or HTTP protocols, which could lead to further attacks, and there is no check that the URI contains a `hostname` part. Whilst the [`fetch()` specification](https://fetch.spec.whatwg.org/) may provide some safety here, along with underlying fetch implementations, there is still potential for attacks through using `data:` URIs, or just attacking some other protocol entirely, e.g., FTP or CalDav.\n\n[1] https://github.com/dahlia/fedify/blob/main/runtime/docloader.ts#L141\n[2] https://github.com/dahlia/fedify/blob/main/runtime/docloader.ts#L175\n\n#### Deno-specific Attack Vectors\n\nIn Deno specifically, the `fetch()` API allows [accessing local filesystem](https://docs.deno.com/deploy/api/runtime-fetch/), I'm not sure how Deno's [Permissions model](https://docs.deno.com/runtime/manual/runtime/permission_apis/) may prevent attacks utilising `file:` URIs.\n \n> Fetch also supports fetching from file URLs to retrieve static files. For more info on static files, see the [filesystem API documentation](https://docs.deno.com/deploy/api/runtime-fs).\n\n#### ActivityPub Security Considerations\n\nThis is also noted in the ActivityPub spec in [Section B.3 Security Considerations](https://www.w3.org/TR/activitypub/#security-localhost), however, there it is more limited in scope.\n\n#### Other Implementations\n\nIt may be acceptable to allow a server operator to allow access to given non-public IP addresses, for instance [in Mastodon](https://github.com/mastodon/mastodon/blob/092bb8a27af9ee87ff9ebabaf354477470ea3a94/app/lib/request.rb#L330) they allow requests to non-public IP addresses, i.e., localhost in development and those in the `ALLOWED_PRIVATE_ADDRESSES` environment variable.\n\n### PoC\n\nI'm not sure a PoC is necessary given this is a reasonably well known vulnerability vector.\n\n### Impact\n\nThis impacts server operates, as resources that are internal to their network may find themselves being improperly accessed or potentially even attacked or exposed to the public.\n\n### Notes for resolution:\n\nWhen implementing public IP address validation, be careful of [CWE-1389](https://cwe.mitre.org/data/definitions/1389.html) and [CWE-1286](https://cwe.mitre.org/data/definitions/1286.html) both of which [recently](https://github.com/advisories/GHSA-78xj-cgh5-2h22) caused a CVE to be filed against the popular node.js `ip` package, although this package was not originally intended for security purposes.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:N/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:N/VA:L/SC:L/SI:N/SA:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@fedify/fedify"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.9.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@fedify/fedify"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.10.0"
      }, {
        "fixed" : "0.10.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@fedify/fedify"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.11.0"
      }, {
        "fixed" : "0.11.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/dahlia/fedify/security/advisories/GHSA-p9cg-vqcc-grcx"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-39687"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dahlia/fedify/commit/30f9cf4a175704a04c874f3ea88414c5f1e00b28"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dahlia/fedify/commit/c641e976089dd913f649889c1bfb016df04e86ba"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/dahlia/fedify"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/dahlia/fedify/releases/tag/0.11.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-918" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-07-05T20:07:54Z",
    "nvd_published_at" : "2024-07-05T18:15:32Z"
  }
}