CVE-2024-29042: Translate Cache Poisoning Vulnerability Vulnerability

MODERATE
Advisory Identifier: GHSA-882j-4vj5-7vmj
CVSS 5.3
CWE-20
Published
Advisory Summary

CVE-2024-29042 is a MODERATE (CVSS 5.3) cache poisoning vulnerability vulnerability (CWE-20: Improper Input Validation) affecting Translate libraries in the npm ecosystem. The issue involves cache poisoning vulnerability. Remediation is available by upgrading affected packages to version 3.0.0.

CVE-2024-29042 at a Glance

CVE Identifier CVE-2024-29042
GHSA Identifier GHSA-882j-4vj5-7vmj
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-20: Improper Input Validation
Affected Product Translate
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.3

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:U/C:N/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 Unchanged (S:U)
Confidentiality None (C:N)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2024-29042

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

translate fixed: 3.0.0
npm install translate@3.0.0
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 translate

How to Check if You Are Affected

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

npm ls translate

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

Note: The npm ls translate 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-20: Improper Input Validation, where the product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. In Translate, 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 An attacker controlling the second variable of the `translate` function is able to perform a cache poisoning attack. They can change the outcome of translation requests made by subsequent users. ### Details The `opt.id` parameter allows the overwriting of the cache key. If an attacker sets the `id` variable to the cache key that would be generated by another user, they can choose the response that user gets served. ### PoC Take the following simple server allowing users to supply text and the language to translate to. ```javascript import translate from "translate"; import express from 'express'; const app = express(); app.use(express.json()); app.post('/translate', async (req, res) => { const { text, language } = req.body; const result = await translate(text, language); return res.json(result); }); const port = 3000; app.listen(port, () => { console.log(`Server is running on port ${port}`); }); ``` We can send the following request to poison the cache: ``` {"text":"I hate you", "language":{"to":"nl","id":"undefined:en:nl:google:I love you"}} ``` ![Poisoning the cache](https://user-images.githubusercontent.com/44903767/285421743-ccfa3d9d-24cf-47b7-b805-0e4034cec82e.png) Now, any user that attempts to translate "I love you" to Dutch, will get "I hate you" in Dutch as the response. ![The victim gets our poisoned data](https://user-images.githubusercontent.com/44903767/285422033-b3853ca2-8a5a-4875-91e8-ba2ef0258bc6.png) ### Impact An attacker can control the results other users may get

CVE-2024-29042 Affected Translate Versions

1 component(s)
Fixed Versions:
3.0.0
Product / Package Ecosystem Affected Versions Fixed Version
translate
npm
< 3.0.0
3.0.0

References

Frequently Asked Questions

What is CVE-2024-29042?
CVE-2024-29042 is a security vulnerability in Translate involving Cache Poisoning Vulnerability under CWE-20: Improper Input Validation.
Which Translate versions are affected?
Affected versions include releases prior to 3.0.0 across affected packages: translate.
What version fixes CVE-2024-29042?
Upgrading to 3.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is translate affected?
Yes, translate is affected in releases prior to 3.0.0. Upgrade your dependency to 3.0.0 or later.
What is the CVSS score of CVE-2024-29042?
CVE-2024-29042 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N.
What CWE is associated with CVE-2024-29042?
CVE-2024-29042 is classified under CWE-20: Improper Input Validation (The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly.).
How can I check npm dependencies for CVE-2024-29042?
Run the dependency tree command: 'npm ls translate'. 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-882j-4vj5-7vmj",
  "modified" : "2024-03-22T20:02:15Z",
  "published" : "2024-03-22T16:57:21Z",
  "aliases" : [ "CVE-2024-29042" ],
  "summary" : "Cache Poisoning Vulnerability",
  "details" : "### Summary\nAn attacker controlling the second variable of the `translate` function is able to perform a cache poisoning attack. They can change the outcome of translation requests made by subsequent users.\n\n### Details\nThe `opt.id` parameter allows the overwriting of the cache key. If an attacker sets the `id` variable to the cache key that would be generated by another user, they can choose the response that user gets served.\n\n### PoC\nTake the following simple server allowing users to supply text and the language to translate to.\n```javascript\nimport translate from \"translate\";\nimport express from 'express';\n\nconst app = express();\napp.use(express.json());\n\napp.post('/translate', async (req, res) => {\n  const { text, language } = req.body;\n  const result = await translate(text, language);\n  return res.json(result);\n});\n\nconst port = 3000;\napp.listen(port, () => {\n  console.log(`Server is running on port ${port}`);\n});\n```\n\nWe can send the following request to poison the cache:\n```\n{\"text\":\"I hate you\", \"language\":{\"to\":\"nl\",\"id\":\"undefined:en:nl:google:I love you\"}}\n```\n![Poisoning the cache](https://user-images.githubusercontent.com/44903767/285421743-ccfa3d9d-24cf-47b7-b805-0e4034cec82e.png)\n\nNow, any user that attempts to translate \"I love you\" to Dutch, will get \"I hate you\" in Dutch as the response.\n![The victim gets our poisoned data](https://user-images.githubusercontent.com/44903767/285422033-b3853ca2-8a5a-4875-91e8-ba2ef0258bc6.png)\n\n\n### Impact\nAn attacker can control the results other users may get\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "translate"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/franciscop/translate/security/advisories/GHSA-882j-4vj5-7vmj"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-29042"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/franciscop/translate/commit/7a2bf8b9f05f7c45c09683973ef4d8e995804aa4"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/franciscop/translate/commit/cc1ba03078102f83e0503a96f1a081489bb865d3"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/franciscop/translate"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-20" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-03-22T16:57:21Z",
    "nvd_published_at" : "2024-03-22T17:15:07Z"
  }
}