This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Attacking the Diebold Signature Variant – RSA Signatures with Unverified High-order Padding

Ryan W. Gardner Corresponding author. [email protected] Tadayoshi Kohno [email protected] Alec Yasinsac [email protected] Department of Computer Science, Johns Hopkins University, Baltimore, MD 21218, USA Department of Computer Science and Engineering, University of Washington, Seattle, WA 98195, USA Department of Computer Science, Florida State University, Tallahassee, FL 32306, USA
Abstract

We examine a natural but improper implementation of RSA signature verification deployed on the widely used Diebold Touch Screen and Optical Scan voting machines. In the implemented scheme, the verifier fails to examine a large number of the high-order bits of signature padding and the public exponent is three. We present an very mathematically simple attack that enables an adversary to forge signatures on arbitrary messages in a negligible amount of time.

keywords:
Cryptography , RSA signature , Padding , Voting , Cryptanalysis

, ,

1 Background

Standard signatures using the RSA primitive are generally computed in two steps: 1) A one-way transformation TT is applied to a message mm to produce an encoded message MM. 2) The RSA primitive using the private exponent is applied to MM to generate the signature σ\sigma. Given a signature σ\sigma^{\prime} on a message mm^{\prime}, verification generally proceeds similarly: 1) Again, the transformation TT is applied to mm^{\prime} to obtain the encoded message M=T(m)M^{\prime}=T(m^{\prime}), and 2) the RSA primitive using the public exponent is applied to the signature σ\sigma^{\prime} to produce M′′M^{\prime\prime}. 3) Finally, MM^{\prime} and M′′M^{\prime\prime} are checked for equality, and the signature verifies if and only if they are equivalent.

In this paper, we examine an improperly implemented RSA signature scheme, which uses a public exponent of three, where the verifier fails to compare a large number of the high-order bits of the encoded messages MM^{\prime} and M′′M^{\prime\prime}. We briefly present an simple attack against such implementations that enables an adversary to forge signatures on arbitrary messages in a negligible amount of time. Specifically, the attack works for any transformation function TT and for all messages when b<13n3b<\frac{1}{3}\ell_{n}-3, where bb is the number of low-order bits of MM^{\prime} and M′′M^{\prime\prime} that are examined, and n\ell_{n} is the bit-length of the RSA modulus.

This flawed signature scheme has become relevant in practice as we observe multiple instantiations of it in recent (May 2007) versions of the widely used Diebold voting machine firmware.111The code was examined under a charter from the Florida Department of State in June 2007 [8]. We find that the Diebold Touch Screen bootloader 1.3.6 and Optical Scan 1.96.8 employ a natural, yet flawed, implementation of “text-book” RSA where a transformation function T=SHA-1T=\textsf{SHA-1} is used, and the least significant 160 bits (i.e. the SHA-1 hash) of MM^{\prime} and M′′M^{\prime\prime} are exclusively examined when verifying their equality. The verified signatures cover data [8] that, if unauthenticated, has been publicly reported to enable simple arbitrary software installation [11], vote pre-loading (and pre-removing) [10], arbitrary code execution [15], and a mass spreading, vote stealing virus [6] on the voting machines.

Several other research papers have analyzed variants and flawed constructions of RSA authentication systems and their padding and redundancy schemes. Recently, Bleichenbacher describes an attack under conditions similar to those we examine, where a public exponent of three is used and erroneously implemented signature verification code fails to appropriately verify most of the low-order bits of a PKCS-1 padded message [1]. Examining another standard, Coron, Naccache, and Stern extend a chosen plaintext attack on the RSA cryptosystem by Desmedt and Odlyzko [5] to develop a signature forgery strategy that is effective on a scheme that uses a padding format differing from ISO 9796-1 by only one bit [3]. In addition to these more common modes for RSA, several studies have discovered weaknesses, under varying conditions, in a number of schemes that do not hash messages before signing, but instead apply redundancy bits to them [4, 9, 14, 2, 12, 13].

