[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16314839#comment-16314839
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9927:
--------------------------------------------

rhtyd closed pull request #2125: CLOUDSTACK-9927: Root admin user should be 
forced to change password …
URL: https://github.com/apache/cloudstack/pull/2125
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ui/scripts/installWizard.js b/ui/scripts/installWizard.js
index 9d7c23da476..5b769f39bfa 100644
--- a/ui/scripts/installWizard.js
+++ b/ui/scripts/installWizard.js
@@ -16,18 +16,55 @@
 // under the License.
 (function($, cloudStack) {
     cloudStack.installWizard = {
+        changedFirstPassword: false,
         // Check if install wizard should be invoked
         check: function(args) {
-            $.ajax({
-                url: createURL('listZones'),
-                dataType: 'json',
-                async: true,
-                success: function(data) {
-                    args.response.success({
-                        doInstall: !data.listzonesresponse.zone
-                    });
-                }
-            });
+            if(isAdmin()) {
+                $.ajax({
+                    url: createURL('listDomains'),
+                    data: {
+                        listAll: true,
+                        level: '0'
+                    },
+                    dataType: 'json',
+                    async: false,
+                    success: function(json) {
+                        var rootDomain= json.listdomainsresponse.domain[0];
+                        $.ajax({
+                            url: createURL('listUsers'),
+                            data: {
+                                listAll: true,
+                                domainid: rootDomain.id,
+                                account: 'admin'
+                            },
+                            dataType: 'json',
+                            async: false,
+                            success: function(json) {
+                                var adminUsers = json.listusersresponse.user;
+                                var adminUser;
+                                for(var i=0; i<adminUsers.length; i++) {
+                                    if(adminUsers[i].username === 'admin') {
+                                        adminUser = adminUsers[i];
+                                        break;
+                                    }
+                                }
+                                if(adminUser != null && (adminUser.userdetails 
== null || adminUser.userdetails.isdefaultpassword == null)) {
+                                    
cloudStack.installWizard.changedFirstPassword = true;
+                                }
+
+                                args.response.success({
+                                    doInstall: 
!cloudStack.installWizard.changedFirstPassword
+                                });
+                            }
+                        });
+
+                  }
+                });
+            } else {
+                args.response.success({
+                    doInstall: false
+                });
+            }
         },
 
         changeUser: function(args) {
@@ -37,7 +74,7 @@
                     id: cloudStack.context.users[0].userid,
                     password: md5Hashed ? $.md5(args.data.password) : 
args.data.password
                 },
-                type: 'POST',
+                type: "POST",
                 dataType: 'json',
                 async: true,
                 success: function(data) {
diff --git a/ui/scripts/ui-custom/installWizard.js 
b/ui/scripts/ui-custom/installWizard.js
index f7ed074e774..1adfac804f2 100644
--- a/ui/scripts/ui-custom/installWizard.js
+++ b/ui/scripts/ui-custom/installWizard.js
@@ -106,7 +106,11 @@
                 });
 
                 $prev.click(function() {
-                    goTo(prevStepID);
+                    if (prevStepID === 'changeUser' && 
cloudStack.installWizard.changedFirstPassword) {
+                        goTo('intro');
+                    } else {
+                        goTo(prevStepID);
+                    }
                 });
 
                 return function(args) {
@@ -330,7 +334,8 @@
                 });
 
                 $advanced.click(function() {
-                    complete();
+                    state.isAdvancedUser = true;
+                    goTo('changeUser');
 
                     return false;
                 });
@@ -342,6 +347,27 @@
             },
 
             changeUser: function(args) {
+
+                if (cloudStack.installWizard.changedFirstPassword) {
+                    if (!state.isAdvancedUser) {
+                        $.ajax({
+                            url: createURL('listZones'),
+                            dataType: 'json',
+                            async: true,
+                            success: function(data) {
+                                if(data.listzonesresponse.zone) {
+                                    complete();
+                                } else {
+                                    goTo('addZoneIntro', 'newUser', $form);
+                                }
+                            }
+                        });
+                    } else {
+                        complete();
+                    }
+
+                    return $('<div>');
+                }
                 var $changeUser = $('<div></div>').addClass('step 
change-user');
                 var $form = $('<form></form>').appendTo($changeUser);
 
@@ -386,6 +412,12 @@
 
                 // Save event
                 $form.submit(function() {
+                    if ($form.find('input[name=password]').val() === 
'password') {
+                        cloudStack.dialog.notice({ message: 'Password must not 
be the default.'});
+
+                        return false;
+                    }
+
                     if (!$form.valid()) return false;
 
                     var $loading = 
$('<div></div>').addClass('loading-overlay').prependTo($form);
@@ -393,7 +425,23 @@
                         data: cloudStack.serializeForm($form),
                         response: {
                             success: function(args) {
-                                goTo('addZoneIntro', 'newUser', $form);
+                                cloudStack.installWizard.changedFirstPassword 
= true;
+                                if (!state.isAdvancedUser) {
+                                    $.ajax({
+                                        url: createURL('listZones'),
+                                        dataType: 'json',
+                                        async: true,
+                                        success: function(data) {
+                                            if(data.listzonesresponse.zone) {
+                                                complete();
+                                            } else {
+                                                goTo('addZoneIntro', 
'newUser', $form);
+                                            }
+                                        }
+                                    });
+                                } else {
+                                    complete();
+                                }
                             }
                         }
                     });


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Root admin user should be forced to change password
> ---------------------------------------------------
>
>                 Key: CLOUDSTACK-9927
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9927
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>          Components: Management Server
>            Reporter: Harikrishna Patnala
>            Assignee: Harikrishna Patnala
>             Fix For: 4.10.1.0
>
>
> The default password for the root admin in CloudStack is "password". The user 
> is not required to change this password.
> Using CloudStack with the default password is the same as using it with no 
> password. An attacker could log onto the management UI or API and make 
> changes to the system, delete or steal resources, and stop services.
> Mitigation:
> Do not continue in UI until admin has changed his password to something other 
> than the default. Also, do not permit the admin to change his password back 
> to the default one later.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to