CVE-2024-34714: Insufficient Information (NVD-CWE-noinfo)
value: The Hoppscotch Browser Extension is a browser extension for Hoppscotch, a community-driven end-to-end open-source API development ecosystem. Due to an oversight during a change made to the extension in the commit d4e8e4830326f46ba17acd1307977ecd32a85b58, a critical check for the origin list was missed and allowed for messages to be sent to the extension which the extension gladly processed and responded back with the results of, while this wasn't supposed to happen and be blocked by the origin not being present in the origin list.

This vulnerability exposes Hoppscotch Extension users to sites which call into Hoppscotch Extension APIs internally. This fundamentally allows any site running on the browser with the extension installed to bypass CORS restrictions if the user is running extensions with the given version. This security hole was patched in the commit 7e364b928ab722dc682d0fcad713a96cc38477d6 which was released along with the extension version `0.35`. As a workaround, Chrome users can use the Extensions Settings to disable the extension access to only the origins that you want. Firefox doesn't have an alternative to upgrading to a fixed version.
CWE description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
Published: 2024-05-14T16:17Z
Repository: https://github.com/hoppscotch/hoppscotch-extension
Language: JSON
Files changed: manifest.common.json, package.json, src/contentScript.ts, src/hookContent.js
Commit date: 2024-05-06 20:44:58 +0530
Commit message: fix: disable postMessage from unknown origin (#295)


Diff: diff --git a/manifest.common.json b/manifest.common.json
index 46d4e81..67d7d7a 100644
--- a/manifest.common.json
+++ b/manifest.common.json
@@ -1,9 +1,9 @@
 {
   "manifest_version": 3,
   "name": "Hoppscotch Browser Extension",
-  "version": "0.34",
+  "version": "0.35",
   "description": "Provides more capabilities for Hoppscotch",
   "icons": {
     "16": "icons/icon-16x16.png",
     "48": "icons/icon-48x48.png",
     "128": "icons/icon-128x128.png"
diff --git a/package.json b/package.json
index 76252c9..7279c9d 100644
--- a/package.json
+++ b/package.json
@@ -1,8 +1,8 @@
 {
   "name": "hoppscotch-extension",
-  "version": "0.34.0",
+  "version": "0.35.0",
   "description": "Provides more features to the Hoppscotch webapp (https://hoppscotch.io/)",
   "scripts": {
     "clean": "rimraf dist .parcel-cache",
     "build:chrome": "HOPP_EXTENSION_TARGET=CHROME parcel build src/* --dist-dir dist/ && copyfiles icons/* dist",
     "build:firefox": "HOPP_EXTENSION_TARGET=FIREFOX parcel build src/* --dist-dir dist/ && copyfiles icons/* dist"
diff --git a/src/contentScript.ts b/src/contentScript.ts
index b54ea3c..7222fcb 100644
--- a/src/contentScript.ts
+++ b/src/contentScript.ts
@@ -71,12 +71,19 @@ function main() {
     if (changes.originList && changes.originList.newValue) {
       injectHoppExtensionHook()
     }
   })
 
-  window.addEventListener("message", (ev) => {
-    if (ev.source !== window || !ev.data) {
+  window.addEventListener("message", async (ev) => {
+    const originList = await getOriginList()
+    let url = new URL(window.location.href)
+
+    const originType = originList.includes(url.origin)
+      ? "VALID_ORIGIN"
+      : "UNKNOWN_ORIGIN"
+
+    if (ev.source !== window || !ev.data || originType != "VALID_ORIGIN") {
       return
     }
 
     if (ev.data.type === "__POSTWOMAN_EXTENSION_REQUEST__") {
       chrome.runtime.sendMessage(
diff --git a/src/hookContent.js b/src/hookContent.js
index c54c221..ebe8314 100644
--- a/src/hookContent.js
+++ b/src/hookContent.js
@@ -34,11 +34,11 @@
       status: "available",
     })
   }
 
   window.__POSTWOMAN_EXTENSION_HOOK__ = {
-    getVersion: () => ({ major: 0, minor: 34 }),
+    getVersion: () => ({ major: 0, minor: 35 }),
 
     decodeB64ToArrayBuffer: (input, ab) => {
       const keyStr =
         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
 

Vulnerable code:   "version": "0.34",
  "version": "0.34.0",
  window.addEventListener("message", (ev) => {
    if (ev.source !== window || !ev.data) {
    getVersion: () => ({ major: 0, minor: 34 }),
Fixed code:   "version": "0.35",
  "version": "0.35.0",
  window.addEventListener("message", async (ev) => {
    const originList = await getOriginList()
    let url = new URL(window.location.href)

    const originType = originList.includes(url.origin)
      ? "VALID_ORIGIN"
      : "UNKNOWN_ORIGIN"

    if (ev.source !== window || !ev.data || originType != "VALID_ORIGIN") {
    getVersion: () => ({ major: 0, minor: 35 }),