Vulnerability: Exposure of Sensitive Information to an Unauthorized Actor in GitHub repository polonel/trudesk prior to 1.2.3.
Vulnerability ID: CVE-2022-1893
CWE: CWE-200
Severity score: 2.9
Project: https://github.com/polonel/trudesk
Published: 2022-05-31
File: src/controllers/main.js
Commit message: fix(core): image data removal
Commit author: Chris Brame

Vulnerable version (before fix):
 mainController.uploadFavicon = function (req, res) {     }      if (!fs.existsSync(object.filePath)) return res.status(400).send('File failed to save to disk')      settingUtil.setSetting('gen:customfavicon', true, function (err) {       if (err) return res.status(400).send('Failed to save setting to database') mainController.uploadLogo = function (req, res) {     }      if (!fs.existsSync(object.filePath)) return res.status(400).send('File failed to save to disk')      settingUtil.setSetting('gen:customlogo', true, function (err) {       if (err) return res.status(400).send('Failed to save setting to database') mainController.uploadPageLogo = function (req, res) {     }      if (!fs.existsSync(object.filePath)) return res.status(400).send('File failed to save to disk')      settingUtil.setSetting('gen:custompagelogo', true, function (err) {       if (err) return res.status(400).send('Failed to save setting to database')

Fixed version (after fix):
 mainController.uploadFavicon = function (req, res) {     }      if (!fs.existsSync(object.filePath)) return res.status(400).send('File failed to save to disk')     if (path.extname(object.filename) === '.jpg' || path.extname(object.filename) === '.jpeg') {       require('../helpers/utils').stripExifData(object.filePath)     }      settingUtil.setSetting('gen:customfavicon', true, function (err) {       if (err) return res.status(400).send('Failed to save setting to database') mainController.uploadLogo = function (req, res) {     }      if (!fs.existsSync(object.filePath)) return res.status(400).send('File failed to save to disk')     if (path.extname(object.filename) === '.jpg' || path.extname(object.filename) === '.jpeg') {       require('../helpers/utils').stripExifData(object.filePath)     }      settingUtil.setSetting('gen:customlogo', true, function (err) {       if (err) return res.status(400).send('Failed to save setting to database') mainController.uploadPageLogo = function (req, res) {     }      if (!fs.existsSync(object.filePath)) return res.status(400).send('File failed to save to disk')     if (path.extname(object.filename) === '.jpg' || path.extname(object.filename) === '.jpeg') {       require('../helpers/utils').stripExifData(object.filePath)     }      settingUtil.setSetting('gen:custompagelogo', true, function (err) {       if (err) return res.status(400).send('Failed to save setting to database')

Patch:
patch: @@ -655,6 +655,9 @@ mainController.uploadFavicon = function (req, res) {
     }
 
     if (!fs.existsSync(object.filePath)) return res.status(400).send('File failed to save to disk')
+    if (path.extname(object.filename) === '.jpg' || path.extname(object.filename) === '.jpeg') {
+      require('../helpers/utils').stripExifData(object.filePath)
+    }
 
     settingUtil.setSetting('gen:customfavicon', true, function (err) {
       if (err) return res.status(400).send('Failed to save setting to database')
@@ -727,6 +730,9 @@ mainController.uploadLogo = function (req, res) {
     }
 
     if (!fs.existsSync(object.filePath)) return res.status(400).send('File failed to save to disk')
+    if (path.extname(object.filename) === '.jpg' || path.extname(object.filename) === '.jpeg') {
+      require('../helpers/utils').stripExifData(object.filePath)
+    }
 
     settingUtil.setSetting('gen:customlogo', true, function (err) {
       if (err) return res.status(400).send('Failed to save setting to database')
@@ -800,6 +806,9 @@ mainController.uploadPageLogo = function (req, res) {
     }
 
     if (!fs.existsSync(object.filePath)) return res.status(400).send('File failed to save to disk')
+    if (path.extname(object.filename) === '.jpg' || path.extname(object.filename) === '.jpeg') {
+      require('../helpers/utils').stripExifData(object.filePath)
+    }
 
     settingUtil.setSetting('gen:custompagelogo', true, function (err) {
       if (err) return res.status(400).send('Failed to save setting to database')
path: src/controllers/main.js