2 Construction

We now describe the construction of the flawed RSA signature scheme we examine.

Let n=pqn=pq be an n\ell_{n}-bit standard RSA modulus equal to the product of two primes, and let dd denote the private exponent such that 3d1 mod ϕ(n)3d\equiv 1{\mbox{~{}{mod}~{}}}\phi(n). Let 33 be the public exponent. We use the notation [x]:ab[x]_{:a-b} to refer to the value obtained by writing bits aba-b of xx as a binary number, where bit 0 is the least significant bit of xx. Furthermore, in the general scheme we find, a message mm is transformed into an encoded message MM using a transformation TT before it is signed. In practice, the function TT usually involves hashing and padding the message mm or applying redundancy to it. However, for the sake of this analysis, we let TT be any function T:{0,1}nT:{\{0,1\}}^{*}\rightarrow\mathbb{Z}_{n}^{*} (where n\mathbb{Z}_{n}^{*} may be approximated as all integers inclusively between 0 and n1n-1).

Signature generation on a message m{0,1}m\in{\{0,1\}}^{*} then consists of the following two classic computations:

M=T(m)M=T(m) (1)
σ=Md mod n\sigma=M^{d}{\mbox{~{}{mod}~{}}}n (2)

and the resulting signature is then σn\sigma\in\mathbb{Z}_{n}^{*}.

Verification proceeds similarly given a signature σ\sigma^{\prime} and a message mm^{\prime}. The verifier computes:

M=T(m)M^{\prime}=T(m^{\prime}) (1)
M′′=σ3 mod nM^{\prime\prime}=\sigma^{\prime 3}{\mbox{~{}{mod}~{}}}n (2)

Then, although an appropriate algorithm would verify that M=M′′M^{\prime}=M^{\prime\prime}, in the faulty construction we find, the verifier checks

[M]:0(b1)=[M′′]:0(b1)[M^{\prime}]_{:0-(b-1)}=[M^{\prime\prime}]_{:0-(b-1)}

for a b<13n3b<\frac{1}{3}\ell_{n}-3. The signature is considered valid if and only if the two values are equivalent.

3 Attack

Assuming the verification scheme described above, we now describe a very simple method for forging signatures on arbitrary messages.

Let mm be any message and M=T(m)M=T(m). It follows from the construction that if we can find a value σ\sigma, such that

σ3M+2bz mod n\sigma^{3}\equiv M+2^{b}z{\mbox{~{}{mod}~{}}}n

for any integer zz where 2bz<n2^{b}z<n, then σ\sigma is a valid signature. (Notice that if 2bz>n2^{b}z>n, its value is likely to alter the lower bb bits of the modular reduction, in which case they will no longer match those of MM.)

In the case where MM is odd, a solution is almost immediate when we consider the problem in 2b\mathbb{Z}_{2^{b}}^{*}. Since we know the order of 2b=2b1\mathbb{Z}_{2^{b}}^{*}=2^{b-1}, we can find the cube root of M mod 2bM{\mbox{~{}{mod}~{}}}2^{b}. First, using Euclid’s extended algorithm, we find rr such that 3r1 mod 2b13r\equiv 1{\mbox{~{}{mod}~{}}}2^{b-1}.

Claim 1

σMr mod 2b\sigma\equiv M^{r}{\mbox{~{}{mod}~{}}}2^{b} is a valid signature on mm when MM is odd.

{@proof}

[Proof.] σ3M3rM1+yϕ(2b)M mod 2b\sigma^{3}\equiv M^{3r}\equiv M^{1+y\phi(2^{b})}\equiv M{\mbox{~{}{mod}~{}}}2^{b} by Euler’s theorem. Since σ\sigma was generated as an element of 2b\mathbb{Z}_{2^{b}}^{*}, we know it can be written as an integer less than 2b2^{b}. Thus, σ323b2n9<n\sigma^{3}\leq 2^{3b}\leq 2^{\ell_{n}-9}<n and σ3M+2bz mod n\sigma^{3}\equiv M+2^{b}z{\mbox{~{}{mod}~{}}}n for some zz where 2bz<n2^{b}z<n.

