Improper Input Validation Affecting translate package, versions <3.0.0


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    0.05% (17th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-JS-TRANSLATE-6483248
  • published 24 Mar 2024
  • disclosed 22 Mar 2024
  • credit PinkDraconian

How to fix?

Upgrade translate to version 3.0.0 or higher.

Overview

translate is a Translate text to different languages on node.js and the browser

Affected versions of this package are vulnerable to Improper Input Validation due to the manipulation of the second variable of the translate function. An attacker can change the outcome of translation requests made by subsequent users by controlling this variable. The opt.id parameter allows for the overwriting of the cache key, enabling an attacker to set the id variable to a cache key that would be generated by another user, thereby choosing the response that user gets served.

PoC

Server allowing users to supply text and the language to translate to:

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}); });

Payload:

{"text":"I hate you", "language":{"to":"nl","id":"undefined:en:nl:google:I love you"}}

CVSS Scores

version 3.1
Expand this section

Snyk

Recommended
5.3 medium
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Privileges Required (PR)
    None
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    None
  • Integrity (I)
    Low
  • Availability (A)
    None