Descrizione
joi is a schema description language and data validator for JavaScript. From 16.0.0 until 17.13.5 and 18.2.4, joi's lib/types/keys.js internals.rename() implementation used by object().rename() permits a schema that renames keys with a regular-expression source and a Joi.expression() or Joi.x() target that interpolates the pattern's own match data, combined with { multiple: true }, to derive a target from an attacker-controlled input key. An attacker can send x-__proto__ with an object value, causing the target to render as __proto__ and set the prototype of the object returned by validate() instead of creating an own key. The global Object.prototype is not modified, so the effect is confined to the object returned by that validation call. Static-string targets and schemas using the default { multiple: false } are not affected. This issue is fixed in versions 17.13.5 and 18.2.4.
Tipo di vulnerabilità
CWE-1321
Prototype pollution: modifica non controllata del prototipo di un oggetto
Il prodotto riceve dall’esterno gli attributi da impostare in un oggetto, ma non impedisce che vengano modificati anche quelli del suo prototipo, alterando il comportamento di tutta l’applicazione (tipico di JavaScript).
Impatto sui sistemi
| Ambito | Impatto |
| Riservatezza, Integrità, Disponibilità |
Leggere i dati dell’applicazione, Modificare i dati dell’applicazione |
| Disponibilità |
Interruzione del servizio: arresto o riavvio |
Come si previene
Sviluppo
By freezing the object prototype first (for example, Object.freeze(Object.prototype)), modification of the prototype becomes impossible.
Architettura e progettazione
By blocking modifications of attributes that resolve to object prototype, such as proto or prototype, this weakness can be mitigated.
Sviluppo · Validazione dell’input
When handling untrusted objects, validating using a schema can be used.
Sviluppo
By using an object without prototypes (via Object.create(null) ), adding object prototype attributes by accessing the prototype via the special attributes becomes impossible, mitigating this weakness.
Sviluppo
Map can be used instead of objects in most cases. If Map methods are used instead of object attributes, it is not possible to access the object prototype or modify it.
Tutte le 588 CVE di tipo CWE-1321, con andamento e prevenzione