VOOZH about

URL: https://link.springer.com/chapter/10.1007/978-3-031-30589-4_7?error=cookies_not_supported&code=8d1c579c-849b-49b1-a5c9-860ec0872d57

⇱ Caveat Implementor! Key Recovery Attacks on MEGA | Springer Nature Link


Skip to main content

Caveat Implementor! Key Recovery Attacks on MEGA

  • Conference paper
  • First Online:

Abstract

MEGA is a large-scale cloud storage and communication platform that aims to provide end-to-end encryption for stored data. A recent analysis by Backendal, Haller and Paterson (IEEE S &P 2023) invalidated these security claims by presenting practical attacks against MEGA that could be mounted by the MEGA service provider. In response, the MEGA developers added lightweight sanity checks on the user RSA private keys used in MEGA, sufficient to prevent the previous attacks.

We analyse these new sanity checks and show how they themselves can be exploited to mount novel attacks on MEGA that recover a target user’s RSA private key with only slightly higher attack complexity than the original attacks. We identify the presence of an ECB encryption oracle under a target user’s master key in the MEGA system; this oracle provides our adversary with the ability to partially overwrite a target user’s RSA private key with chosen data, a powerful capability that we use in our attacks. We then present two distinct types of attack, each type exploiting different error conditions arising in the sanity checks and in subsequent cryptographic processing during MEGA ’s user authentication procedure. The first type appears to be novel and exploits the manner in which the MEGA code handles modular inversion when recomputing \(u=q^{-1} \bmod p\). The second can be viewed as a small subgroup attack (van Oorschot and Wiener, EUROCRYPT 1996, Lim and Lee, CRYPTO 1998). We prototype the attacks and show that they work in practice.

As a side contribution, we show how to improve the RSA key recovery attack of Backendal-Haller-Paterson against the unpatched version of MEGA to require only 2 logins instead of the original 512.

We conclude by discussing wider lessons about secure implementation of cryptography that our work surfaces.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+
from $39.99 /Month
  • Starting from 10 chapters or articles per month
  • Access and download chapters and articles from more than 300k books and 2,500 journals
  • Cancel anytime
View plans

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
eBook
USD 99.00
Price excludes VAT (USA)
Softcover Book
USD 129.99
Price excludes VAT (USA)

Tax calculation will be finalised at checkout

Purchases are for personal use only

Similar content being viewed by others

Discover the latest articles, books and news in related subjects, suggested using machine learning.

