CVE-2023-3531 (published 2023-07-06T20:15Z)

Cross-site Scripting (XSS) - Stored in GitHub repository nilsteampassnet/teampass prior to 3.0.10.

CVSS v3 base score: 5.4, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N)

Weakness information:
cwe_id: CWE-79
cwe_name: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
description: 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.
extended_description: 
            Cross-site scripting (XSS) vulnerabilities occur when:
            
               Untrusted data enters a web application, typically from a web request.
               The web application dynamically generates a web page that contains this untrusted data.
               During page generation, the application does not prevent the data from containing content that is executable by a web browser, such as JavaScript, HTML tags, HTML attributes, mouse events, Flash, ActiveX, etc.
               A victim visits the generated web page through a web browser, which contains malicious script that was injected using the untrusted data.
               Since the script comes from a web page that was sent by the web server, the victim's web browser executes the malicious script in the context of the web server's domain.
               This effectively violates the intention of the web browser's same-origin policy, which states that scripts in one domain should not be able to access resources or run code in a different domain.
            
            There are three main kinds of XSS:
            
               
                  Type 1: Reflected XSS (or Non-Persistent) - 
         			The server reads data directly from the HTTP request and reflects it back in the HTTP response. Reflected XSS exploits occur when an attacker causes a victim to supply dangerous content to a vulnerable web application, which is then reflected back to the victim and executed by the web browser. The most common mechanism for delivering malicious content is to include it as a parameter in a URL that is posted publicly or e-mailed directly to the victim. URLs constructed in this manner constitute the core of many phishing schemes, whereby an attacker convinces a victim to visit a URL that refers to a vulnerable site. After the site reflects the attacker's content back to the victim, the content is executed by the victim's browser.
               
                  Type 2: Stored XSS (or Persistent) - 
               The application stores dangerous data in a database, message forum, visitor log, or other trusted data store. At a later time, the dangerous data is subsequently read back into the application and included in dynamic content. From an attacker's perspective, the optimal place to inject malicious content is in an area that is displayed to either many users or particularly interesting users. Interesting users typically have elevated privileges in the application or interact with sensitive data that is valuable to the attacker. If one of these users executes malicious content, the attacker may be able to perform privileged operations on behalf of the user or gain access to sensitive data belonging to the user. For example, the attacker might inject XSS into a log message, which might not be handled properly when an administrator views the logs.
            
               
                  Type 0: DOM-Based XSS - 
               In DOM-based XSS, the client performs the injection of XSS into the page; in the other types, the server performs the injection. DOM-based XSS generally involves server-controlled, trusted script that is sent to the client, such as Javascript that performs sanity checks on a form before the user submits it. If the server-supplied script processes user-supplied data and then injects it back into the web page (such as with dynamic HTML), then DOM-based XSS is possible.
            
            
            Once the malicious script is injected, the attacker can perform a variety of malicious activities. The attacker could transfer private information, such as cookies that may include session information, from the victim's machine to the attacker. The attacker could send malicious requests to a web site on behalf of the victim, which could be especially dangerous to the site if the victim has administrator privileges to manage that site. Phishing attacks could be used to emulate trusted web sites and trick the victim into entering a password, allowing the attacker to compromise the victim's account on that web site. Finally, the script could exploit a vulnerability in the web browser itself possibly taking over the victim's machine, sometimes referred to as "drive-by hacking."
            In many cases, the attack can be launched without the victim even being aware of it. Even with careful users, attackers frequently use a variety of methods to encode the malicious portion of the attack, such as URL encoding or Unicode, so the request looks less suspicious.
         
         

Fix information:
repo_url: https://github.com/nilsteampassnet/teampass
commit_details: repo_url: https://github.com/nilsteampassnet/teampass
author: nilsteampassnet
author_date: 2023-07-06 21:16:02+02:00
msg: 3.0.10

