Landscape insecure tokens generation
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Landscape Server |
Fix Released
|
Critical
|
Simon Poirier |
Bug Description
Hi team!
Landscape API Access and Secret keys are generated using python random.choice() function:
/opt/canonical/
import random
import string
__all__ = ["create_
def create_
"""Create a randomly generated 20 character access key."""
key_choice = string.uppercase + string.digits
key = []
for i in xrange(20):
return "".join(key)
def create_
"""Create a randomly generated 40 character access secret."""
secret_choice = (
secret = []
for i in xrange(40):
return "".join(secret)
Python random module uses the Mersenne Twister as the core generator. As it is a pseudo-random numbers generator it is not suitable for generating secrets.
From https:/
Warning The pseudo-random generators of this module should not be used for security purposes. Use os.urandom() or SystemRandom if you require a cryptographically secure pseudo-random number generator.
The same function (random.choice()) used to generate password recovery token:
/opt/canonical/
...
import string
import random
...
def make_secure_
choices = string.digits + string.letters
return "".join(
...
In theory, it is possible to collect as much data as needed to obtain the state of the Mersenne Twister matrix and, afterwards, predict the next values of the generator. A related technique is described on https:/
To get generated password reset tokens attacker can register a new account using '/new-standalon
Impact
Compromising admin account or obtaining secret API keys which can be used to RCE on multiple hosts registered in organisation.
Mitigation
Use os.urandom() or SystemRandom functions to generate secret tokens.
CVE References
Changed in landscape: | |
status: | New → Triaged |
importance: | Undecided → Critical |
assignee: | nobody → Simon Poirier (simpoir) |
Changed in landscape: | |
status: | Triaged → In Progress |
Changed in landscape: | |
status: | In Progress → Fix Committed |
milestone: | none → 19.10.5 |
Changed in landscape: | |
status: | Fix Committed → Fix Released |
information type: | Private Security → Public |
information type: | Public → Public Security |
Hello!
Thank for the update. Will you assign CVE for this bug?