CVE-2022-2818 (published 2022-08-15T11:21Z)

Improper Removal of Sensitive Information Before Storage or Transfer in GitHub repository cockpit-hq/cockpit prior to 2.2.2.\n\n

CVSS v3 base score: 8.8, HIGH (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: CWE-212
cwe_name: Improper Removal of Sensitive Information Before Storage or Transfer
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.
extended_description: 
            Resources that may contain sensitive data include documents, packets, messages, databases, etc. While this data may be useful to an individual user or small set of users who share the resource, it may need to be removed before the resource can be shared outside of the trusted group. The process of removal is sometimes called cleansing or scrubbing.
            For example, a product for editing documents might not remove sensitive data such as reviewer comments or the local pathname where the document is stored. Or, a proxy might not remove an internal IP address from headers before making an outgoing request to an Internet site.
         
         

Fix information:
repo_url: https://github.com/cockpit-hq/cockpit
commit_details: repo_url: https://github.com/cockpit-hq/cockpit
author: Artur Heinze
author_date: 2022-08-12 16:54:25+02:00
msg: Fix exposing 2FA secret in JWT token on login
repository: repo_url: https://github.com/cockpit-hq/cockpit
repo_name: Cockpit-HQ/Cockpit
description: Cockpit Core - Content Platform
repo_language: PHP
owner: cockpit-hq
file_changes: filename: CHANGELOG.md
change_type: ModificationType.MODIFY
diff: @@ -4,6 +4,7 @@
 ## WIP
 
 - Add `./tower app:update` cli command to update Cockpit to the latest or specific version
+- Fix exposing 2FA secret in JWT token on login
 
 ## 2.2.1 (2022-08-10)
 

programming_language: Markdown
filename: Auth.php
change_type: ModificationType.MODIFY
diff: @@ -78,21 +78,29 @@ class Auth extends Base {
 
             if (isset($user['twofa']['enabled']) && $user['twofa']['enabled']) {
 
+                unset($user['twofa']);
+
                 return [
                     'success' => true,
                     'user' => [
                         'name' => $user['name'],
                         'user' => $user['user'],
                         'email' => $user['email'],
-                        'twofa' => $this->helper('jwt')->create($user)
+                        'twofa' => $this->helper('jwt')->create([
+                            '_id'   => $user['_id'],
+                            'user'  => $user['user'],
+                            'name'  => $user['name'],
+                            'email' => $user['email'],
+                            'role'  => $user['role'],
+                        ])
                     ]
                 ];
 
-            } else {
-                // remove twofa settings
-                unset($user['twofa']);
             }
 
+            // remove 2FA settings from user session
+            unset($user['twofa']);
+
             $this->app->trigger('app.user.disguise', [&$user]);
 
             $this->helper('auth')->setUser($user);
@@ -140,4 +148,4 @@ class Auth extends Base {
         return $this->stop(412);
 
     }
-}
\ No newline at end of file
+}

programming_language: PHP