jeremylong / Open-Vulnerability-Project

Java libraries for working with available vulnerability data sources (GitHub Security Advisories, NVD, EPSS, CISA Known Exploited Vulnerabilities, etc.)
Apache License 2.0
107 stars 30 forks source link

Use force getBodyBytes #177

Closed re3turn closed 2 weeks ago

re3turn commented 2 weeks ago

NVD descriptions are often in UTF-8. Apache HttpClient's getBodyText will encode using StandardCharsets.US_ASCII if charset is not set, which can result in UTF-8 strings being corrupted.

https://github.com/apache/httpcomponents-client/blob/cc13243cd39426ba34f8da04d5f2200e02734289/httpclient5/src/main/java/org/apache/hc/client5/http/async/methods/SimpleBody.java#L83-L90

For this reason, we do not use getBodyText but instead use getBodyBytes to encode to UTF-8.

$ java -jar vulnz/build/libs/vulnz-6.1.0.jar cve --cveId CVE-2024-5662 --prettyPrint > CVE-2024-5662_after.json
$ diff CVE-2024-5662_before.json CVE-2024-5662_after.json
--- CVE-2024-5662_before.json   2024-07-01 03:05:46.088898445 +0900
+++ CVE-2024-5662_after.json    2024-07-01 03:01:21.652682427 +0900
@@ -8,10 +8,10 @@
     "cveTags" : [ ],
     "descriptions" : [ {
       "lang" : "en",
-      "value" : "The Ultimate Post Kit Addons For Elementor ��� (Post Grid, Post Carousel, Post Slider, Category List, Post Tabs, Timeline, Post Ticker, Tag Cloud) plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the ���url��� parameter within the Social Count (Static) widget in all versions up to, and including, 3.11.7 due to insufficient input sanitization and output escaping. This makes it possible for authenticated attackers, with Contributor-level access and above, to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page."
+      "value" : "The Ultimate Post Kit Addons For Elementor – (Post Grid, Post Carousel, Post Slider, Category List, Post Tabs, Timeline, Post Ticker, Tag Cloud) plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the ‘url’ parameter within the Social Count (Static) widget in all versions up to, and including, 3.11.7 due to insufficient input sanitization and output escaping. This makes it possible for authenticated attackers, with Contributor-level access and above, to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page."
     }, {
       "lang" : "es",
-      "value" : "Los complementos Ultimate Post Kit Addons For Elementor (Post Grid, Post Carousel, Post Slider, Category List, Post Tabs, Timeline, Post Ticker, Tag Cloud) para WordPress es vulnerable a Cross-Site Scripting Almacenado a trav��s del par��metro 'url' dentro el widget Social Count (Static) en todas las versiones hasta la 3.11.7 incluida debido a una sanitizaci��n de entrada y un escape de salida insuficientes. Esto hace posible que atacantes autenticados, con acceso de nivel de Colaborador y superior, inyecten scripts web arbitrarios en p��ginas que se ejecutar��n cada vez que un usuario acceda a una p��gina inyectada."
+      "value" : "Los complementos Ultimate Post Kit Addons For Elementor (Post Grid, Post Carousel, Post Slider, Category List, Post Tabs, Timeline, Post Ticker, Tag Cloud) para WordPress es vulnerable a Cross-Site Scripting Almacenado a través del parámetro 'url' dentro el widget Social Count (Static) en todas las versiones hasta la 3.11.7 incluida debido a una sanitización de entrada y un escape de salida insuficientes. Esto hace posible que atacantes autenticados, con acceso de nivel de Colaborador y superior, inyecten scripts web arbitrarios en páginas que se ejecutarán cada vez que un usuario acceda a una página inyectada."
     } ],
     "metrics" : {
       "cvssMetricV31" : [ {
jeremylong commented 2 weeks ago

Thank you for the PR - and the explanation.