Kaspersky Password Supervisor: All of your passwords are belong to us

tl;dr: The password generator incorporated in Kaspersky Password Supervisor had several issues. The most severe one is that it aged a PRNG now not suited for cryptographic purposes. Its single source of entropy used to be the current time. Your total passwords it created is also bruteforced in seconds. This text explains safely generate passwords, why Kaspersky Password Supervisor failed, and exploit this flaw. It additionally offers a proof of thought to sign in case your model is vulnerable.

The product has been updated and its newest versions aren’t struggling from this discipline.


Two years ago, we seemed at Kaspersky Password Supervisor (KPM), a password supervisor developed by Kaspersky. Kaspersky Password Supervisor is a product that securely shops passwords and paperwork into an encrypted vault, safe by a password. This vault is safe with a grasp password, so, as with heaps of password managers, users want to be conscious a single password to employ and region up all their passwords. Product is equipped for diverse working programs (Windows, macOS, Android, iOS, Web…) Encrypted recordsdata can then be routinely synchronized between your total gadgets, constantly safe by your grasp password.

The critical efficiency of KPM is password management. One key point with password managers is that, opposite to other folks, these tools are correct to generate random, solid passwords. To generate stable passwords, Kaspersky Password Supervisor must rely upon a stable password technology mechanism. We can first peek an instance of a correct password technology formulation, to repeat after why the trend aged by Kaspersky used to be unsuitable, and the most reasonable doubtless method we exploited it. As we are able to peek, passwords generated by this instrument is also bruteforced in seconds.

After a limited lower than two years, this vulnerability has been patched on all versions of KPM. Vulnerability has been assigned CVE-2020-27020.

Generating strong passwords from a charset

For the sake of simplicity, let’s discover how passwords are generated in KeePass, an start source mission. Password technology is applied in varied classes within the KeePassLib.Cryptography.PasswordGenerator namespace. KeePass offers 3 suggestions to generate a password: a charset-basically basically based, a pattern-basically basically based and a personalised technology formulation.

The more uncomplicated formulation is the charset-inappropriate generator, which creates a password from a given charset. Let peek the most reasonable doubtless method it certainly works. Right here is the critical loop guilty for the password technology:

PwCharSet pcs = current PwCharSet(pwProfile.CharSet.ToString());
if(!PwGenerator.PrepareCharSet(pcs, pwProfile))
    return PwgError.InvalidCharSet;

char[] v = current char[pwProfile.Length];
are trying
    for(int i = 0; i < v.Length; ++i)
        char ch = PwGenerator.GenerateCharacter(pcs, crsRandomSource);
        if(ch == char.MinValue)
            return PwgError.TooFewCharacters;

        v[i] = ch;
        if(pwProfile.NoRepeatingCharacters) pcs.Remove(ch);

The GenerateCharacter method is called to generate every single character from the password. It takes a charset and a random source, and outputs a random character from the charset. Its implementation is rather straightforward:

internal static char GenerateCharacter(PwCharSet pwCharSet,
                                       CryptoRandomStream crsRandomSource)
    uint cc = pwCharSet.Size;
    if(cc == 0) return char.MinValue;

    uint i = (uint)crsRandomSource.GetRandomUInt64(cc);
    return pwCharSet[i];

Finally, GetRandomUInt64 is a uniform random number generator that outputs values between 0 and cc – 1:

internal ulong GetRandomUInt64(ulong uMaxExcl)
    if(uMaxExcl == 0) { Debug.Assert(false); throw new ArgumentOutOfRangeException("uMaxExcl"); }

    ulong uGen, uRem;
        uGen = GetRandomUInt64();
        uRem = uGen % uMaxExcl;
    while((uGen - uRem) > (ulong.MaxValue - (uMaxExcl - 1UL)));
    // This ensures that the closing desire of the block (i.e.
    // (uGen - uRem) + (uMaxExcl - 1)) is generatable;
    // for signed longs, overflow to damaging amount: 
    // whereas((uGen - uRem) + (uMaxExcl - 1) < 0);

    return uRem;

