CVE-2022-46165: Github.com/syncthing/syncthing Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-9rp6-23gf-4c3h
CVSS 4.6
CWE-79
Published
Advisory Summary

CVE-2022-46165 is a MODERATE (CVSS 4.6) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Github.com/syncthing/syncthing libraries in the Go ecosystem. The issue involves syncthing vulnerable to cross-site scripting (xss) in web gui. Remediation is available by upgrading affected packages to version 1.23.5.

CVE-2022-46165 at a Glance

CVE Identifier CVE-2022-46165
GHSA Identifier GHSA-9rp6-23gf-4c3h
Severity MODERATE
CVSS v3.1 Base Score 4.6
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Github.com/syncthing/syncthing
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 4.6

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2022-46165

To remediate this vulnerability, upgrade all affected Github.com/syncthing/syncthing dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/syncthing/syncthing fixed: 1.23.5
Upgrade github.com/syncthing/syncthing to 1.23.5
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/syncthing/syncthing

How to Check if You Are Affected

To determine whether your application is affected by CVE-2022-46165, inspect your project dependencies for Github.com/syncthing/syncthing:

inspect dependencies for github.com/syncthing/syncthing

Analyze the terminal output to locate any version of Github.com/syncthing/syncthing in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.23.5), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Github.com/syncthing/syncthing, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Impact 1. A compromised instance with shared folders could sync malicious files which contain arbitrary HTML and JavaScript in the name. If the owner of another device looks over the shared folder settings and moves the mouse over the latest sync, a script could be executed to change settings for shared folders or add devices automatically. 2. Adding a new device with a malicious name could embed HTML or JavaScript inside parts of the page. ## Risk As long as trusted devices are used, the risk is low. Additionally, the web GUI is not used that often in daily use which reduces the likelihood of exploitation. ## Details ### 1. Field "Latest Change" * Open the web GUI at [http://127.0.0.1:8384/](http://127.0.0.1:8384/). * Create/Delete a file named ```<img src=a onerror=alert(123)>``` and sync it to the other instance. * Move your mouse over the latest change to trigger the tooltip. <img width="834" alt="latest-change" src="https://user-images.githubusercontent.com/9484134/205084362-20a8ec13-a88d-469f-bdf1-e5291c20f4c1.png"> ##### Web browser source ```html <span tooltip="" data-original-title="\&quot;><img src=a onerror=alert(123)> @ 2022-11-30 16:58:43" aria-describedby="tooltip409527"> <!-- ngIf: !folderStats[folder.id].lastFile.deleted --><span translate="" translate-value-file="&quot;><img src=a onerror=alert(123)>" ng-if="!folderStats[folder.id].lastFile.deleted" class="ng-scope">Updated "&gt;&lt;img src=a onerror=alert(123)&gt;</span> <!-- end ngIf: !folderStats[folder.id].lastFile.deleted --> <!-- ngIf: folderStats[folder.id].lastFile.deleted --> </span> <div class="tooltip fade top in" role="tooltip" id="tooltip409527" style="top: 446.033px; left: 318.3px; display: block;"> <div class="tooltip-arrow" style="left: 50%;"></div> <div class="tooltip-inner">\"&gt;<img src="a" onerror="alert(123)"> @ 2022-11-30 16:58:43</div> </div> ``` ##### Corresponding code in the project File ````gui/default/index.html````: ```html <tr ng-if="folder.type != 'sendonly' && folder.type != 'receiveencrypted' && folderStats[folder.id].lastFile && folderStats[folder.id].lastFile.filename"> <th><span class="fas fa-fw fa-exchange-alt"></span>&nbsp;<span translate>Latest Change</span></th> <td class="text-right"> <span tooltip data-original-title="{{folderStats[folder.id].lastFile.filename}} @ {{folderStats[folder.id].lastFile.at | date:'yyyy-MM-dd HH:mm:ss'}}"> <span translate translate-value-file="{{folderStats[folder.id].lastFile.filename | basename}}" ng-if="!folderStats[folder.id].lastFile.deleted">Updated {%file%}</span> <span translate translate-value-file="{{folderStats[folder.id].lastFile.filename | basename}}" ng-if="folderStats[folder.id].lastFile.deleted">Deleted {%file%}</span> </span> </td> </tr> ``` File ````gui/default/syncthing/core/tooltipDirective.js````: ```javascript angular.module('syncthing.core') .directive('tooltip', function () { return { restrict: 'A', link: function (scope, element, attributes) { $(element).tooltip({ html: 'true' }); } }; }); ``` The attribute ```html``` should not be set to ```true``` or input sanitized. ### 2. Field "Shared With" * Open the web GUI at [http://127.0.0.1:8384/](http://127.0.0.1:8384/). * Create a device with the following name ```fedora 1"'><h1>Headline</h1><img src=x><script>alert(1)</script>```. * Add the device to another instance and share a folder. * Move your mouse over the malicious device name to trigger the tooltip. <img width="608" alt="shared-with-1" src="https://user-images.githubusercontent.com/9484134/205084172-8cab2d0e-3257-46d5-be81-41fbd7228e0c.png"> ##### Web browser source ```html <span tooltip="" data-original-title="fedora 1&quot;'><h1>Headline</h1><img src=x><script>alert(1)</script> " ng-bind-html="sharesFolder(folder)" class="ng-binding" aria-describedby="tooltip348410">fedora 1"'&gt;<h1>Headline </h1><img src="x"></span> <div class="tooltip fade top" role="tooltip" id="tooltip348410" style="top: 0px; left: 0px; display: block;"> <div class="tooltip-arrow" style="left: 50%;"></div> <div class="tooltip-inner">fedora 1"'&gt;<h1>Headline</h1><img src="x"> <script>alert(1)</script> </div> </div> ``` ##### Corresponding code in the project File ````gui/default/index.html````: ```html <tr> <th><span class="fas fa-fw fa-share-alt"></span>&nbsp;<span translate>Shared With</span></th> <td class="text-right"> <span tooltip data-original-title="{{sharesFolder(folder)}} {{folderHasUnacceptedDevices(folder) ? '<br/>(<sup>1</sup>' + ('The remote device has not accepted sharing this folder.' | translate) + ')' : ''}} {{folderHasPausedDevices(folder) ? '<br/>(<sup>2</sup>' + ('The remote device has paused this folder.' | translate) + ')' : ''}}" ng-bind-html="sharesFolder(folder)"></span> </td> </tr> ``` File ````gui/default/syncthing/core/tooltipDirective.js````: ```javascript angular.module('syncthing.core') .directive('tooltip', function () { return { restrict: 'A', link: function (scope, element, attributes) { $(element).tooltip({ html: 'true' }); } }; }); ``` The attribute ```html``` should not be set to ```true``` or input sanitized. ##### HTML Injection in "Edit Folder" <img width="672" alt="shared-with-2" src="https://user-images.githubusercontent.com/9484134/205084067-b33f8536-e350-4de1-86f6-3d4a12a683c3.png">

