How secure is authentication in mysql protocol?

后端 未结 2 875
野趣味
野趣味 2021-02-15 09:49

My users are using MS Access and ODBC connector to connect to my remote MySQL database. I wonder how secure this is, in the sense of possible password disclosure to 3rd party. I

相关标签:
2条回答
  • 2021-02-15 10:10

    What is it that you want to be "safe to eavesdropping or even man-in-the-middle attacks"? Your password, or your data?

    The title of your question refers specifically to authentication. MySQL does a reasonable job of protecting your password from eavesdroppers (it is not sent plaintext, and the use of a nonce defeats replay attacks). Citing MySQL protocol internals:

    MySQL 4.1 and later

    Remember that mysql.user.Password stores SHA1(SHA1(password))

    • The server sends a random string (scramble) to the client
    • the client calculates:
      • stage1_hash = SHA1(password), using the password that the user has entered.
      • token = SHA1(scramble + SHA1(stage1_hash)) XOR stage1_hash
    • the client sends the token to the server
    • the server calculates
      • stage1_hash' = token XOR SHA1(scramble + mysql.user.Password)
    • the server compares SHA1(stage1_hash') and mysql.user.Password
    • If they are the same, the password is okay.

    (Note SHA1(A+B) is the SHA1 of the concatenation of A with B.)

    This protocol fixes the flaw of the old one, neither snooping on the wire nor mysql.user.Password are sufficient for a successful connection. But when one has both mysql.user.Password and the intercepted data on the wire, he has enough information to connect.

    However, authenticated sessions continue in plaintext: an eavesdropper will be able to see all queries and results; and a MITM would be able to make alterations to the same. As stated in the manual:

    By default, MySQL uses unencrypted connections between the client and the server. This means that someone with access to the network could watch all your traffic and look at the data being sent or received. They could even change the data while it is in transit between client and server.

    Whilst you may not like the answer, SSL is the tool designed to defeat both data eavesdropping (how else can the communications be encrypted?) and MITM attacks (how else can either party verify that its peer is who it thinks it is?). Indeed, if the mysql client-server protocol alone defeated these threats then there would be no reason to use mysql over SSL (and thus it would be unlikely to be a supported configuration).

    0 讨论(0)
  • 2021-02-15 10:21

    Short answer: Yes, the protocol is safe from Eavesdropping and MITM attacks.

    Only if the attacker manages to sniff an authentication attempt AND if the attacker knows the contents of mysql.user, then he can subsequently authenticate against the server. For example if you're using the same password on two different mysql servers and the attacker gains access to one of them, he can also connect to the second server.

    0 讨论(0)
提交回复
热议问题