What is important here is that each character is generated independently from the other ones: every character is random, and knowing which character has been generated before does not give us information about the next char that will be generated.

Finally, let’s assume GetRandomUInt64 is cryptographically strong, and generates a random 64-bit number. Why is there a loop here, and why does this function is not simply implemented as return GetRandomUInt64() % uMaxExcl;?

Uniform random number generation

This loop is essential to uniformly generate numbers in a range.

Imagine you want to get a random char from a charset of 10 possible chars, and you have a random number generator method GetRandom32 which outputs number between 0 and 32 (32 excluded). The straightforward way to output such char would be:

const string charset = "0123456789";
return charset[GetRandom32() % 10];

Let’s see how characters are generated:

  • “4” is returned if GetRandom32() returns 4, 14 or 24 (3 possible values)
  • “5” is returned if GetRandom32() returns 5, 15 or 25 (3 possible values)
  • But “1” is returned if GetRandom32() returns 1, 11, 21 and 31 (4 possible values!)

The distribution is given below:

Distribution of GetRandom32() mod 10

So there is a bias with this method: as one can see from the outputs, digits 0 and 1 will be output more frequently than the other ones. It is commonly called the “modulo bias”. You should check the excellent Definitive guide to “modular bias” and how to avoid it, by Kudelski Security, for more information.

To remove this “modulo bias”, a common method is to discard all the numbers greater than or equal to 30 (the biggest multiple of 10 lower than 16):

const string charset = "0123456789";
do {
    uGen = GetRandom32();
} while (uGen >= 30);
return charset[uGen];

Right here is precisely what KeePass does, even though the bias in KeePass would possibly be noteworthy less critical than within the current instance, because the GetRandomUInt64 generates values noteworthy bigger than the scale of the password personality region.

We saw uniformly purchase a personality from a given fluctuate of characters, assuming our random source is uniform. Let’s peek now what roughly source is suitable to generate cryptographically solid random numbers.

Cryptographically stable PRNG

Generated numbers ought to be random. However what does that mean exactly? An weird and wonderful correct PRNG will pass a sequence of assessments, mainly statistical randomness assessments equivalent to Diehard or Dieharder assessments.

A cryptographically stable PRNG (CSPRNG) will additionally pass those assessments, but it additionally has two heaps of necessities:

  • It must satisfy the next-bit check. Realizing the general bits already generated by a CSPRNG, there would possibly be now not any such thing as a polynomial-time formulation that can predict the next bit with a probability greater that 0.5.
  • If, at any 2d, the total negate of the CSPRNG is compromised, there would possibly be now not any such thing as a formulation to retrieve the bits beforehand returned by the CSPRNG.

These facets are very critical for password technology. For instance, if a password has been compromised for some motive, and if a non-CSPRNG has been aged to generate this password, an attacker would possibly also then be in a predicament to retrieve the heaps of password generated the utilization of this PRNG. Most working programs present CSPRNG implementations: CryptGenRandom on Windows, or /dev/random on UNIX-love working programs.

Some instrument get to employ their very enjoy implementation, in general seeded, fully or partially, by the working system PRNG. KeePass makes employ of two PRNG, basically basically based both on Salsa20 and ChaCha20, and a legacy one in accordance to a variant of ARCFour. Let’s care for the critical two PRNG are cryptographically stable: we enjoy the general parts to generate random, stable passwords from a given charset.

Kaspersky’s Password Technology Intention

Kaspersky Password Supervisor has a constructed-in password generator, which creates password from a given “protection”. The protection settings are uncomplicated: password length, uppercase letters, lowercase letters, digits, and a personalised region of special chars. All these settings is also configured within the Password generator interface, as proven here (here’s the in trend setting):

