CVE-2024-31454 (published 2024-04-09T18:15Z)

PsiTransfer is an open source, self-hosted file sharing solution. Prior to version 2.2.0, the absence of restrictions on the endpoint, which is designed for uploading files, allows an attacker who received the id of a file distribution to change the files that are in this distribution. The vulnerability allows an attacker to influence those users who come to the file distribution after them and slip the victim files with a malicious or phishing signature. Version 2.2.0 contains a patch for this issue.\n\nCVE-2024-31454 allows users to violate the integrity of a file that is uploaded by another user. In this case, additional files are not loaded into the file bucket. Violation of integrity at the level of individual files. While the vulnerability with the number CVE-2024-31453 allows users to violate the integrity of a file bucket without violating the integrity of files uploaded by other users. Thus, vulnerabilities are reproduced differently, require different security recommendations and affect different objects of the application’s business logic.


Weakness information:
cwe_id: NVD-CWE-noinfo
cwe_name: Insufficient Information
description: There is insufficient information about the issue to classify it; details are unkown or unspecified.
extended_description: Insufficient Information

Fix information:
repo_url: https://github.com/psi-4ward/psitransfer
commit_details: repo_url: https://github.com/psi-4ward/psitransfer
author: Christoph Wiechert
author_date: 2024-04-05 12:23:11+02:00
msg: Lock the bucket when the files upload completes
repository: repo_url: https://github.com/psi-4ward/psitransfer
repo_name: psi-4ward/psitransfer
description: Simple open source self-hosted file sharing solution.  
repo_language: JavaScript
owner: psi-4ward
file_changes: filename: upload.js
change_type: ModificationType.MODIFY
diff: @@ -231,7 +231,10 @@ export default {
                   progress: { percentage: 100, humanFileSize: file.humanSize, bytesUploaded: file._File.size }
                 }
               });
-              if (state.files.every(f => f.uploaded)) commit('STATE', 'uploaded', { root: true });
+              if (state.files.every(f => f.uploaded)) {
+                fetch(state.uploadURI + '/' + state.sid + '?lock=yes', { method: 'PATCH' });
+                commit('STATE', 'uploaded', { root: true });
+              }
             }
           }).start();
         }

programming_language: TypeScript
filename: db.js
change_type: ModificationType.MODIFY
diff: @@ -132,6 +132,19 @@ module.exports = class DB {
     await this.store.update(`${ sid }++${ key }`, file);
   }
 
+  async lock(sid) {
+    const files = this.get(sid);
+    if(!files) return;
+    await Promise.all(files.map(async file => {
+      await this.updateMetadata(sid, file.key, { buckedLocked: true });
+    }));
+  }
+
+  isLocked(sid) {
+    const files = this.get(sid);
+    if(!files) return false;
+    return files.some(file => file.metadata.buckedLocked);
+  }
 
   get(sid) {
     return this.db[sid];

programming_language: TypeScript
filename: endpoints.js
change_type: ModificationType.MODIFY
diff: @@ -332,11 +332,25 @@ app.use(`${ config.uploadAppPath }files`,
 
     if (req.method === 'GET') return res.status(405).end();
 
-    // Restrict upload to a file which upload completed already
+    // Lock bucket by PATCH /files/:sid?lock=yes
+    const fid = req.path.substring(1);
+    if(!fid.includes('++') && req.method === 'PATCH' && req.query.lock) {
+      await db.lock(fid);
+      return res.status(204).end('Bucket locked');
+    }
+
     if(['POST', 'PATCH'].includes(req.method)) {
+      // Restrict upload to the bucket if it is locked
+      if(!fid.includes('++') && db.isLocked(fid)) {
+        return res.status(400).end('Bucket locked');
+      }
       try {
-        const fid = req.url.substring(1);
         const info = await store.info(fid);
+        // Restrict upload to the bucket if it is locked
+        if(info.metadata.locked) {
+          return res.status(400).end('Bucket locked');
+        }
+        // Restrict upload to a file which upload completed already
         if(!info.isPartial) {
           return res.status(400).end('Upload already completed');
         }
@@ -363,6 +377,11 @@ app.use(`${ config.uploadAppPath }files`,
         const uploadLength = req.get('Upload-Length');
         assert(uploadLength, 'missing Upload-Length header');
 
+        // Restrict creating new files for locked buckets
+        if(db.isLocked(meta.sid)) {
+          return res.status(400).end('Bucket locked');
+        }
+
         meta.uploadLength = uploadLength;
         meta.key = uuid();
         meta.createdAt = Date.now().toString();

programming_language: TypeScript