When you use the Oracle JDBC client library to make an Oracle connection, is the password or the security-handshake encrypted by default? (Want to know if there is a risk that the password can be sniffed over the wire when making a connection using the Oracle JDBC client library)
The password is always encrypted when in transit over the network.
That is not to say that it is impervious to attack. If an attacker can obtain the hash of a user's password and they can monitor network traffic between a legitimate client and the database, then it is possible to obtain the plain-text password.
For the curious, here is a summary of the authentication process across various versions of the Oracle database software. The steps dealing with the transit of the encrypted password are in bold. It is not entirely intuitive which version of the authentication protocol is being used by the JDBC driver because it doesn't always match its advertised version. This is because the client can negotiate which protocol it wishes to use. For example, the 11g JDBC driver may not necessarily use the 11g authentication protocol when connecting to an 11g database (it may fall back to the 10g authentication protocol). I forget which drivers use which protocols.
Authentication protocol in Oracle Database 8
- The client requests a server session key for a particular user.
- The server generates a server session key.
- The server encrypts the server session key using the requested user's password hash as the secret key.
- The server transmits the encrypted server session key to the client.
- The client decrypts the encrypted server session key using the user's password hash as the secret key.
- The client encrypts the user's password using the server session key as the secret key. (proprietary algorithm based on DES)
- The client transmits the encrypted password to the server.
- The server decrypts the encrypted password using its server session key as the secret key.
- The server computes the hash of the decrypted password.
- If the computed password hash (from step 9) matches the copy stored on the server, then the user has provided the correct password.
Authentication protocol in Oracle Database 9i
- The client requests a server session key for a particular user.
- The server generates a server session key.
- The server encrypts the server session key using the requested user's password hash as the secret key.
- The server transmits the encrypted server session key to the client.
- The client decrypts the encrypted server session key using the user's password hash as the secret key.
- The client encrypts the user's password using the server session key as the secret key. (proprietary algorithm based on DES)
- The client transmits the encrypted password to the server.
- The server decrypts the encrypted password using its server session key as the secret key.
- The server computes the hash of the decrypted password.
- If the computed password hash (from step 9) matches the copy stored on the server, then the user has provided the correct password.
Authentication protocol in Oracle Database 10g
- The client requests a session key from the server, specifying which user it wishes to connect as.
- The server generates a server session key.
- The server encrypts the server session key using the requested user's password hash as the secret key.
- The server transmits the encrypted server session key to the client.
- The client decrypts the encrypted server session key using the requested user's password hash as the secret key.
- The client generates a client session key.
- The client combines the client session key with the server session key.
- The client salts the user's password.
- The client encrypts the user's salted password using the combined session keys (from step 7) as its secret key. (AES-128)
- The client encrypts the client session key using the user's password hash as the secret key.
- The client transmits the encrypted client session key and the encrypted, salted user password to the server.
- The server decrypts the encrypted client session key using the requested user's password hash.
- The server combines the client session key with its server session key.
- The server decrypts the encrypted, salted password using the combined session keys (from step 13) as the secret key.
- The server un-salts the salted password.
- The server hashes the decrypted password.
- The server compares the computed password hash (from step 16) with the stored password hash. If they are equal, the user has provided the correct password.
Authentication protocol in Oracle Database 11g
- The client requests a session key from the server, specifying which user it wishes to connect as.
- The server generates a server session key.
- The server generates verifier data.
- The server encrypts the server session key using the requested user's password hash as the secret key.
- The server transmits the encrypted server session key ("AUTH_SESSKEY") and the verifier data ("AUTH_VFR_DATA") to the client.
- The client hashes the user's password using the verifier data as the salt.
- The client decrypts the encrypted server session key using the user's password hash as the secret key.
- The client generates a client session key.
- The client combines the client session key with the server session key.
- The client salts the user's password.
- The client encrypts the user's salted password using the combined session keys (from step 9) as its secret key. (AES-192)
- The client encrypts the client session key using the user's password hash as the secret key.
- The client transmits the encrypted client session key and the encrypted, salted user password to the server.
- The server decrypts the encrypted client session key using the requested user's password hash.
- The server combines the client session key with its server session key.
- The server decrypts the encrypted, salted password using the combined session keys (from step 15) as the secret key.
- The server un-salts the salted password.
- The server hashes the decrypted password.
- The server compares the computed password hash (from step 18) with the stored password hash. If they are equal, the user has provided the correct password.