CVE-2022-46165 Affected Github.com/syncthing/syncthing Versions

1 component(s)
Fixed Versions:
1.23.5
Product / Package Ecosystem Affected Versions Fixed Version
github.com/syncthing/syncthing
Go
< 1.23.5
1.23.5

References

Frequently Asked Questions

What is CVE-2022-46165?
CVE-2022-46165 is a security vulnerability in Github.com/syncthing/syncthing involving syncthing vulnerable to Cross-site Scripting (XSS) in Web GUI under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Github.com/syncthing/syncthing versions are affected?
Affected versions include releases prior to 1.23.5 across affected packages: github.com/syncthing/syncthing.
What version fixes CVE-2022-46165?
Upgrading to 1.23.5 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/syncthing/syncthing affected?
Yes, github.com/syncthing/syncthing is affected in releases prior to 1.23.5. Upgrade your dependency to 1.23.5 or later.
What is the CVSS score of CVE-2022-46165?
CVE-2022-46165 has a CVSS v3.1 base score of 4.6 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:N.
What CWE is associated with CVE-2022-46165?
CVE-2022-46165 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check Go dependencies for CVE-2022-46165?
Run the dependency tree command: 'inspect dependencies for github.com/syncthing/syncthing'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-9rp6-23gf-4c3h",
  "modified" : "2023-06-06T18:50:28Z",
  "published" : "2023-06-06T16:39:57Z",
  "aliases" : [ "CVE-2022-46165" ],
  "summary" : "syncthing vulnerable to Cross-site Scripting (XSS) in Web GUI",
  "details" : "## Impact\n\n1. A compromised instance with shared folders could sync malicious files which contain arbitrary HTML and JavaScript in the name.\nIf the owner of another device looks over the shared folder settings and moves the mouse over the latest sync, a script could be executed to change settings for shared folders or add devices automatically.\n\n2. Adding a new device with a malicious name could embed HTML or JavaScript inside parts of the page.\n\n## Risk\n\nAs long as trusted devices are used, the risk is low.\nAdditionally, the web GUI is not used that often in daily use which reduces the likelihood of exploitation.\n\n## Details\n\n### 1. Field \"Latest Change\"\n\n* Open the web GUI at [http://127.0.0.1:8384/](http://127.0.0.1:8384/).\n* Create/Delete a file named ```<img src=a onerror=alert(123)>``` and sync it to the other instance.\n* Move your mouse over the latest change to trigger the tooltip.\n\n<img width=\"834\" alt=\"latest-change\" src=\"https://user-images.githubusercontent.com/9484134/205084362-20a8ec13-a88d-469f-bdf1-e5291c20f4c1.png\">\n\n##### Web browser source\n```html\n<span tooltip=\"\" data-original-title=\"\\&quot;><img src=a onerror=alert(123)> @ 2022-11-30 16:58:43\"\n    aria-describedby=\"tooltip409527\">\n    <!-- ngIf: !folderStats[folder.id].lastFile.deleted --><span translate=\"\"\n        translate-value-file=\"&quot;><img src=a onerror=alert(123)>\" ng-if=\"!folderStats[folder.id].lastFile.deleted\"\n        class=\"ng-scope\">Updated \"&gt;&lt;img src=a onerror=alert(123)&gt;</span>\n    <!-- end ngIf: !folderStats[folder.id].lastFile.deleted -->\n    <!-- ngIf: folderStats[folder.id].lastFile.deleted -->\n</span>\n<div class=\"tooltip fade top in\" role=\"tooltip\" id=\"tooltip409527\"\n    style=\"top: 446.033px; left: 318.3px; display: block;\">\n    <div class=\"tooltip-arrow\" style=\"left: 50%;\"></div>\n    <div class=\"tooltip-inner\">\\\"&gt;<img src=\"a\" onerror=\"alert(123)\"> @ 2022-11-30 16:58:43</div>\n</div>\n```\n\n##### Corresponding code in the project \n\nFile ````gui/default/index.html````:\n```html\n<tr ng-if=\"folder.type != 'sendonly' && folder.type != 'receiveencrypted' && folderStats[folder.id].lastFile && folderStats[folder.id].lastFile.filename\">\n    <th><span class=\"fas fa-fw fa-exchange-alt\"></span>&nbsp;<span translate>Latest Change</span></th>\n    <td class=\"text-right\">\n        <span tooltip data-original-title=\"{{folderStats[folder.id].lastFile.filename}} @ {{folderStats[folder.id].lastFile.at | date:'yyyy-MM-dd HH:mm:ss'}}\">\n        <span translate translate-value-file=\"{{folderStats[folder.id].lastFile.filename | basename}}\" ng-if=\"!folderStats[folder.id].lastFile.deleted\">Updated {%file%}</span>\n        <span translate translate-value-file=\"{{folderStats[folder.id].lastFile.filename | basename}}\" ng-if=\"folderStats[folder.id].lastFile.deleted\">Deleted {%file%}</span>\n        </span>\n    </td>\n</tr>\n```\n\nFile ````gui/default/syncthing/core/tooltipDirective.js````:  \n```javascript\nangular.module('syncthing.core')\n    .directive('tooltip', function () {\n        return {\n            restrict: 'A',\n            link: function (scope, element, attributes) {\n                $(element).tooltip({\n                    html: 'true'\n                });\n            }\n        };\n    });\n```\n\nThe attribute ```html``` should not be set to ```true``` or input sanitized.\n\n### 2. Field \"Shared With\"\n\n* Open the web GUI at [http://127.0.0.1:8384/](http://127.0.0.1:8384/).\n* Create a device with the following name ```fedora 1\"'><h1>Headline</h1><img src=x><script>alert(1)</script>```.\n* Add the device to another instance and share a folder.\n* Move your mouse over the malicious device name to trigger the tooltip.\n \n<img width=\"608\" alt=\"shared-with-1\" src=\"https://user-images.githubusercontent.com/9484134/205084172-8cab2d0e-3257-46d5-be81-41fbd7228e0c.png\">\n\n\n##### Web browser source  \n\n```html\n<span tooltip=\"\" data-original-title=\"fedora 1&quot;'><h1>Headline</h1><img src=x><script>alert(1)</script>  \"\n    ng-bind-html=\"sharesFolder(folder)\" class=\"ng-binding\" aria-describedby=\"tooltip348410\">fedora 1\"'&gt;<h1>Headline\n    </h1><img src=\"x\"></span>\n<div class=\"tooltip fade top\" role=\"tooltip\" id=\"tooltip348410\" style=\"top: 0px; left: 0px; display: block;\">\n    <div class=\"tooltip-arrow\" style=\"left: 50%;\"></div>\n    <div class=\"tooltip-inner\">fedora 1\"'&gt;<h1>Headline</h1><img src=\"x\">\n        <script>alert(1)</script>\n    </div>\n</div>\n```\n\n##### Corresponding code in the project \n\nFile ````gui/default/index.html````:\n\n```html\n<tr>\n    <th><span class=\"fas fa-fw fa-share-alt\"></span>&nbsp;<span translate>Shared With</span></th>\n    <td class=\"text-right\">\n        <span tooltip data-original-title=\"{{sharesFolder(folder)}} {{folderHasUnacceptedDevices(folder) ? '<br/>(<sup>1</sup>' + ('The remote device has not accepted sharing this folder.' | translate) + ')' : ''}} {{folderHasPausedDevices(folder) ? '<br/>(<sup>2</sup>' + ('The remote device has paused this folder.' | translate) + ')' : ''}}\" ng-bind-html=\"sharesFolder(folder)\"></span>\n    </td>\n</tr>\n```\n\nFile ````gui/default/syncthing/core/tooltipDirective.js````:  \n\n```javascript\nangular.module('syncthing.core')\n    .directive('tooltip', function () {\n        return {\n            restrict: 'A',\n            link: function (scope, element, attributes) {\n                $(element).tooltip({\n                    html: 'true'\n                });\n            }\n        };\n    });\n```\n\nThe attribute ```html``` should not be set to ```true``` or input sanitized.\n\n##### HTML Injection in \"Edit Folder\"\n\n<img width=\"672\" alt=\"shared-with-2\" src=\"https://user-images.githubusercontent.com/9484134/205084067-b33f8536-e350-4de1-86f6-3d4a12a683c3.png\">\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/syncthing/syncthing"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.23.5"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/syncthing/syncthing/security/advisories/GHSA-9rp6-23gf-4c3h"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-46165"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/syncthing/syncthing/commit/73c52eafb6566435dffd979c3c49562b6d5a4238"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/syncthing/syncthing/commit/f5e5af391a6583047c64ef8c51642003a79b75cf"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/syncthing/syncthing"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/syncthing/syncthing/releases/tag/v1.23.5"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/IRYGBFJPVBW6PPTETNIBWQJE4HJSA5PJ"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/XEBWSQVGHSTR4ZO7LVVEMPEGMV2DS5XR"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-06-06T16:39:57Z",
    "nvd_published_at" : "2023-06-06T18:15:10Z"
  }
}