CVE-2022-1893: Improper Removal of Sensitive Information Before Storage or Transfer (CWE-212)
value: Improper Removal of Sensitive Information Before Storage or Transfer in GitHub repository polonel/trudesk prior to 1.2.3.
CWE description: The product stores, transfers, or shares a resource that contains sensitive information, but it does not properly remove that information before the product makes the resource available to unauthorized actors.
CVSS v3 base score: 5.3
Published: 2022-05-31T22:15Z
Repository: https://github.com/polonel/trudesk
Language: JavaScript
Files changed: src/controllers/main.js
Commit date: 2022-05-28 04:12:16 -0400
Commit message: fix(core): image data removal
Diff: diff --git a/src/controllers/main.js b/src/controllers/main.js
index 62c4e840c..aad770b17 100644
--- a/src/controllers/main.js
+++ b/src/controllers/main.js
@@ -653,10 +653,13 @@ mainController.uploadFavicon = function (req, res) {
     if (_.isUndefined(object.filePath) || _.isUndefined(object.filename)) {
       return res.status(400).send('Invalid image data')
     }
 
     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')
 
       settingUtil.setSetting('gen:customfaviconfilename', object.filename, function (err) {
@@ -725,10 +728,13 @@ mainController.uploadLogo = function (req, res) {
     if (_.isUndefined(object.filePath) || _.isUndefined(object.filename)) {
       return res.status(400).send('Invalid image data')
     }
 
     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')
 
       settingUtil.setSetting('gen:customlogofilename', object.filename, function (err) {
@@ -798,10 +804,13 @@ mainController.uploadPageLogo = function (req, res) {
     if (_.isUndefined(object.filePath) || _.isUndefined(object.filename)) {
       return res.status(400).send('Invalid image data')
     }
 
     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')
 
       settingUtil.setSetting('gen:custompagelogofilename', object.filename, function (err) {

Fixed code:     if (path.extname(object.filename) === '.jpg' || path.extname(object.filename) === '.jpeg') {
      require('../helpers/utils').stripExifData(object.filePath)
    }
    if (path.extname(object.filename) === '.jpg' || path.extname(object.filename) === '.jpeg') {
      require('../helpers/utils').stripExifData(object.filePath)
    }
    if (path.extname(object.filename) === '.jpg' || path.extname(object.filename) === '.jpeg') {
      require('../helpers/utils').stripExifData(object.filePath)
    }