CVE-2017-15278 (published 2017-10-12T08:29Z)

Cross-Site Scripting (XSS) was discovered in TeamPass before 2.1.27.9. The vulnerability exists due to insufficient filtration of data (in /sources/folders.queries.php). An attacker could execute arbitrary HTML and script code in a browser in the context of the vulnerable website.

Severity: LOW
CVSS v2 base score: 3.5 (AV:N/AC:M/Au:S/C:N/I:P/A:N)
CVSS v3 base score: 5.4, MEDIUM (CVSS:3.0/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: 2017-10-11 19:29:26+02:00
msg: 2.1.27

Fixed "PW copy to clipboard" log unconsistency in specific case
Improved the possibility to define the access level on Roles when creating new folder
repository: repo_url: https://github.com/nilsteampassnet/TeamPass
repo_name: nilsteampassnet/TeamPass
description: Collaborative Passwords Manager
repo_language: PHP
owner: nilsteampassnet
file_changes: filename: changelog.md
change_type: ModificationType.MODIFY
diff: @@ -9,8 +9,10 @@
  Fixed some other security failures (credit to ​security at Amossys)
  Improved security regarding uploading files
  Fixed issue while restoring DB from administration page
+ Fixed "PW copy to clipboard" log unconsistency in specific case
  Improved / Fixed administration task for encrypting/decrypting files
  Improved security regarding item history display
+ Improved the possibility to define the access level on Roles when creating new folder
  Added filter in Roles
  New: confirm deletion of attachment
  #1956 Warning appears on Category and API pages in admin mode

programming_language: Markdown
filename: folders.load.php
change_type: ModificationType.MODIFY
diff: @@ -20,6 +20,7 @@ if (!isset($_SESSION['CPM']) || $_SESSION['CPM'] != 1) {
 <script type="text/javascript">
 //<![CDATA[
 $(function() {
+    $("#span_new_rep_roles").hide();
 
     //Launch the datatables pluggin
     var tableFolders = $("#t_folders").dataTable({
@@ -61,7 +62,7 @@ $(function() {
             $("#new_folder_wait").hide();
 
             //empty dialogbox
-            $("#div_add_group input, #div_add_group select").val("");
+            $("#div_add_group input, #div_add_group select, #new_rep_roles").val("");
             $("#add_node_renewal_period").val("0");
             $("#folder_block_modif, #folder_block_creation").val("0");
             $("#parent_id").val("na");
@@ -89,7 +90,8 @@ $(function() {
                             "parent_id": $('#parent_id').val().replace(/"/g,'&quot;') ,
                             "renewal_period": $('#add_node_renewal_period').val().replace(/"/g,'&quot;') ,
                             "block_creation": $("#folder_block_creation").val() ,
-                            "block_modif": $("#folder_block_modif").val()
+                            "block_modif": $("#folder_block_modif").val(),
+                            "access_level": $("#new_rep_roles").val()
                         };
 
                         //send query
@@ -334,6 +336,14 @@ $(function() {
     $("#click_refresh_folders_list").click(function() {
         tableFolders.api().ajax.reload();
     });
+
+    $("#parent_id").change(function() {
+        if ($(this).val() === "0") {
+            $("#span_new_rep_roles").show();
+        } else {
+            $("#span_new_rep_roles").hide();
+        }
+    })
 });
 
 

programming_language: PHP
filename: folders.php
change_type: ModificationType.MODIFY
diff: @@ -116,7 +116,7 @@ echo '
 <div id="div_add_group" style="display:none;">
     <div id="addgroup_show_error" style="text-align:center;margin:2px;display:none;" class="ui-state-error ui-corner-all"></div>
 
-    <label for="ajouter_groupe_titre" class="label_cpm">'.$LANG['group_title'].'</label>
+    <label for="ajouter_groupe_titre" class="label_cpm">'.addslashes($LANG['group_title']).'</label>
     <input type="text" id="ajouter_groupe_titre" class="input_text text ui-widget-content ui-corner-all" />
 
     <label for="parent_id" class="label_cpm">'.addslashes($LANG['group_parent']).'</label>
@@ -124,7 +124,7 @@ echo '
         '.$droplist.'
     </select>
 
-    <label for="new_rep_complexite" class="label_cpm">'.$LANG['complex_asked'].'</label>
+    <label for="new_rep_complexite" class="label_cpm">'.addslashes($LANG['complex_asked']).'</label>
     <select id="new_rep_complexite" class="input_text text ui-widget-content ui-corner-all">';
 foreach ($SETTINGS_EXT['pwComplexity'] as $complex) {
     echo '<option value="'.$complex[0].'">'.$complex[1].'</option>';
@@ -132,17 +132,26 @@ foreach ($SETTINGS_EXT['pwComplexity'] as $complex) {
 echo '
     </select>
 
-    <label for="add_node_renewal_period" class="label_cpm">'.$LANG['group_pw_duration'].'</label>
+    <span id="span_new_rep_roles">
+    <label for="new_rep_roles" class="label_cpm">'.addslashes($LANG['access_level_for_roles']).'</label>
+    <select id="new_rep_roles" class="input_text text ui-widget-content ui-corner-all">
+        <option value="">'.$LANG['no_access'].'</option>
+        <option value="R">'.$LANG['read'].'</option>
+        <option value="W">'.$LANG['write'].'</option>
+    </select>
+    </span>
+
+    <label for="add_node_renewal_period" class="label_cpm">'.addslashes($LANG['group_pw_duration']).'</label>
     <input type="text" id="add_node_renewal_period" value="0" class="input_text text ui-widget-content ui-corner-all" />
 
-    <label for="folder_block_creation" class="">'.$LANG['auth_creation_without_complexity'].'</label>
+    <label for="folder_block_creation" class="">'.addslashes($LANG['auth_creation_without_complexity']).'</label>
     <select id="folder_block_creation" class="ui-widget-content ui-corner-all">
         <option value="0">'.$LANG['no'].'</option>
         <option value="1">'.$LANG['yes'].'</option>
     </select>
 
     <div style="margin-top:10px;">
-        <label for="folder_block_modif">'.$LANG['auth_modification_without_complexity'].'</label>
+        <label for="folder_block_modif">'.addslashes($LANG['auth_modification_without_complexity']).'</label>
         <select id="folder_block_modif" class="ui-widget-content ui-corner-all">
             <option value="0">'.$LANG['no'].'</option>
             <option value="1">'.$LANG['yes'].'</option>

programming_language: PHP
filename: arabic.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: bulgarian.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: catalan.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: chinese.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: czech.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: dutch.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: english.php
change_type: ModificationType.MODIFY
diff: @@ -1,4 +1,4 @@
-<?php 
+<?php
 /**
  *
  * @file          english.php
@@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'user_ga_code' => 'Email Google Authentication to user',

programming_language: PHP
filename: estonian.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: french.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Droit associé des Roles',
     'user_ga_code' => 'Envoyer le code Google Authenticator à l\'utilisateur par email',
     'send_ga_code' => 'Google Authenticator pour l\'utilisateur',
     'error_no_email' => 'Cet utilisateur n\'a pas de courriel de défini !',

programming_language: PHP
filename: german.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: greek.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: hungarian.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: italian.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: japanese.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: norwegian.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: polish.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: portuguese.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: portuguese_br.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: romanian.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: russian.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: spanish.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: swedish.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: turkish.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: ukrainian.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: vietnamese.php
change_type: ModificationType.MODIFY
diff: @@ -14,6 +14,7 @@
  */
 global $LANG;
 $LANG = array (
+    'access_level_for_roles' => 'Associated access for Roles',
     'admin_script_backup_secret' => 'Passkey for backup execution',
     'admin_script_backup_secret_tip' => 'The backup passkey needs to be provided to start the backup. It has to be added a key parameter to script.backup.php. Example:scripts.backup.php?key=your_passkey',
     'text' => 'Text',

programming_language: PHP
filename: items.load.php
change_type: ModificationType.MODIFY
diff: @@ -3932,15 +3932,17 @@ var showPwd = function(){
 /*
 * permits to save
 */
-function itemLog(log_case)
+function itemLog(log_case, item_id)
 {
+    console.log("> "+item_id);
+    item_id = item_id || $('#id_item').val();
     $.post(
         "sources/items.logs.php",
         {
             type        : log_case,
-            id_item     : $('#id_item').val(),
+            id_item     : item_id,
             folder_id   : $('#hid_cat').val(),
-        hid_label   : $('#hid_label').val(),
+            hid_label   : $('#hid_label').val(),
             key         : "<?php echo $_SESSION['key']; ?>"
         }
     );
@@ -4025,7 +4027,7 @@ function proceed_list_update(stop_proceeding)
         var clipboard = new Clipboard('.mini_pw');
         clipboard.on('success', function(e) {
             $("#message_box").html("<?php echo addslashes($LANG['pw_copied_clipboard']); ?>").show().fadeOut(1000);
-            itemLog("item_password_copied");
+            itemLog("item_password_copied", e.trigger.dataset.clipboardId);
             e.clearSelection();
         });
 

programming_language: PHP
filename: profile.php
change_type: ModificationType.MODIFY
diff: @@ -92,6 +92,16 @@ foreach ($rows as $record) {
     $arraFlags[$record['label']] = $record['label'];
 }
 
+// Prepare Headers
+header('Access-Control-Allow-Origin: *');
+echo '
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+    <head>
+        <title>User Profile</title>
+    </head>
+<body>';
+
 echo '
 <input type="hidden" id="profile_user_token" value="" />
 <table style="margin-left:7px;">
@@ -717,3 +727,5 @@ function changePersonalSaltKey(credentials, ids, nb_total)
     );
 }
 </script>
+</body>
+</html>

programming_language: PHP
filename: folders.queries.php
change_type: ModificationType.MODIFY
diff: @@ -438,6 +438,19 @@ if (null !== $post_newtitle) {
             $complexity = htmlspecialchars_decode($dataReceived['complexity']);
             $parentId = htmlspecialchars_decode($dataReceived['parent_id']);
             $renewalPeriod = htmlspecialchars_decode($dataReceived['renewal_period']);
+            if ($parentId === "0") {
+                if (isset($dataReceived['access_level']) === true) {
+                    $access_level_by_role = filter_var(htmlspecialchars_decode($dataReceived['access_level']), FILTER_SANITIZE_STRING);
+                } else {
+                    if ($_SESSION['user_manager'] === "1") {
+                        $access_level_by_role = "W";
+                    } else {
+                        $access_level_by_role = "";
+                    }
+                }
+            } else {
+                $access_level_by_role = "";
+            }
 
             //Check if title doesn't contains html codes
             if (preg_match_all("|<[^>]+>(.*)</[^>]+>|U", $title, $out)) {
@@ -544,46 +557,52 @@ if (null !== $post_newtitle) {
                     $tree = new Tree\NestedTree\NestedTree(prefix_table("nested_tree"), 'id', 'parent_id', 'title');
                     $tree->rebuild();
 
-                    if ($isPersonal !== 1
-                        && isset($SETTINGS['subfolder_rights_as_parent'])
-                        && $SETTINGS['subfolder_rights_as_parent'] === 1
-                        || ($isPersonal !== 1 && $parentId === "0")
-                    ) {
+                    // Add right to see this folder
+                    if ($_SESSION['is_admin'] === "1" || $_SESSION['user_manager'] === "1") {
                         //Get user's rights
                         identifyUserRights(
-                            array_push($_SESSION['groupes_visibles'], $newId),
+                            $_SESSION['groupes_visibles'],
                             implode(";", $_SESSION['groupes_interdits']),
                             $_SESSION['is_admin'],
-                            $_SESSION['fonction_id']
+                            is_array($_SESSION['fonction_id']) === true ? implode(";", $_SESSION['fonction_id']) : $_SESSION['fonction_id']
                         );
+                    }
 
+                    if ($isPersonal !== 1
+                        && $parentId === "0"
+                    ) {
                         //add access to this new folder
                         foreach (explode(';', $_SESSION['fonction_id']) as $role) {
-                            if (!empty($role)) {
+                            if (empty($role) === false && empty($access_level_by_role) === false) {
                                 DB::insert(
                                     prefix_table("roles_values"),
                                     array(
                                         'role_id' => $role,
                                         'folder_id' => $newId,
-                                        'type' => "W"
+                                        'type' => $access_level_by_role
                                     )
                                 );
                             }
                         }
                     }
 
-                    //If it is a subfolder, then give access to it for all roles that allows the parent folder
-                    $rows = DB::query("SELECT role_id, type FROM ".prefix_table("roles_values")." WHERE folder_id = %i", $parentId);
-                    foreach ($rows as $record) {
-                        //add access to this subfolder
-                        DB::insert(
-                            prefix_table("roles_values"),
-                            array(
-                                'role_id' => $record['role_id'],
-                                'folder_id' => $newId,
-                                'type' => $record['type']
-                            )
-                        );
+
+                    if (isset($SETTINGS['subfolder_rights_as_parent']) === true
+                        && $SETTINGS['subfolder_rights_as_parent'] === "1"
+                    ) {
+                        //If it is a subfolder, then give access to it for all roles that allows the parent folder
+                        $rows = DB::query("SELECT role_id, type FROM ".prefix_table("roles_values")." WHERE folder_id = %i", $parentId);
+                        foreach ($rows as $record) {
+                            //add access to this subfolder
+                            DB::insert(
+                                prefix_table("roles_values"),
+                                array(
+                                    'role_id' => $record['role_id'],
+                                    'folder_id' => $newId,
+                                    'type' => $record['type']
+                                )
+                            );
+                        }
                     }
 
                     // if parent folder has Custom Fields Categories then add to this child one too

programming_language: PHP
filename: items.queries.php
change_type: ModificationType.MODIFY
diff: @@ -2695,7 +2695,7 @@ if (null !== $post_type) {
                                     $new_line .= '<i class="fa fa-sm fa-user mi-black mini_login" data-clipboard-text="'.strtr($record['login'], '"', "&quot;").'" title="'.$LANG['item_menu_copy_login'].'"></i>&nbsp;';
                                 }
                                 if (empty($pw) === false) {
-                                    $new_line .= '<i class="fa fa-sm fa-lock mi-black mini_pw" data-clipboard-text="'.strtr($pw, '"', "&quot;").'" title="'.$LANG['item_menu_copy_pw'].'"></i>&nbsp;';
+                                    $new_line .= '<i class="fa fa-sm fa-lock mi-black mini_pw" data-clipboard-text="'.strtr($pw, '"', "&quot;").'" title="'.$LANG['item_menu_copy_pw'].'" data-clipboard-id="'.$record['id'].'"></i>&nbsp;';
                                 }
                             }
                         }

programming_language: PHP
filename: main.functions.php
change_type: ModificationType.MODIFY
diff: @@ -510,6 +510,9 @@ function defuse_return_decrypted($value)
 function trimElement($chaine, $element)
 {
     if (!empty($chaine)) {
+        if (is_array($chaine) === true) {
+            $chaine = implode(";", $chaine);
+        }
         $chaine = trim($chaine);
         if (substr($chaine, 0, 1) == $element) {
             $chaine = substr($chaine, 1);
@@ -658,7 +661,7 @@ function identifyUserRights($groupesVisiblesUser, $groupesInterditsUser, $isAdmi
         $_SESSION['read_only_folders'] = array();
         $_SESSION['fonction_id'] = $idFonctions;
         $groupesInterdits = array();
-        if (!is_array($groupesInterditsUser)) {
+        if (is_array($groupesInterditsUser) === false) {
             $groupesInterditsUser = explode(';', trimElement($groupesInterditsUser, ";"));
         }
         if (!empty($groupesInterditsUser) && count($groupesInterditsUser) > 0) {

programming_language: PHP