Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2024-29042 Overview
CVE-2024-29042 is a cache poisoning vulnerability in the translate npm package maintained by Francisco. The package provides text translation capabilities for Node.js and browser environments. Versions prior to 3.0.0 allow an attacker who controls the second argument of the translate function to override the internal cache key through the opt.id parameter. By setting opt.id to match a cache key generated for another user, the attacker can control the translation response delivered to subsequent requests. The maintainer addressed the issue in version 3.0.0 by simplifying the available options and eliminating runtime writes to the cache key.
Critical Impact
Attackers who influence translation options can poison the shared cache and manipulate translation output served to other users of the application.
Affected Products
- Francisco translate npm package, all versions prior to 3.0.0
- Node.js applications consuming the vulnerable translate module
- Browser applications bundling the vulnerable translate module
Discovery Timeline
- 2024-03-22 - CVE-2024-29042 published to the National Vulnerability Database (NVD)
- 2026-06-17 - Last updated in the NVD database
Technical Details for CVE-2024-29042
Vulnerability Analysis
The translate package caches translation results to avoid repeat network calls to upstream engines such as Google, DeepL, Libre, and Yandex. Cache keys are normally derived from inputs like source text, source language, and target language. The vulnerable implementation also honors a user-supplied opt.id field that directly overrides the computed cache key.
When an application exposes any attribute of the options object to untrusted input, an attacker can set opt.id to a cache key that will later be computed for a legitimate user request. The attacker-supplied translation is then stored under that key and returned to the victim, enabling integrity attacks on downstream translation output. The flaw is tracked under improper input validation [CWE-20].
Root Cause
The root cause is an overly permissive options interface that allowed caller-controlled values to overwrite internal state. The pre-3.0.0 TypeScript definition exposed keys, cache, engines, and other advanced tweaking fields on the per-call options object. The maintainer removed these runtime-writable options in favor of a minimal { from, to } call-time surface, with configuration moved to module-level properties.
Attack Vector
Exploitation requires that the application forwards attacker-influenced data into the second argument of translate(). A common pattern is accepting translation preferences from a request body or query string and passing the parsed object straight to the library. No authentication is required if the surrounding endpoint is unauthenticated.
// Patch excerpt from index.d.ts - options surface reduced
-type Options =
- | string
- | {
- from?: string;
- to?: string;
- key?: string;
- engine?: "google" | "deepl" | "libre" | "yandex";
- keys?: { [name: string]: string };
- cache?: number;
- engines?: { [name: string]: Engine };
- };
-
-export default function Translate(
- text: string,
- options?: Options
-): Promise<string>;
+type Options = string | { from?: string; to?: string };
+
+declare const translate: {
+ (text: string, opts?: Options): Promise<string>;
+ key?: string;
+ engine?: "google" | "deepl" | "libre" | "yandex";
+};
// Source: https://github.com/franciscop/translate/commit/cc1ba03078102f83e0503a96f1a081489bb865d3
Detection Methods for CVE-2024-29042
Indicators of Compromise
- Translation responses that do not match the submitted source text or target language for a given request.
- Application logs showing calls to translate() where the options argument contains an id, keys, cache, or engines field originating from client input.
- Unexpected cache hits for inputs that should be unique per user session.
Detection Strategies
- Perform a software composition analysis scan of package.json and package-lock.json to identify translate versions below 3.0.0.
- Grep source trees for calls to translate(text, opts) where opts is derived from req.body, req.query, or other untrusted inputs.
- Add integration tests that submit crafted opt.id values and confirm the library ignores them.
Monitoring Recommendations
- Log the keyset of the options object passed into translate() and alert on unexpected properties.
- Monitor outbound requests to translation engine APIs for volume anomalies that may indicate attempted cache seeding.
- Track user-reported inconsistencies in translated content as a potential signal of cache poisoning.
How to Mitigate CVE-2024-29042
Immediate Actions Required
- Upgrade the translate package to version 3.0.0 or later across all Node.js and browser build targets.
- Audit application code to ensure untrusted input is never forwarded directly as the second argument of translate().
- Invalidate any existing translation caches that may have been populated while running a vulnerable version.
Patch Information
The fix is delivered in translate 3.0.0. The maintainer reworked the options surface so that callers can only pass { from, to } at call time, while engine, key, and cache configuration are set as module-level properties. See the GitHub Security Advisory GHSA-882j-4vj5-7vmj and the remediation commits 7a2bf8b and cc1ba03.
// Patch excerpt from src/engines/deepl.js - stricter key suffix check
export default {
needkey: true,
fetch: ({ key, from, to, text }) => {
- const suffix = /:fx$/.test(key) ? "-free" : "";
+ const suffix = key.endsWith(":fx") ? "-free" : "";
text = encodeURIComponent(text);
return [
`https://api${suffix}.deepl.com/v2/translate?auth_key=${key}&source_lang=${from}&target_lang=${to}&text=${text}`,
// Source: https://github.com/franciscop/translate/commit/7a2bf8b9f05f7c45c09683973ef4d8e995804aa4
Workarounds
- Construct a sanitized options object on the server side and copy only from and to from user input before calling translate().
- Disable the shared cache or scope caches per authenticated user if upgrading immediately is not possible.
- Place a validation layer in front of translation endpoints that rejects unexpected properties on the options payload.
# Upgrade the vulnerable package
npm install translate@^3.0.0
npm audit --production
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