In the case where MM is even, the same attack does not apply since M2bM\notin\mathbb{Z}_{2^{b}}^{*}. Instead, we use a slightly modified approach to obtain a member from that group.

Choose cc to be the least integer such that (2bc)3>n(2^{b}c)^{3}>n, and let rr be defined as above.

Claim 2

σ=2bc+((M+n)r mod 2b)\sigma=2^{b}c+\left((M+n)^{r}{\mbox{~{}{mod}~{}}}2^{b}\right) is a valid signature on mm when MM is even.

{@proof}

[Proof.] Let τ=((M+n)r mod 2b)\tau=\left((M+n)^{r}{\mbox{~{}{mod}~{}}}2^{b}\right). We will first find an upper bound on σ3\sigma^{3}. Since τ<2b\tau<2^{b},

σ3=(2bc+τ)3<(2b(c+1))3.\sigma^{3}=\left(2^{b}c+\tau\right)^{3}<\left(2^{b}(c+1)\right)^{3}.

Further, (2b(c1))3<n\left(2^{b}(c-1)\right)^{3}<n by our choice of cc, which we can rewrite

c+1<n32b+2.c+1<\frac{\sqrt[3]{n}}{2^{b}}+2.

Combining these two inequalities yields

σ3<(2b(n32b+2))3=(n3+2b+1)3,\sigma^{3}<\left(2^{b}\left(\frac{\sqrt[3]{n}}{2^{b}}+2\right)\right)^{3}=\left(\sqrt[3]{n}+2^{b+1}\right)^{3},

or, by our bound on bb,

σ3<(n3+2(13n3)+1)3=(n3+22n3)3.\sigma^{3}<\left(\sqrt[3]{n}+2^{(\frac{1}{3}\ell_{n}-3)+1}\right)^{3}=\left(\sqrt[3]{n}+2^{-2}\sqrt[3]{n}\right)^{3}.

Thus,

σ3<12564n.\sigma^{3}<\frac{125}{64}n.

Now, with the above bound, and the fact that σ3>n\sigma^{3}>n, by our choice of cc. We can conclude (σ3 mod n)=σ3n(\sigma^{3}{\mbox{~{}{mod}~{}}}n)=\sigma^{3}-n. Hence, σ\sigma is a successful forgery iff σ3nM mod 2b\sigma^{3}-n\equiv M{\mbox{~{}{mod}~{}}}2^{b}. Indeed,

σ3n\displaystyle\sigma^{3}-n (2bc)3+3(2bc)2τ+3(2bc)τ2\displaystyle\equiv(2^{b}c)^{3}+3(2^{b}c)^{2}\tau+3(2^{b}c)\tau^{2}
+τ3n mod 2b\displaystyle\hskip 31.29802pt+\tau^{3}-n{\mbox{~{}{mod}~{}}}2^{b}
τ3n mod 2b.\displaystyle\equiv\tau^{3}-n{\mbox{~{}{mod}~{}}}2^{b}.

Since nn is odd, M+nM+n is a member of 2b\mathbb{Z}_{2^{b}}^{*}, and τ3M+n mod 2b\tau^{3}\equiv M+n{\mbox{~{}{mod}~{}}}2^{b} just as we saw in the MM odd case. Therefore, σ3M mod n mod 2b\sigma^{3}\equiv M{\mbox{~{}{mod}~{}}}n{\mbox{~{}{mod}~{}}}2^{b}.

4 Conclusion