KPM Password Generator

By default, KPM generates 12-personality passwords with an prolonged charset.

Tricking the frequency of look

The technology task is noteworthy extra complex than the Keepass formulation. KPM first picks two random floats $r_1$ and $r_2$ between 0 and 1, and multiplies them with the length of the password charset to web a price within the charset table:

charset = ...  # personality region to employ
r1 = random.random()
r2 = random.random()
pos = r1 * r2 * len(charset)
return charset[pos]

The distribution of $r_1 cases r_2$ is (on yarn of MathWorld):

[begin{eqnarray} P[r_1 r_2 = a] &=& int_0^1int_0^1 delta(xy – a) dy dx \ &=& int_0^1int_{-a}^{x-a} delta(z) frac{1}{x} dz dx \ &=& int_0^1 1(x geq a) frac{1}{x} dx \ &=& int_a^1 frac{1}{x} dx \ &=& -ln(a) terminate{eqnarray}]

Let’s predicament it:

Uniform product distribution

The distribution of this perform is now not uniform: lower positions enjoy extra prospects to occur than values shut to from 1. Such formulation is moderately puzzling, but it looks to be it’s a ways precisely what KPM wished to enforce.

How is created the charset? Is it fully ordered, love “abcdefghij…”? No…

  • For the critical three chars, charset is fully ordered (nearly… we are able to peek that later).
  • Then, for the next chars, KPM depends on letter frequency: it assumes least frequent letters (in some language) must appear extra in general within the generated password. The supposed frequency of apparition of every letter, as aged in KPM, is proven within the graph below:

Passwords letter frequency

Then, charset is ordered in accordance to the inverse frequency of look of every letter: q, x, z, w… n, a, e.

As lower values are extra more doubtless to appear given the distribution perform, we are able to care for some chars love “q” and “x” are extra more doubtless to appear in passwords generated by KPM.

If these stats were taken independently to generate every char of a password, we would possibly also peek in general several “q”, “x” or “z” within the passwords. Nonetheless, issues are extra complex: generated chars are taken into yarn within the computation of the frequencies of look. If a “z” is generated, then the likelihood of look of “z” within the frequency table can be strongly increased. Once the charset is ordered in accordance to this table, “z” can be at the tip of the table, and can fair enjoy noteworthy less changes to be taken.

Variation of the probability of appearance of each letter

These changes additionally enjoy an influence on heaps of letters: after “z” has been picked, the likelihood of “a”, “e”, “m”, “q”, “s” and “x” has additionally increased. On the opposite, “h” has reduced. However, after “h” is picked, its probability of look will then expand a lot.

Our speculation is that formulation has been applied to trick in trend password cracking tools. Password crackers equivalent to Hashcat or John the Ripper are trying and atomize first probable password, e.g. passwords generated by other folks. Their password cracking formulation depends on the proven fact that there are potentially “e” and “a” in a password created by a human than “x” or “j”, or that the bigrams “th” and “he” will appear noteworthy extra in general than “qx” or “zr”.

Dedicated ways equivalent to Markov generator, which care for that there would possibly be a hidden Markov mannequin within the trend passwords are generated by other folks, can straight atomize this variety of technology (peek Lickety-split Dictionary Attacks on Passwords The employ of Time-Set Tradeoff for added shrimp print).

Hence, passwords generated by KPM can be, on reasonable, a ways within the list of candidate passwords examined by these tools. If an attacker tries to crack a listing of passwords generated by KPM, he’ll potentially wait slightly a actually long time till the critical one is found. Right here is moderately artful.

Nonetheless, if an attacker knows that a password has been generated by KPM, he can adapt his instrument to lift into consideration the mannequin adopted by KPM. As these passwords are, in a particular sense, biased (to sort out password crackers), this bias is also aged to generate the most probable passwords generated by this instrument, and check them first. A straightforward formulation to attain it’s a ways also to employ a Markov generator, as the one equipped by John the Ripper (This method has now not been examined).