Including new time related fields
Improving XSS protection
repository: repo_url: https://github.com/nilsteampassnet/teampass
repo_name: nilsteampassnet/TeamPass
description: Collaborative Passwords Manager
repo_language: PHP
owner: nilsteampassnet
file_changes: filename: functions.js
change_type: ModificationType.MODIFY
diff: @@ -400,9 +400,17 @@ function simplePurifier(
     return DOMPurify.sanitize(
         text
             .replaceAll('&lt;', '<')
+            .replaceAll('&#x3C;', '<')
+            .replaceAll('&#60;', '<')
             .replaceAll('&gt;', '>')
+            .replaceAll('&#x3E;', '>')
+            .replaceAll('&#62;', '>')
             .replaceAll('&amp;', '&')
+            .replaceAll('&#38;', '&')
+            .replaceAll('&#x26;', '&')
             .replaceAll('&quot;', '"')
+            .replaceAll('&#34;;', '"')
+            .replaceAll('&#x22;', '"')
             .replaceAll('&#39;', "'"),
         {USE_PROFILES: {html:bHtml, svg:bSvg, svgFilters: bSvgFilters}}
     );
@@ -458,7 +466,7 @@ function fieldDomPurifierLoop(elementClass)
             $(element).hasClass('purifyHtml') === true ? true : false,
             $(element).hasClass('purifySvg') === true ? true : false,
             $(element).hasClass('purifySvgFilter') === true ? true : false,
-            typeof $(element).data('purify-text') !== undefined ? $(element).data('purify-text') : ''
+            typeof $(element).data('purify-text') !== 'undefined' ? $(element).data('purify-text') : ''
         );
 
         if (purifiedField === false) {
@@ -479,7 +487,11 @@ function fieldDomPurifierLoop(elementClass)
             };
         } else {
             $(element).val(purifiedField);
-            arrFields[$(element).data('field')] = purifiedField;
+            if (typeof $(element).data('field') !== 'undefined') {
+                arrFields[$(element).data('field')] = purifiedField;
+            } else if (typeof $(element).data('field-name') !== 'undefined') {
+                arrFields[$(element).data('field-name')] = purifiedField;
+            }
         }
     });
     

programming_language: JavaScript
filename: install.queries.php
change_type: ModificationType.MODIFY
diff: @@ -431,6 +431,9 @@ if (null !== $post_type) {
                             `encryption_type` VARCHAR(20) NOT NULL DEFAULT 'not_set',
                             `fa_icon` varchar(100) DEFAULT NULL,
                             `item_key` varchar(500) NOT NULL DEFAULT '-1',
+                            `created_at` varchar(30) NULL,
+                            `updated_at` varchar(30) NULL,
+                            `deleted_at` varchar(30) NULL,
                             PRIMARY KEY (`id`),
                             KEY `restricted_inactif_idx` (`restricted_to`,`inactif`)
                             ) CHARSET=utf8;"

programming_language: PHP
filename: upgrade_operations.php
change_type: ModificationType.MODIFY
diff: @@ -87,55 +87,141 @@ $superGlobal = new protect\SuperGlobal\SuperGlobal();
 // Get POST with operation to perform
 $post_operation = filter_input(INPUT_POST, 'type', FILTER_SANITIZE_FULL_SPECIAL_CHARS);
 if (isset($post_operation) === true && empty($post_operation) === false) {
-    // ---->
-    // OPERATION - 20230604_1 - generate key for item_key
+    if ($post_operation === '20230604_1') {
+        // ---->
+        // OPERATION - 20230604_1 - generate key for item_key
+
+        // Get items to treat
+        $rows = mysqli_query(
+            $db_link,
+            "SELECT id FROM ".$pre."items
+            WHERE item_key = '-1'
+            ORDER BY id
+            LIMIT ".$post_nb.";"
+        );
+        // Handle error on query
+        if (!$rows) {
+            echo '[{"finish":"1" , "error":"'.mysqli_error($db_link).'"}]';
+            exit();
+        }
+
+        // Get total of items to treat
+        $total = mysqli_num_rows($rows);
+
+        // Loop on items and update for requested ones
+        if ((int) $total > 0) {
+            while ($row = mysqli_fetch_array($rows, MYSQLI_ASSOC)) {
+                // Gererate a key and update
+                mysqli_query(
+                    $db_link,
+                    "UPDATE `".$pre."items`
+                    SET `item_key` = '".uniqidReal(50)."'
+                    WHERE `id` = ".$row['id'].";"
+                );
+                if (mysqli_error($db_link)) {
+                    echo '[{"finish":"1", "next":"", "error":"MySQL Error! '.addslashes(mysqli_error($db_link)).'"}]';
+                    exit();
+                }
+            }
+        }
+
+        // Manage end of operation
+        if ($total === 0) {
+            $finish = 1;
+        } else {
+            $finish = 0;
+        }
+        // ----<
+    } elseif ($post_operation === 'populateItemsTable_CreatedAt') {
+        $finish = populateItemsTable_CreatedAt($pre, $post_nb);
+    } elseif ($post_operation === 'populateItemsTable_UpdatedAt') {
+        $finish = populateItemsTable_UpdatedAt($pre);
+    } elseif ($post_operation === 'populateItemsTable_DeletedAt') {
+        $finish = populateItemsTable_DeletedAt($pre);
+    }
+}
 