Notes

  1. 1.

    This by itself does not suffice for authenticated encryption security, but presents the “immediate” level of countermeasures, i.e. the most easily achievable solution in the short term. [2] outlines further levels of countermeasures termed “minimal” and “recommended”, which provide better guarantees but require more fundamental changes to the MEGA platform.

  2. 2.

    For \( x \in \mathbb {Z}\), the value of \(| x |_{\textsf{b}} \) as understood by the MEGA client implementations is not always exact. In the big integer representation used by the web client, \(| x |_{\textsf{b}} \) is normally rounded up to the closest multiple of 8 or 32.

  3. 3.

    For instance, we omit the file attributes in our description for simplicity.

  4. 4.

    We include the prime \( p ' \) for several reasons. First, because of one of the uncaught errors, we must make sure that \( q \bmod p \ne 0\). Further, to avoid false positives from error \(\bot _{5} \), we need the \(\gcd ( p , q ) \ne 1\) signal to be equivalent to \(\gcd ( p , q ) = r _ i \).

  5. 5.

    Note that the attack can be easily modified to use one less login for each \( r _ i \). This is because, in the online phase, if the server does not get a positive answer from the oracle for any of the values \( t \in \left\{ 0, \ldots , r _ i - 2\right\} \), it means that the value \( r _ i - 1\) is the correct one and so does not need to be submitted explicitly.

  6. 6.

    That is, \({\texttt{ptd}}[{0}:{4}] = {\texttt{p}}[{124}:{128}] \) for all \(\texttt{p} \), and \({\texttt{ptp} _ i }[{0}:{2}] = {\texttt{q} ^*}[{126}:{128}] \) for all \(\texttt{q} ^*\).

  7. 7.

    There is a possibility that \( d ^* \bmod ( p - 1)( q - 1) = 0\) where \( d ^* \leftarrow d ' + ( d \bmod 2^{1968})\) and \( d \) is the original value encrypted in \(\texttt{ct} \). Because of the uncaught non-termination bug arising during the computation of \(( d ^*)^{-1} \bmod ( p - 1)( q - 1)\), in this case the attack would fail, but this is highly unlikely to happen in practice.

  8. 8.

    Note that the server does not know whether this is because prior to zero-padding, we have \(| m ^* |_{\textsf{B}} \le | N ^* |_{\textsf{B}} - 2\) and therefore trivially \({\texttt{m} ^*}[{1}] = \texttt{00} \) or because \(| m ^* |_{\textsf{B}} = | N ^* |_{\textsf{B}} \) and \({\texttt{m} ^*}[{1}] = \texttt{00} \). However, the root cause is immaterial to our attack.

  9. 9.

    The factors do not need to be common between \(( p ^* - 1)\) and \(( q ^* - 1)\), and can be freely distributed between the two.

  10. 10.

    These primes could repeat, the goal here is to avoid \(( p ^* - 1)( q ^* - 1)\) having any other small factors except for \( r _0 , \ldots , r _{ n -1}\).

  11. 11.

    Note that by the choice of \( d ^\prime \), overwriting the least significant full block of \( d ^\prime \) with \( B \) is equivalent to adding \(2^{48} \cdot B \) to \( d ^\prime \).

  12. 12.

    An honest response refers to the data that an honest server would have sent. Note that in this case, the “honest” \(\texttt{uh} \) will not match the value recovered from \(\texttt{c} ^*_{ i , x }\), but this check only comes after the errors triggered by the attack. The attacker could equally replace the \(\texttt{uh} \) value with an arbitrary 11-byte UTF-8 string.

  13. 13.

    This is also why we cannot make the block-aligned simplification for this attack, because if we aligned it such that the least-significant block of \( d ^*\) is full and therefore placed our target block \( B \) there, then if \( B \equiv 0 \pmod {2}\) the client would output error \(\bot _{6} \) on all queries.

  14. 14.

    Note that an 11 B byte string interpreted as a valid UTF-8 string will likely not be a string of size 11, i.e. a string consisting of 11 characters, since not all byte values are interpreted as text and non-ASCII characters require multiple bytes to encode [36].

  15. 15.

    One alternative is to instead for all \( t \in \mathcal {T} _ i \) submit \( x ' \leftarrow x \cdot t ^{-1} \cdot t _j \bmod r _ i \) for some \( t _j \in \mathcal {T} _ i , t _j \ne t \), and use the original error \((\bot _{2}, 254)\) as the confirmation signal. This still has a potential for false positives and false negatives, however. A final, and most expensive, failover strategy is then to cycle through all values of \( x \), saving the ones for which the client returns \((\bot _{2}, 254)\) and then running an offline computation to determine which \( x \) values are matched to which \( t \) values.

  16. 16.

    The traditional presentation of this algorithm invokes the LLL algorithm which gives a short vector that is at most an exponential factor away from the shortest vector. However, the lattice dimensions involved here are in the range where the shortest vector problem (SVP) can be solved efficiently in practice – say, up to dimension 150 [7] – and we may thus simply assume we solve SVP. In any case, the exponential factor is \(\approx 1.0219^{h}\) which is \(< 3\) for \(h \le 50\).

  17. 17.

    We extract \(g(x)\) as \(g^{(j)} {:}{=}v_{j}/X^{j} \in \mathbb {Z}\).

  18. 18.

    We note that this computation is “proudly parallel” or “embarrassingly parallel”. This is because for each of our \(2^{16}\) guesses we can run an independent lattice reduction. We also note that the running time is independent of whether the input instance corresponds to a correct or incorrect guess. Moreover, incorrect solutions resulting from incorrect guesses can be filtered out using the known public key.

  19. 19.

    In contrast to timing-based side-channel attacks, generally considered less practical in the remote, as opposed to local, setting.

References

  1. Albrecht, M.R., Mareková, L., Paterson, K.G., Stepanovs, I.: Four attacks and a proof for Telegram. In: 43rd IEEE Symposium on Security and Privacy, SP 2022, San Francisco, CA, USA, 22–26 May 2022, pp. 87–106. IEEE (2022). https://doi.org/10.1109/SP46214.2022.9833666

  2. Backendal, M., Haller, M., Paterson, K.G.: MEGA: malleable encryption goes awry. In: 44th IEEE Symposium on Security and Privacy (2023, to appear). https://eprint.iacr.org/2022/959

  3. Barbosa, M., et al.: SoK: computer-aided cryptography. In: 2021 IEEE Symposium on Security and Privacy, pp. 777–795. IEEE Computer Society Press, May 2021. https://doi.org/10.1109/SP40001.2021.00008

  4. Bleichenbacher, D.: Chosen ciphertext attacks against protocols based on the RSA encryption standard PKCS #1. In: Krawczyk, H. (ed.) CRYPTO 1998. LNCS, vol. 1462, pp. 1–12. Springer, Heidelberg (1998). https://doi.org/10.1007/BFb0055716

  5. Bruseghini, L., Paterson, K.G., Huigens, D.: Victory by KO: attacking OpenPGP using key overwriting. In: ACM Conference on Computer and Communications Security (ACM CCS) (2022, to appear). https://doi.org/10.3929/ethz-b-000545839

  6. Coppersmith, D.: Finding a small root of a bivariate integer equation; factoring with high bits known. In: Maurer, U. (ed.) EUROCRYPT 1996. LNCS, vol. 1070, pp. 178–189. Springer, Heidelberg (1996). https://doi.org/10.1007/3-540-68339-9_16

  7. Ducas, L., Stevens, M., van Woerden, W.: Advanced lattice sieving on GPUs, with tensor cores. In: Canteaut, A., Standaert, F.-X. (eds.) EUROCRYPT 2021. LNCS, vol. 12697, pp. 249–279. Springer, Cham (2021). https://doi.org/10.1007/978-3-030-77886-6_9

  8. Howgrave-Graham, N.A.: Computational Mathematics Inspired by RSA. Ph.D. thesis, University of Bath (1998). https://researchportal.bath.ac.uk/en/studentTheses/computational-mathematics-inspired-by-rsa

  9. Howgrave-Graham, N.: Finding small roots of univariate modular equations revisited. In: Darnell, M. (ed.) Cryptography and Coding 1997. LNCS, vol. 1355, pp. 131–142. Springer, Heidelberg (1997). https://doi.org/10.1007/BFb0024458

  10. Klima, V., Rosa, T.: Attack on private signature keys of the OpenPGP format, PGP(TM) programs and other applications compatible with OpenPGP. Cryptology ePrint Archive, Report 2002/076 (2002). https://eprint.iacr.org/2002/076

  11. Len, J., Grubbs, P., Ristenpart, T.: Partitioning oracle attacks. In: Bailey, M., Greenstadt, R. (eds.) USENIX Security 2021, pp. 195–212. USENIX Association, August 2021

  12. Lim, C.H., Lee, P.J.: A key recovery attack on discrete log-based schemes using a prime order subgroup. In: Kaliski, B.S. (ed.) CRYPTO 1997. LNCS, vol. 1294, pp. 249–263. Springer, Heidelberg (1997). https://doi.org/10.1007/BFb0052240

  13. May, A.: Using LLL-reduction for solving RSA and factorization problems. In: Nguyen, P., Vallée, B. (eds.) The LLL Algorithm. Information Security and Cryptography. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-02295-1_10

  14. MEGA: About Us, September 2022. https://mega.io/about

  15. MEGA: Mega.nz web client (2022). https://github.com/meganz/webclient

  16. MEGA: Security White Paper, June 2022. https://mega.nz/SecurityWhitepaper.pdf

  17. MEGA: webclient - #15273: Patch for ETH Zurich exploit, June 2022. https://github.com/meganz/webclient/commit/d2a0d054d4dbb90f035b3b4b421f780adafaa78e

  18. MEGA: webclient - #15295: Output detailed information about RSA decoding failures, June 2022. https://github.com/meganz/webclient/commit/cd4ab89b2cd0e388b0ea55753b86c8808f810138

  19. MEGA: webclient - asmcrypto.js, August 2022. https://github.com/meganz/webclient/blob/v4.21.4/js/vendor/asmcrypto.js

  20. MEGA: webclient - asmcrypto.js: Modulus, August 2022. https://github.com/meganz/webclient/blob/v4.21.4/js/vendor/asmcrypto.js#L10325

  21. MEGA: webclient - asmcrypto.js: Modulus_inverse. https://github.com/meganz/webclient/blob/v4.21.4/js/vendor/asmcrypto.js#L10382 (August 2022)

  22. MEGA: webclient - asmcrypto.js: mredc, August 2022. https://github.com/meganz/webclient/blob/v4.21.4/js/vendor/asmcrypto.js#L9706

  23. MEGA: webclient - asmcrypto.js: RSA_decrypt, August 2022. https://github.com/meganz/webclient/blob/v4.21.4/js/vendor/asmcrypto.js#L10746

  24. MEGA: webclient - crypto.js: api_updfkeysync, September 2022. https://github.com/meganz/webclient/blob/v4.21.4/js/crypto.js#L3050

  25. MEGA: webclient - crypto.js: crypto_decodeprivkey, August 2022. https://github.com/meganz/webclient/blob/v4.21.4/js/crypto.js/#L2047

  26. MEGA: webclient - nodedec.js: crypto_rsadecrypt, August 2022. https://github.com/meganz/webclient/blob/v4.21.4/nodedec.js/#L550

  27. MEGA: webclient - security.js: decryptRsaKeyAndSessionId, August 2022. https://github.com/meganz/webclient/blob/v4.21.4/js/security.js#L1231

  28. Micheli, G.D., Heninger, N.: Recovering cryptographic keys from partial information, by example. Cryptology ePrint Archive, Report 2020/1506 (2020). https://eprint.iacr.org/2020/1506

  29. Ryan, K., Heninger, N.: Cryptanalyzing MEGA in six queries. Cryptology ePrint Archive, Report 2022/914 (2022). https://eprint.iacr.org/2022/914

  30. Shakevsky, A., Ronen, E., Wool, A.: Trust dies in darkness: shedding light on samsung’s TrustZone keymaster design. Cryptology ePrint Archive, Report 2022/208 (2022). https://eprint.iacr.org/2022/208

  31. Stein, W., et al.: Sage Mathematics Software Version 9.5. The Sage Development Team (2022). http://www.sagemath.org

  32. The FPLLL development team: FPLLL, a lattice reduction library (2021). https://github.com/fplll/fplll

  33. The mitmproxy development team: mitmproxy - an interactive HTTPS proxy (2022). https://mitmproxy.org/

  34. van Oorschot, P.C., Wiener, M.J.: On Diffie-Hellman key agreement with short exponents. In: Maurer, U. (ed.) EUROCRYPT 1996. LNCS, vol. 1070, pp. 332–343. Springer, Heidelberg (1996). https://doi.org/10.1007/3-540-68339-9_29

  35. Vanhoef, M., Ronen, E.: Dragonblood: analyzing the dragonfly handshake of WPA3 and EAP-pwd. In: 2020 IEEE Symposium on Security and Privacy, pp. 517–533. IEEE Computer Society Press, May 2020. https://doi.org/10.1109/SP40000.2020.00031

  36. Wikipedia: UTF-8 (2022). https://en.wikipedia.org/wiki/UTF-8

Download references

Acknowledgements

The research of Mareková was carried out in part during a visit to the Applied Cryptography Group at ETH Zürich. She was also supported by the EPSRC and the UK Government as part of the Centre for Doctoral Training in Cyber Security at Royal Holloway, University of London (EP/P009301/1). The work of Paterson was supported in part by a gift from VMware. The work of Albrecht was done while Albrecht was at Royal Holloway.

Author information

Authors and Affiliations

  1. King’s College London, London, UK

    Martin R. Albrecht

  2. Applied Cryptography Group, ETH Zurich, Zurich, Switzerland

    Miro Haller & Kenneth G. Paterson

  3. Information Security Group, Royal Holloway, University of London, London, UK

    Lenka Mareková

Authors
  1. Martin R. Albrecht
  2. Miro Haller
  3. Lenka Mareková
  4. Kenneth G. Paterson

Corresponding author

Correspondence to Lenka Mareková.

Editor information

Editors and Affiliations

  1. Bar-Ilan University, Ramat Gan, Israel

    Carmit Hazay

  2. Simula UiB, Bergen, Norway

    Martijn Stam

About this paper

Cite this paper

Albrecht, M.R., Haller, M., Mareková, L., Paterson, K.G. (2023). Caveat Implementor! Key Recovery Attacks on MEGA. In: Hazay, C., Stam, M. (eds) Advances in Cryptology – EUROCRYPT 2023. EUROCRYPT 2023. Lecture Notes in Computer Science, vol 14008. Springer, Cham. https://doi.org/10.1007/978-3-031-30589-4_7

Download citation

Publish with us

Profiles

  1. Lenka Mareková View author profile

Societies and partnerships