We can end that the technology algorithm in itself is now not that base: this would possibly withstand in opposition to in trend tools. Nonetheless, if an attacker knows a particular person makes employ of KPM, he’ll be in a predicament to atomize his password noteworthy extra with out problems than a fully random password. Our recommendation is, alternatively, to generate random passwords long ample to be too solid to be broken by a instrument.

We beforehand saw that KPM picked two random values $r_1$ and $r_2$ to compute an index within the charset table. Let’s peek now how these values are computed.

KPM’s Random Number Generator

These two values come straight from the KPM PRNG. This PRNG outputs uniformly floats between 0 and 1, 1 excluded.

The PRNG aged differs within the Desktop and the Web model:

  • The Web model aged Math.random(). This perform is now not suitable to generate cryptographically stable random numbers (which contains entropy required to generate passwords), as explained in doctors/Web/JavaScript/Reference/Global_Objects/Math/random. The underlying PRNG aged by Chrome, Firefox and Safari for Math.random() is xorshift128+. It’s fully fleet, but now not suitable to generate cryptographic cloth. The protection penalties in KPM has now not been studied, but we urged Kaspersky to exchange it with window.crypto.getRandomValues(), as urged by the Mozilla documentation online page beforehand talked about.
  • The desktop model aged a PRNG equipped by Enhance: the mt19937 Mersenne Twister. Mersenne Twister is extremely correct and widely aged PRNG, and MT 19937 is the most favorite Mersenne Twister. It’s uniformly distributed, has a extraordinarily long duration, and is fleet when compared with the heaps of “correct” PRNGs.

Nonetheless, is the utilization of a Mersenne Twister a correct suggestion to manufacture passwords? Surely now not.

The command with this generator is that it’s a ways now not a CSPRNG. Realizing a pair of of its ouputs (624 if this is the case) permits to retrieve its corpulent negate, and to foretell the general values this would possibly generate, plus the general values it has already generated (peek Berlekamp-Massey or Reeds-Sloane algorithms).

Off-the-shelf tools love randcrack are available to atomize Python’s random module, which makes employ of a extraordinarily similar (if now not the similar) implementation of MT 19937. Most efficient very minor diversifications ought to be wanted to atomize Enhance implementation.

In put collectively, exploiting such flaw within the context of Kaspersky’s Password Supervisor is now not easy:

  • Passwords are instant: 12 chars by default. Retrieving 624 password chars requires to decide on 52 passwords.
  • The raw output price is now not known: output price is the predicament within the charset of every letter of the password. More values is also wanted.
  • And we saw that this predicament within the charset is a the product of two values produced by the PRNG.

We attain now not peek a actually uncomplicated formulation to assault this PRNG within the context of KPM.

Seeding the Mersenne Twister

