Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RBAC] az ad sp credential reset: fix weak credential generation #13357

Merged
merged 12 commits into from
May 11, 2020

Conversation

qianwens
Copy link
Member

@qianwens qianwens commented May 6, 2020

Description

Password autogenerated by az ad sp credential reset is a Guid which is not secure.

Testing Guide

az ad sp credential reset -n test
Expected result: password should be a string with at least one special character
History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change.
[Component Name 2] az command b: Add some customer-facing feature.


This checklist is used to make sure that common guidelines for a pull request are followed.

@qianwens qianwens requested review from arrownj, jiasli and yonzhan May 6, 2020 09:56
@yonzhan yonzhan added this to the S169 - For Build milestone May 6, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented May 6, 2020

add to S169

@jiasli
Copy link
Member

jiasli commented May 7, 2020

Please title the PR with meaningful description, like "[RBAC] az ad sp credential reset: fix weak credential generation", so that HISTORY.rst contains useful information for the user.

Comment on lines 1744 to 1759
def _random_password(length):
import random
import string
random_source = string.ascii_letters + string.digits + string.punctuation
password = random.choice(string.ascii_lowercase)
password += random.choice(string.ascii_uppercase)
password += random.choice(string.digits)
password += random.choice(string.punctuation)

for i in range(length - 4):
password += random.choice(random_source)

password_list = list(password)
random.SystemRandom().shuffle(password_list)
password = ''.join(password_list)
return password
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the code is borrowed from somewhere else, it is a good practice to put the source link in the comment: https://pynative.com/python-generate-random-string/

@qianwens qianwens changed the title [Graph]fix a security issue: az ad sp credential reset [RBAC] az ad sp credential reset: fix weak credential generation May 7, 2020
@jiasli
Copy link
Member

jiasli commented May 7, 2020

@fengzhou-msft I think we have decided not to include backticks ` in the title?

password += random.choice(string.digits)
password += random.choice(string.punctuation)

for i in range(length - 4): # pylint: disable=unused-variable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for i in range(length - 4): # pylint: disable=unused-variable
for _ in range(length - 4):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants