Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
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 applicationsLearn about Improper Input Validation vulnerabilities in an interactive lesson.
Start learningUpgrade translate
to version 3.0.0 or higher.
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.
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"}}