We have found a natural, but improper implementation of an RSA signature scheme in a highly sensitive application, electronic voting. We present an extremely mathematically simple attack against it, which is also very practical.222We verified the attack for the odd case on an optical scan machine provided by the state of Florida. We hope this subtle, but real flaw emphasizes the challenges of properly securing systems and also stresses the importance of approaching such tasks diligently.333After being notified of the flaw, the vendor improved the signature verification code in new versions of their firmware [7] although existing machines that are not updated remain vulnerable, of course.

Acknowledgments

This research was supported by NSF grant CNS-0524252 and by a grant from the Florida Department of State. We also thank Avi Rubin for his comments and support.

References

  • [1] D. Bleichenbacher. RSA signature forgery based on implementation error. Advances in Cryptology – CRYPTO ’06, Rump session, August 2006. Available at http://www.imc.org/ietf-openpgp/mail-archive/msg14307.html.
  • [2] E. Brier, C. Clavier, J.-S. Coron, and D. Naccache. Cryptanalysis of RSA signatures with fixed-pattern padding. In Advances in Cryptology – CRYPTO ’01, volume 2139, pages 433–439. Springer-Verlag, 2001.
  • [3] J.-S. Coron, D. Naccache, and J. P. Stern. On the security of RSA padding. In Advances in Cryptology – CRYPTO ’99, volume 1666, pages 1–18. Springer-Verlag, 1999.
  • [4] W. de Jonge and D. Chaum. Attacks on some RSA signatures. In Advances in Cryptology – CRYPTO ’85, volume 218, pages 18–27. Springer-Verlag, 1986.
  • [5] Y. Desmedt and A. M. Odlyzko. A chosen text attack on the RSA cryptosystem and some discrete logarithm schemes. In Advances in Cryptology – CRYPTO ’85, volume 218, pages 516–522. Springer-Verlag, 1986.
  • [6] A. J. Feldman, J. A. Halderman, and E. W. Felten. Security analysis of the diebold accuvote-ts voting machine. In USENIX/ACCURATE Electronic Voting Technology Workshop – EVT ’07, 2007.
  • [7] D. Gainey, M. Gerke, and A. Yasinsac. Software review and security analysis of the diebold voting machine software, supplemental report. Technical report, Florida Department of State, August 2007.
  • [8] R. Gardner, A. Yasinsac, M. Bishop, T. Kohno, Z. Hartley, J. Kerski, D. Gainey, R. Walega, E. Hollander, and M. Gerke. Software review and security analysis of the diebold voting machine software. Technical report, Florida Department of State, July 2007.
  • [9] M. Girault and J.-F. Misarsky. Selective forgery of RSA signatures using redundancy. In Advances in Cryptology - EUROCRYPT ’97, volume 1233, pages 495–508. Springer-Verlag, 1997.
  • [10] H. Hursti. Critical security issues the diebold optical scan design, July 2005. Available at http://www.blackboxvoting.org/BBVreport.pdf.
  • [11] H. Hursti. Diebold tsx evaluation: Critical security issues with diebold tsx, May 2006. Available at http://www.blackboxvoting.org/BBVreportIIunredacted.pdf.
  • [12] A. K. Lenstra and I. Shparlinski. Selective forgery of RSA signatures with fixed-pattern padding. In Practice and Theory in Public Key Cryptosystems – PKC ’02, volume 2274, pages 228–236. Springer-Verlag, 2002.
  • [13] M. Michels, M. Stadler, and H.-M. Sun. On the security of some variants of the RSA signature scheme. In European Symposium on Research in Computer Security – ESORICS ’98, volume 1485, pages 85–96. Springer-Verlag, 1998.
  • [14] J.-F. Misarsky. A multiplicative attack using LLL algorithm on RSA signatures with redundancy. In Advances in Cryptology – CRYPTO ’97, volume 1294, pages 221–234. Springer-Verlag, 1997.
  • [15] D. Wagner, D. Jefferson, M. Bishop, C. Karlof, and N. Sastry. Security analysis of the diebold accubasic interpreter. Technical report, Voting Systems Technology Assessment Advisory Board, Office of the Secretary of State of California, February 2006.