-    // Get items to treat
-    $rows = mysqli_query(
+// Close connection
+mysqli_close($db_link);
+
+
+// Return back
+echo '[{"finish":"'.$finish.'" , "next":"", "error":"", "total":"'.$total.'"}]';
+
+
+
+function populateItemsTable_CreatedAt($pre, $post_nb)
+{
+    global $db_link;
+    // loop on items - created_at
+    $items = mysqli_query(
         $db_link,
-        "SELECT id FROM ".$pre."items
-        WHERE item_key = '-1'
-        ORDER BY id
-        LIMIT ".$post_nb.";"
+        "select i.id as id, ls.date as datetime
+        from `" . $pre . "items` as i
+        inner join `" . $pre . "log_items` as ls on ls.id_item = i.id
+        WHERE ls.action = 'at_creation' AND i.created_at IS NULL
+        LIMIT " . $post_nb.";"
     );
-    // Handle error on query
-    if (!$rows) {
-        echo '[{"finish":"1" , "error":"'.mysqli_error($db_link).'"}]';
-        exit();
+    while ($item = mysqli_fetch_assoc($items)) {
+        if (empty((string) $item['datetime']) === false && is_null($item['datetime']) === false) {
+            // update created_at field
+            mysqli_query(
+                $db_link,
+                "UPDATE `" . $pre . "items` SET created_at = '".$item['datetime']."' WHERE id = ".$item['id']
+            );
+        }
     }
 
-    // Get total of items to treat
-    $total = mysqli_num_rows($rows);
+    // Is it finished?
+    $remainingItems = mysqli_num_rows(
+        mysqli_query(
+            $db_link,
+            "SELECT * FROM `" . $pre . "items` WHERE created_at IS NULL"
+        )
+    );
+    return $remainingItems > 0 ? 0 : 1;
+}
 
-    // Loop on items and update for requested ones
-    if ((int) $total > 0) {
-        while ($row = mysqli_fetch_array($rows, MYSQLI_ASSOC)) {
-            // Gererate a key and update
+function populateItemsTable_UpdatedAt($pre)
+{
+    global $db_link;
+    // loop on items - updated_at
+    $items = mysqli_query(
+        $db_link,
+        "select i.id as id, (select date from " . $pre . "log_items where action = 'at_modification' and id_item=id order by date DESC limit 1) as datetime 
+        from `" . $pre . "items` as i;"
+    );
+    while ($item = mysqli_fetch_assoc($items)) {
+        if (is_null($item['datetime']) === false) {
+            // update updated_at field
             mysqli_query(
                 $db_link,
-                "UPDATE `".$pre."items`
-                SET `item_key` = '".uniqidReal(50)."'
-                WHERE `id` = ".$row['id'].";"
+                "UPDATE `" . $pre . "items` SET updated_at = '".$item['datetime']."' WHERE id = ".$item['id']
             );
-            if (mysqli_error($db_link)) {
-                echo '[{"finish":"1", "next":"", "error":"MySQL Error! '.addslashes(mysqli_error($db_link)).'"}]';
-                exit();
-            }
         }
     }
 
-    // Manage end of operation
-    if ($total === 0) {
-        $finish = 1;
-    } else {
-        $finish = 0;
-    }
-    // ----<
+    return 1;
 }
 
-// Close connection
-mysqli_close($db_link);
-
+function populateItemsTable_DeletedAt($pre)
+{
+    global $db_link;
+    // loop on items - deleted_at
+    $items = mysqli_query(
+        $db_link,
+        "select i.id as id, (select date from " . $pre . "log_items where action = 'at_deleted' and id_item=id order by date DESC limit 1) as datetime
+        from `" . $pre . "items` as i;"
+    );
+    while ($item = mysqli_fetch_assoc($items)) {
+        if (is_null($item['datetime']) === false) {
+            // update updated_at field
+            mysqli_query(
+                $db_link,
+                "UPDATE `" . $pre . "items` SET deleted_at = '".$item['datetime']."' WHERE id = ".$item['id']
+            );
+        }
+    }
 
-// Return back
-echo '[{"finish":"'.$finish.'" , "next":"", "error":"", "total":"'.$total.'"}]';
\ No newline at end of file
+    return 1;
+}
\ No newline at end of file

programming_language: PHP
filename: upgrade_run_3.0.php
change_type: ModificationType.MODIFY
diff: @@ -83,6 +83,8 @@ require_once '../includes/libraries/protect/SuperGlobal/SuperGlobal.php';
 $superGlobal = new protect\SuperGlobal\SuperGlobal();
 
 
+//---------------------------------------------------------------------
+
 //--->BEGIN 3.0.1
 
 // Ensure admin user is ready
@@ -95,6 +97,7 @@ mysqli_query(
 
 //---<END 3.0.1
 
+//---------------------------------------------------------------------
 
 //--->BEGIN 3.0.5
 
@@ -112,6 +115,7 @@ if (!$res) {
 
 //---<END 3.0.5
 
+//---------------------------------------------------------------------
 
 //--->BEGIN 3.0.6
 // Add new setting 'sending_emails_job_frequency'
@@ -152,6 +156,7 @@ if ($res === false) {
 }
 //---<END 3.0.6
 
+//---------------------------------------------------------------------
 
 //--->BEGIN 3.0.7
 // Alter
@@ -172,6 +177,7 @@ mysqli_query(
 
 //---<END 3.0.7
 
+//---------------------------------------------------------------------
 
 //--->BEGIN 3.0.8
 // Add field mfa_disabled to USERS table
@@ -188,6 +194,7 @@ if ($res === false) {
 
 //---<END 3.0.8
 
+//---------------------------------------------------------------------
 
 //--->BEGIN 3.0.9
 // Add new setting 'reload_cache_table_task'
@@ -350,16 +357,61 @@ if ($res === false) {
     exit();
 }
 
-//
+// populate created_at, updated_at and deleted_at fields in USERS table
 $tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `" . $pre . "users` WHERE created_at IS NOT NULL"));
 if (intval($tmp) === 0) {
     populateUsersTable($pre);
 }
+//---<END 3.0.9
 
+//---------------------------------------------------------------------
 
-// populate created_at, updated_at and deleted_at fields in USERS table
+//--->BEGIN 3.0.10
 
-//---<END 3.0.9
+// Add field created_at to ITEMS table
+$res = addColumnIfNotExist(
+    $pre . 'items',
+    'created_at',
+    "varchar(30) NULL;"
+);
+if ($res === false) {
+    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field created_at to table ITEMS! ' . mysqli_error($db_link) . '!"}]';
+    mysqli_close($db_link);
+    exit();
+}
+
+// Add field updated_at to ITEMS table
+$res = addColumnIfNotExist(
+    $pre . 'items',
+    'updated_at',
+    "varchar(30) NULL;"
+);
+if ($res === false) {
+    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field updated_at to table ITEMS! ' . mysqli_error($db_link) . '!"}]';
+    mysqli_close($db_link);
+    exit();
+}
+
+// Add field deleted_at to ITEMS table
+$res = addColumnIfNotExist(
+    $pre . 'items',
+    'deleted_at',
+    "varchar(30) NULL;"
+);
+if ($res === false) {
+    echo '[{"finish":"1", "msg":"", "error":"An error appears when adding field deleted_at to table ITEMS! ' . mysqli_error($db_link) . '!"}]';
+    mysqli_close($db_link);
+    exit();
+}
+/*
+// populate created_at, updated_at and deleted_at fields in ITEMS table
+$tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `" . $pre . "items` WHERE created_at IS NOT NULL"));
+if (intval($tmp) === 0) {
+    populateItemsTable($pre);
+}*/
+//---<END 3.0.10
+
+//---------------------------------------------------------------------
 
 // Save timestamp
 $tmp = mysqli_num_rows(mysqli_query($db_link, "SELECT * FROM `" . $pre . "misc` WHERE type = 'admin' AND intitule = 'upgrade_timestamp'"));
@@ -421,4 +473,4 @@ function populateUsersTable($pre)
             );
         }
     }
-}
\ No newline at end of file
+}

programming_language: PHP
filename: upgrade_scripts_manager.php
change_type: ModificationType.MODIFY
diff: @@ -39,6 +39,9 @@ $scripts_list = array(
     array('upgrade_run_3.0.0_files.php', 'user_id'),
     array('upgrade_run_3.0.php', 'user_id'),
     array('upgrade_operations.php', '20230604_1'),
+    array('upgrade_operations.php', 'populateItemsTable_CreatedAt'),
+    array('upgrade_operations.php', 'populateItemsTable_UpdatedAt'),
+    array('upgrade_operations.php', 'populateItemsTable_DeletedAt'),
 );
 $param = '';
 

programming_language: PHP
filename: items.js.php
change_type: ModificationType.MODIFY
diff: @@ -702,6 +702,16 @@ $var['hidden_asterisk'] = '<i class="fas fa-asterisk mr-2"></i><i class="fas fa-
                 } else {
                     $('#form-item-field, .form-item-category').addClass('hidden');
                 }
+
+
+
+                // Prepare datePicker
+                $('#form-item-deleteAfterDate, .datepicker').datepicker({
+                    format: '<?php echo str_replace(['Y', 'M'], ['yyyy', 'mm'], $SETTINGS['date_format']); ?>',
+                    todayHighlight: true,
+                    todayBtn: true,
+                    language: '<?php echo isset($_SESSION['user_language_code']) === true ? $_SESSION['user_language_code'] : 'en'; ?>'
+                });
                 
                 // Add track-change class
                 //$('#form-item-label, #form-item-description, #form-item-login, #form-item-password, #form-item-email, #form-item-url, #form-item-folder, #form-item-restrictedto, #form-item-tags, #form-item-anyoneCanModify, #form-item-deleteAfterShown, #form-item-deleteAfterDate, #form-item-anounce, .form-item-field-custom').addClass('track-change');
@@ -1269,10 +1279,9 @@ $var['hidden_asterisk'] = '<i class="fas fa-asterisk mr-2"></i><i class="fas fa-
         var data = {
             'item_id': store.get('teampassItem').id,
             'folder_id': selectedFolderId,
-            'label': DOMPurify.sanitize($('#form-item-copy-new-label').val()),
             'access_level': store.get('teampassItem').hasAccessLevel,
         }
-
+        
         // Launch action
         $.post(
             'sources/items.queries.php', {
@@ -2678,27 +2687,14 @@ $var['hidden_asterisk'] = '<i class="fas fa-asterisk mr-2"></i><i class="fas fa-
             var reg = new RegExp("[.|,|;|:|!|=|+|-|*|/|#|\"|'|&]");
 
             // Sanitize text fields
-            let formLabel = fieldDomPurifier('#form-item-label', false, false, false),
-                formDescription = $('#form-item-description').summernote('code') !== "<p><br></p>" ? fieldDomPurifier('#form-item-description', true, false, false, $('#form-item-description').summernote('code')) : '',
-                formEmail = fieldDomPurifier('#form-item-email'),
-                formTags = fieldDomPurifier('#form-item-tags'),
-                formUrl = fieldDomPurifier('#form-item-url'),
-                formIcon = fieldDomPurifier('#form-item-icon');
-            if (formLabel === false || formDescription === false || formEmail === false || formTags === false || formUrl === false || formIcon === false) {
-                // Label is empty
-                toastr.remove();
-                toastr.warning(
-                    'XSS attempt detected. Field has been emptied.',
-                    'Error', {
-                        timeOut: 5000,
-                        progressBar: true
-                    }
-                );
+            purifyRes = fieldDomPurifierLoop('#form-item .purify');
+            if (purifyRes.purifyStop === true) {
+                // if purify failed, stop
                 return false;
             }
             
             // Do some easy checks
-            if (formLabel === '') {
+            if (purifyRes.arrFields['label'] === '') {
                 // Label is empty
                 toastr.remove();
                 toastr.error(
@@ -2709,8 +2705,7 @@ $var['hidden_asterisk'] = '<i class="fas fa-asterisk mr-2"></i><i class="fas fa-
                     }
                 );
                 return false;
-            } else if (formTags !== '' &&
-                reg.test(formTags)
+            } else if (purifyRes.arrFields['tags'] !== '' && reg.test(purifyRes.arrFields['tags'])
             ) {
                 // Tags not wel formated
                 toastr.remove();
@@ -2835,30 +2830,27 @@ $var['hidden_asterisk'] = '<i class="fas fa-asterisk mr-2"></i><i class="fas fa-
                 var data = {
                     'anyone_can_modify': $('#form-item-anyoneCanModify').is(':checked') ? 1 : 0,
                     'complexity_level': parseInt($('#form-item-password-complex').val()),
-                    'description': formDescription,
+                    'description': $('#form-item-description').summernote('code'),
                     'diffusion_list': diffusion,
                     'diffusion_list_names': diffusionNames,
                     'folder': parseInt($('#form-item-folder').val()),
-                    'email': formEmail,
+                    'email': purifyRes.arrFields['email'],
                     'fields': fields,
                     'folder_is_personal': store.get('teampassItem').IsPersonalFolder === 1 ? 1 : 0,
                     'id': store.get('teampassItem').id,
-                    'label': formLabel,
-                    'login': DOMPurify.sanitize($('#form-item-login').val()),
+                    'label': purifyRes.arrFields['label'],
+                    'login': purifyRes.arrFields['login'],
                     'pw': $('#form-item-password').val(),
                     'restricted_to': restriction,
                     'restricted_to_roles': restrictionRole,
-                    'tags': formTags,
+                    'tags': purifyRes.arrFields['tags'],
                     'template_id': parseInt($('input.form-check-input-template:checkbox:checked').data('category-id')),
-                    'to_be_deleted_after_date': ($('#form-item-deleteAfterDate').length !== 0 &&
-                        $('#form-item-deleteAfterDate').val() !== '') ? $('#form-item-deleteAfterDate').val() : '',
-                    'to_be_deleted_after_x_views': ($('#form-item-deleteAfterShown').length !== 0 &&
-                            $('#form-item-deleteAfterShown').val() !== '' && $('#form-item-deleteAfterShown').val() >= 1) ?
-                        parseInt($('#form-item-deleteAfterShown').val()) : '',
-                    'url': formUrl,
+                    'to_be_deleted_after_date': purifyRes.arrFields['deleteAfterDate'] !== '' ? purifyRes.arrFields['deleteAfterDate'] : '',
+                    'to_be_deleted_after_x_views': parseInt(purifyRes.arrFields['deleteAfterShown']) > 0 ? parseInt(purifyRes.arrFields['deleteAfterShown']) : '',
+                    'url': purifyRes.arrFields['url'],
                     'user_id': parseInt('<?php echo $_SESSION['user_id']; ?>'),
                     'uploaded_file_id': store.get('teampassApplication').uploadedFileId === undefined ? '' : store.get('teampassApplication').uploadedFileId,
-                    'fa_icon': formIcon,
+                    'fa_icon': purifyRes.arrFields['icon'],
                 };
                 if (debugJavascript === true) {
                     console.log('SAVING DATA');

programming_language: JavaScript
filename: items.php
change_type: ModificationType.MODIFY
diff: @@ -175,18 +175,18 @@ foreach ($rows as $reccord) {
                                     <div class="input-group-prepend">
                                         <span class="input-group-text"><?php echo langHdl('label'); ?></span>
                                     </div>
-                                    <input id="form-item-label" type="text" class="form-control form-item-control" data-change-ongoing="" data-field-name="label">
+                                    <input id="form-item-label" type="text" class="form-control form-item-control purify" data-change-ongoing="" data-field-name="label">
                                 </div>
                                 <!-- DESCRIPTION -->
                                 <div class="mb-3">
-                                    <div id="form-item-description" class="form-item-control w-100 clear-me-html" data-field-name="description" data-change-ongoing=""></div>
+                                    <div id="form-item-description" class="form-item-control w-100 clear-me-html purify purifyHtml" data-field-name="description" data-change-ongoing=""></div>
                                 </div>
                                 <!-- LOGIN -->
                                 <div class="input-group mb-3">
                                     <div class="input-group-prepend">
                                         <span class="input-group-text"><?php echo langHdl('login'); ?></span>
                                     </div>
-                                    <input id="form-item-login" type="text" class="form-control form-item-control" data-field-name="login" data-change-ongoing="">
+                                    <input id="form-item-login" type="text" class="form-control form-item-control purify" data-field-name="login" data-change-ongoing="">
                                 </div>
                                 <!-- PASSWORD -->
                                 <div class="input-group mb-2">
@@ -243,21 +243,21 @@ foreach ($rows as $reccord) {
                                     <div class="input-group-prepend">
                                         <span class="input-group-text"><?php echo langHdl('email'); ?></span>
                                     </div>
-                                    <input id="form-item-email" type="email" class="form-control form-item-control" data-field-name="email" data-change-ongoing="">
+                                    <input id="form-item-email" type="email" class="form-control form-item-control purify" data-field-name="email" data-change-ongoing="">
                                 </div>
                                 <!-- URL -->
                                 <div class="input-group mb-3">
                                     <div class="input-group-prepend">
                                         <span class="input-group-text"><?php echo langHdl('url'); ?></span>
                                     </div>
-                                    <input id="form-item-url" type="url" class="form-control form-item-control" data-field-name="url" data-change-ongoing="">
+                                    <input id="form-item-url" type="url" class="form-control form-item-control purify" data-field-name="url" data-change-ongoing="">
                                 </div>
                                 <!-- ICON -->
                                 <div class="input-group mb-3">
                                     <div class="input-group-prepend">
                                         <span class="input-group-text"><?php echo langHdl('icon'); ?></span>
                                     </div>
-                                    <input id="form-item-icon" type="text" class="form-control form-item-control" data-field-name="icon" data-change-ongoing="">
+                                    <input id="form-item-icon" type="text" class="form-control form-item-control " data-field-name="icon" data-change-ongoing="">
                                     <span class="ml-2 col-md-1 clear-me-html" id="form-item-icon-show"></span>
                                 </div>
                                 <small class='form-text text-muted'>
@@ -284,7 +284,7 @@ foreach ($rows as $reccord) {
                                     <div class="input-group-prepend">
                                         <span class="input-group-text"><?php echo langHdl('tags'); ?></span>
                                     </div>
-                                    <input id="form-item-tags" type="text" class="form-control form-item-control autocomplete" data-change-ongoing="">
+                                    <input id="form-item-tags" type="text" class="form-control form-item-control autocomplete purify" data-change-ongoing="" data-field-name="tags">
                                 </div>
                                 <!-- ANYONE CAN MODIFY -->
                                 <?php
@@ -323,7 +323,7 @@ foreach ($rows as $reccord) {
                                                     <?php echo langHdl('item_deleted_after_being_viewed_x_times'); ?>
                                                 </div>
                                                 <div class="d-inline p-2">
-                                                    <input type="text" class="form-control form-item-control" id="form-item-deleteAfterShown" data-change-ongoing="">
+                                                    <input type="text" class="form-control form-item-control purify" data-field-name="deleteAfterShown" id="form-item-deleteAfterShown" data-change-ongoing="">
                                                 </div>
                                             </div>
                                             <div class="row">
@@ -337,7 +337,7 @@ foreach ($rows as $reccord) {
                                                                 <i class="fas fa-calendar"></i>
                                                             </span>
                                                         </div>
-                                                        <input type="text" class="form-control float-right form-item-control" id="form-item-deleteAfterDate" data-change-ongoing="">
+                                                        <input type="text" class="form-control float-right form-item-control purify" data-field-name="deleteAfterDate" id="form-item-deleteAfterDate" data-change-ongoing="">
                                                     </div>
                                                 </div>
                                             </div>
@@ -408,6 +408,7 @@ foreach ($rows as $reccord) {
                             <div class="tab-pane" id="tab_4">
                                 <div id="form-item-field" class="hidden">
                                     <?php
+                                        echo "coucou ".count($_SESSION['item_fields']);
                                         if (isset($_SESSION['item_fields']) === true) {
                                             foreach ($_SESSION['item_fields'] as $category) {
                                                 echo '
@@ -457,6 +458,12 @@ foreach ($rows as $reccord) {
                                                 </p>
                                             </div>';
                                             }
+                                        } else {
+                                            echo
+                                            '<div class="alert alert-info">
+                                                <h5><i class="icon fa fa-info mr-3"></i>' . langHdl('information') . '</h5>
+                                                ' . langHdl('no_fields') . '
+                                            </div>';
                                         } ?>
                                 </div>
                                 <div class="alert alert-info hidden no-item-fields">

programming_language: PHP
filename: items.queries.php
change_type: ModificationType.MODIFY
diff: @@ -450,6 +450,7 @@ switch ($inputData['type']) {
                         'encryption_type' => 'teampass_aes',
                         'fa_icon' => $post_fa_icon,
                         'item_key' => uniqidReal(50),
+                        'created_at' => time(),
                     )
                 );
                 $newID = DB::insertId();
@@ -1194,6 +1195,7 @@ switch ($inputData['type']) {
                         'encryption_type' => TP_ENCRYPTION_NAME,
                         'perso' => in_array($inputData['folderId'], $_SESSION['personal_folders']) === true ? 1 : 0,
                         'fa_icon' => $post_fa_icon,
+                        'updated_at' => time(),
                     ),
                     'id=%i',
                     $inputData['itemId']
@@ -2030,6 +2032,7 @@ switch ($inputData['type']) {
 
             // generate the query to update the new record with the previous values
             $aSet = array();
+            $aSet['created_at'] = time();
             foreach ($originalRecord as $key => $value) {
                 if ($key === 'id_tree') {
                     $aSet['id_tree'] = $post_dest_id;
@@ -2641,6 +2644,7 @@ switch ($inputData['type']) {
                 prefixTable('items'),
                 array(
                     'viewed_no' => $dataItem['viewed_no'] + 1,
+                    'updated_at' => time(),
                 ),
                 'id = %i',
                 $inputData['id']
@@ -2793,6 +2797,7 @@ switch ($inputData['type']) {
                             prefixTable('items'),
                             array(
                                 'inactif' => 1,
+                                'deleted_at' => time(),
                             ),
                             'id = %i',
                             $inputData['id']
@@ -3169,27 +3174,10 @@ switch ($inputData['type']) {
         );
 
         // Prepare POST variables
-        $inputData['label'] = filter_var($dataReceived['label'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
         $inputData['folderId'] = (int) filter_var($dataReceived['folder_id'], FILTER_SANITIZE_NUMBER_INT);
         $inputData['itemId'] = (int) filter_var($dataReceived['item_id'], FILTER_SANITIZE_NUMBER_INT);
         $post_access_level = (int) filter_var($dataReceived['access_level'], FILTER_SANITIZE_NUMBER_INT);
 
-        // perform a check in case of Read-Only user creating an item in his PF
-        if (($_SESSION['user_read_only'] === true
-                && in_array($inputData['label'], $_SESSION['personal_folders']) === false)
-            || (int) $post_access_level <= 20
-        ) {
-            echo (string) prepareExchangedData(
-                $SETTINGS['cpassman_dir'],
-                array(
-                    'error' => true,
-                    'message' => langHdl('error_not_allowed_to'),
-                ),
-                'encode'
-            );
-            break;
-        }
-
         // Check that user can access this item
         $granted = accessToItemIsGranted($inputData['itemId'], $SETTINGS);
         if ($granted !== true) {
@@ -3217,6 +3205,7 @@ switch ($inputData['type']) {
             prefixTable('items'),
             array(
                 'inactif' => '1',
+                'deleted_at' => time(),
             ),
             'id = %i',
             $inputData['itemId']
@@ -3867,6 +3856,7 @@ $SETTINGS['cpassman_dir'],$inputData['data'], 'decode');
                             prefixTable('items'),
                             array(
                                 'perso' => 1,
+                                'updated_at' => time(),
                             ),
                             'id=%i',
                             $record['id']
@@ -4742,6 +4732,7 @@ $SETTINGS['cpassman_dir'],$returnValues, 'encode');
                 prefixTable('items'),
                 array(
                     'id_tree' => $inputData['folderId'],
+                    'updated_at' => time(),
                 ),
                 'id=%i',
                 $inputData['itemId']
@@ -4801,6 +4792,7 @@ $SETTINGS['cpassman_dir'],$returnValues, 'encode');
                 array(
                     'id_tree' => $inputData['folderId'],
                     'perso' => 1,
+                    'updated_at' => time(),
                 ),
                 'id=%i',
                 $inputData['itemId']
@@ -4814,6 +4806,7 @@ $SETTINGS['cpassman_dir'],$returnValues, 'encode');
                 prefixTable('items'),
                 array(
                     'id_tree' => $inputData['folderId'],
+                    'updated_at' => time(),
                 ),
                 'id=%i',
                 $inputData['itemId']
@@ -4941,6 +4934,7 @@ $SETTINGS['cpassman_dir'],$returnValues, 'encode');
                 array(
                     'id_tree' => $inputData['folderId'],
                     'perso' => 0,
+                    'updated_at' => time(),
                 ),
                 'id=%i',
                 $inputData['itemId']
@@ -5060,6 +5054,7 @@ $SETTINGS['cpassman_dir'],$returnValues, 'encode');
                         prefixTable('items'),
                         array(
                             'id_tree' => $inputData['folderId'],
+                            'updated_at' => time(),
                         ),
                         'id = %i',
                         $item_id
@@ -5123,6 +5118,7 @@ $SETTINGS['cpassman_dir'],$returnValues, 'encode');
                         array(
                             'id_tree' => $inputData['folderId'],
                             'perso' => 1,
+                            'updated_at' => time(),
                         ),
                         'id = %i',
                         $item_id
@@ -5140,6 +5136,7 @@ $SETTINGS['cpassman_dir'],$returnValues, 'encode');
                         prefixTable('items'),
                         array(
                             'id_tree' => $inputData['folderId'],
+                            'updated_at' => time(),
                         ),
                         'id = %i',
                         $item_id
@@ -5271,6 +5268,7 @@ $SETTINGS['cpassman_dir'],$returnValues, 'encode');
                         array(
                             'id_tree' => $inputData['folderId'],
                             'perso' => 0,
+                            'updated_at' => time(),
                         ),
                         'id=%i',
                         $item_id
@@ -5369,7 +5367,7 @@ $SETTINGS['cpassman_dir'],
                     in_array($dataSource['id_tree'], $_SESSION['groupes_visibles']) === false
                 ) {
                     echo (string) prepareExchangedData(
-$SETTINGS['cpassman_dir'],
+                        $SETTINGS['cpassman_dir'],
                         array(
                             'error' => true,
                             'message' => langHdl('error_not_allowed_to'),
@@ -5384,6 +5382,7 @@ $SETTINGS['cpassman_dir'],
                     prefixTable('items'),
                     array(
                         'inactif' => '1',
+                        'deleted_at' => time(),
                     ),
                     'id = %i',
                     $item_id

programming_language: PHP