We saw that the PRNG uniformly generates floats in [0, 1[. The code guilty for its initialization must discover love:

mt19937:: result_type seed = ...;
auto mtrand = std:: bind(std:: uniform_real_distribution<float>(0,1), mt19937(seed));

Where does the seed come from? The password technology perform is is known as love this:

std:: string pwlib:: generatePassword(pwdlib:: Protection protection, int seed)
    if (seed == 0) {
        FILETIME feet;

        seed = feet.dwLowDateTime + feet.dwHighDateTime;
    auto mtrand = std:: bind(std:: uniform_real_distribution<float>(0,1), mt19937(seed));
    return generateRandomPassword(protection, mtrand);

Right here is big titillating for 2 causes:

  • The seed is correct 32 bits. That formulation it’s a ways also bruteforced with out problems.
  • An occasion of the PRNG is created every time a password is generated. It formulation Kaspersky Password Supervisor can generated at most $2^{32}$ passwords for a given charset.

GetSystemTimeAsFileTime is aged as a seed ideal if a seed is now not equipped to the generatePassword formulation. How is is known as this sort when a particular person requests a current password? The resolution is:

std:: string pwlib:: generatePassword(pwdlib:: Protection protection)
  return generatePassword(protection, time(0));

So the seed aged to generate every password is the current system time, in seconds. It formulation every occasion of Kaspersky Password Supervisor on the earth will generate the exact identical password at a given 2d. This would possibly be evident to position if every click on on the “Generate” button, within the password generator interface, produced the similar password. Nonetheless, for some motive, password technology is though-provoking: dozens of random chars are displayed whereas the staunch password has already been computed:

Animated password generation

This animation takes extra than 1 2d, so it’s a ways now not conceivable to click on several cases on the “Generate” button within a 2d. That’s positively why the weak spot had now not been found earlier than.

The penalties are obviously base: every password is also bruteforced. For instance, there are 315619200 seconds between 2010 and 2021, so KPM would possibly also generate at most 315619200 passwords for a given charset. Bruteforcing them takes a pair of minutes.

It’s slightly in trend that Web net sites or forums repeat the creation time of accounts. Realizing the creation date of an yarn, an attacker can are trying and bruteforce the yarn password with a shrimp fluctuate of passwords (~100) and save entry to it.

Furthermore, passwords from leaked databases containing hashed passwords, passwords for encrypted archives, TrueCrypt/Veracrypt volumes, and heaps others. is also additionally with out problems retrieved if they had been generated the utilization of Kaspersky Password Supervisor.

An surprising source of entropy: out-of-bounds read

We wrote a proof of thought to be particular we were now not lacking one thing. It generates a listing of 1000 conceivable passwords from the current time. To check the PoC:

  1. Compile the equipped PoC (pwlib.cpp). File ought to be compiled with Visible C++ (floating values within the source code enjoy now not the exact identical values when compiled with Clang or gcc). I aged Visible C++ 2017 for my assessments. The employ of a deliver invite for Visible C++ 32 bits, enter:

     cmake -Bbuild -H.
     msbuild methodpwbrute.vcxproj
  2. Jog compiled executable to manufacture a listing of 1000 passwords.

     Debugpwbrute.exe > pass.txt
  3. Originate a password in Kaspersky Password Supervisor with the next protection:
    • Lowercase ideal
    • 12 chars
  4. Review that the generated password is indeed point out in pass.txt.

It’s now not entirely purposeful, but allowed us to uncover a trojan horse within the password technology task, within the perform that computes the likelihood of look of a given letter shiny the beforehand generated chars. Right here is the pseudo code for the getContextProbabilities formulation:

  const drift *getContextProbabilities(const std:: string &password) {
    std:: string lowercasePassword;

    // Convert to lowercase, care for ideal lowercase
    for (char c :  password) {
      if (islower(c)) {
        lowercasePassword += c;
      } else if (isupper(c)) {
        lowercasePassword += char(c - 'A' + 'a');
    int n = 0;
    for (int i = lowercasePassword.length() - 1; i >= 0; i--) {
      int index = password[i] - 'a'; // FIXME: exchange with lowercasePassword

The password being constructed is transformed to lowercase. Non-letters are removed. Then, there would possibly be an iteration on the password as a substitute of the lowercase password correct created. This ends in a imperfect computation of the index variable (the predicament of a letter within the alphabet). This index is aged to retrieve a element of an array. That ends in an out-of-bounds read of this array.

Frequency of appearances are then computed from uninitialized or arbitrary recordsdata in some cases. Even supposing the algorithm is imperfect, it certainly makes the passwords extra complex to bruteforce in some cases.

The attacked PoC generates candidates for lowercase passwords ideal so as that the index is continually properly computed (else the PoC requires to be tailored).

Kaspersky assigned CVE-2020-27020 to this vulnerability, and published a security advisory on their online page: trend/vulnerability.aspx?el=12430#270421.

Your total versions earlier than these ones are affected:

  • Kaspersky Password Supervisor for Windows 9.0.2 Patch F
  • Kaspersky Password Supervisor for Android
  • Kaspersky Password Supervisor for iOS

On Windows, the Mersenne Twister PRNG has been modified with the BCryptGenRandom perform:

drift RandomFloat(BCRYPT_ALG_HANDLE *hAlgorithm) {
    uint32_t l;
    BCryptGenRandom(*hAlgorithm, (uint8_t *)&l, sizeof(l), 0);
    return (drift)l * (1.0f / 0x100000000);

The return price of this perform used to be now not checked within the beta versions equipped by Kaspersky, but we guess this has been fastened now.

Math.random() within the Web model has been modified with the stable window.crypto.getRandomValues() formulation.

Android and iOS versions enjoy additionally been patched, but we enjoy now not seemed at the fixes.


Kaspersky Password Supervisor aged a elaborate formulation to generate its passwords. This method aimed to manufacture passwords now not easy to atomize for in trend password crackers. Nonetheless, such formulation lowers the strength of the generated passwords in opposition to dedicated tools. We confirmed generate stable passwords taking KeePass as an instance: uncomplicated suggestions love random draws are stable, as quickly as you establish away with the “modulo bias” whereas peeking a letter from a given fluctuate of chars.

We additionally studied the Kaspersky’s PRNG, and confirmed it used to be very veteran. Its interior structure, a Mersenne twister taken from the Enhance library, is now not suited to generate cryptographic cloth. However the critical flaw is that this PRNG used to be seeded with the current time, in seconds. That formulation every password generated by vulnerable versions of KPM is also bruteforced in minutes (or in a 2d while you happen to know approximately the technology time).

In the end, we equipped a proof of thought that shrimp print the corpulent technology formulation aged by KPM. It is also aged to substantiate the flaw is indeed point out in Windows versions of Kaspersky Password Supervisor < 9.0.2 Patch F. By the most reasonable doubtless method, penning this PoC allowed us to position an out of bounds read right by the computation of the frequency of look of password chars, which makes passwords a limited stronger that they are going to must were.


  • June 15, 2019: represent and proof of thought despatched to Kasperky by HackerOne.
  • June 17, 2019: Kaspersky acknowledges it has got the represent.
  • June 25, 2019: Kaspersky confirms the vulnerability.
  • October 4, 2019: Kaspersky sends a non-public Windows method so we are able to substantiate the bugs were fastened, and informs us they are going to rollout a resolution to address beforehand generated passwords earlier than the tip of the yr.
  • October 8, 2019: we verify the vulnerabilities were fastened, but reported a current shrimp defect within the fix.
  • October 10, 2019: Kaspersky Password Supervisor for Windows 9.0.2 Patch D is released, fixing the vulnerabilities, but with out the fix for the reported defect. Web model is additionally updated.
  • October 9, 2019: Kaspersky Password Supervisor for Android model with the fix is released.
  • October 10, 2019: Kaspersky Password Supervisor for iOS model with the fix is released.
  • December 10, 2019: Kaspersky Password Supervisor for Windows 9.0.2 Patch F is released closing the defect in patch D.
  • April 9, 2020: Kaspersky informs us they are going to release a patch in October to address beforehand generated passwords.
  • October 13, 2020: Kaspersky Password Supervisor 9.0.2 Patch M is released, with a notification to users to repeat them some password ought to be re-generated. Kaspersky informs us the similar notification will additionally be point out in cell versions right by the critical quarter of 2021. CVE-2020-27020 has additionally been reserved.
  • December 28, 2020: Kaspersky has the same opinion a represent concerning the vulnerability is also disclosed after the CVE is published.
  • April 27, 2021: Kaspersky security advisory is published.
  • May maybe 14, 2021: Records for the CVE-2020-27020 is published.

Related Articles

Back to top button
%d bloggers like this: