Monday, June 14, 2021

Deprecated SSH Cryptographic Settings

 



Our security scanner Qualys reported the vulnerability “Deprecated SSH Cryptographic Settings” across RHEL6 & RHEL7 fleet servers.

The scan report provided description of the threat posed by the vulnerability, recommendation for correcting the problem and the result which shows how Qualys verified the vulnerability.

Vulnerability : Deprecated SSH Cryptographic Settings
QID: 38739
THREAT: The SSH protocol (Secure Shell) is a method for secure remote login from one computer to another.The target is using deprecated SSH cryptographic settings to communicate.
IMPACT: A man-in-the-middle attacker may be able to exploit this vulnerability to record the communication to decrypt the session key and even the messages.
SOLUTION: Avoid using deprecated cryptographic settings. Use best practices when configuring SSH.
RESULTS:

Type Name
key exchange diffie-hellman-group1-sha1
cipher arcfour256
cipher arcfour128
cipher 3des-cbc
cipher blowfish-cbc
cipher cast128-cbc
cipherarcfour

So in our case, looking at the result section, qualys has found the listed ciphers and Keyexchange methods that are enabled/configured on our servers.

The remediation steps started as follows:

  • Initial Test (prior to remediation)
  • Tweaking the relevant config file
  • Post Test (after remediation)

Initial Test

We know that this is a SSH related vulnerability, So running below command would output the current ciphers & kexalgorithm methods configured on the server. We can see that the scanner reported ciphers & kexalgorithm methods are present.

Note: -T option is used for Extended test mode to Check the validity of the configuration file, output the effective configuration to stdout and then exit.

[root@linuxminion ~]# sshd -T | egrep -iw "ciphers|kexalgorithms"
ciphers 3des-cbc,blowfish-cbc,cast128-cbc,arcfour,arcfour128,arcfour256,aes128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
kexalgorithms diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,curve25519-sha256@libssh.org,gss-gex-sha1-,gss-group1-sha1-,gss-group14-sha1-
[root@linuxminion ~]

Now let’s do the actual SSH test connecting to this host using the deprecated ciphers & kexalgorithm method and see how it goes.

[root@testserver ~]# ssh ec2-user@linuxminion -ociphers=arcfour256 -okexalgorithms=diffie-hellman-group1-sha1
 Last login: Tue Jun 25 23:44:28 2019 from ip-172-31-7-76.ap-southeast-2.compute.internal
[ec2-user@linuxminion ~]$

Yes, it succeeded because that cipher & kexalgorithm method are configured on our server.

When we run the same command with -vv option we get the verbose SSH output and below lines are of interest as they show the cipher negotiated from client to server and vice versa

 debug1: kex: server->client arcfour256 hmac-md5-etm@openssh.com none
 debug2: mac_setup: setup hmac-md5-etm@openssh.com
 debug1: kex: client->server arcfour256 hmac-md5-etm@openssh.com none
 debug1: kex: diffie-hellman-group1-sha1 need=16 dh_need=16
 debug1: kex: diffie-hellman-group1-sha1 need=16 dh_need=16

Tweaking the relevant config file : (sshd_config)

The ciphers are configured in the /etc/ssh/sshd_config file and hence we will now disable the deprecated ciphers & kexalgorithm methods by adding/modifying below lines in config file.
Here we are excluding those ciphers & kexalgorithm method and including only those that we want to enable.

Ciphers aes128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com

Kexalgorithms diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,curve25519-sha256@libssh.org,gss-gex-sha1-,gss-group1-sha1-,gss-group14-sha1-

Post configuration, the output looks as below in our case

[root@linuxminion ~]# sshd -T | egrep -iw "ciphers|kexalgorithms"
Ciphers aes128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
Kexalgorithms diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,curve25519-sha256@libssh.org,gss-gex-sha1-,gss-group14-sha1-
[root@linuxminion ~]#

Note: Restart the SSHD service post config change to /etc/ssh/sshd_config

In case of RHEL6
# service sshd restart

In case of RHEL7
# systemctl restart sshd.service

Post Test (after remediation)

Test the SSH connection to the server using the disabled cipher & kexalgorithm method and it should error out as below:

“No matching cipher found” for Cipher
“Unable to negotiate a key exchange method” for kexalgorithm

which is true as its not listed/configured in our sshd_config.

[root@testserver ~]# ssh ec2-user@linuxminion -ociphers=arcfour256
no matching cipher found: client arcfour256 server aes128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
[root@testserver ~]#

[root@testserver ~]# ssh ec2-user@linuxminion -okexalgorithms=diffie-hellman-group1-sha1
Unable to negotiate a key exchange method
[root@testserver ~]#

Lastly, have the server scanned again by scanning tool to confirm for remediation of this vulnerability. The report should not pick this one.

References:

http://man7.org/linux/man-pages/man5/sshd_config.5.html

Tuesday, May 25, 2021

installation Guide of SoftEther VPN Client on Linux

 

If you have a VPN account from CITeS (Center for IT Services - UoM) and you want to configure your SoftEther VPN client on your ubuntu machine, this is the best guide for you. This blog post is a conversion to the linux environment from the guide here given for windows environment . I’ll explore the steps in general and give the example using CITeS VPN account. So you can apply the same procedure for another VPN server account too.

As a prerequisite you should have created an account from a VPN server. (For this case from CITeS VPN server)

1.Download and Install SoftEther VPN Client

  1. Download SoftEther VPN Client software from their official website (https://www.softether.org)
Navigation to Download SoftEther VPN

3.Click on Download SoftEther VPN link.

Select Component : SoftEther VPN Client

Select Platform : Linux

Select CPU : Select the appropriate CPU from the Drop down

4. Click on the appropriate downloading link based on the version of the software.

5. Extract the downloaded tar.gz file. Here after I will refer the extracted folder as <vpnclient>

6. Navigate to <vpnclient>folder and open a terminal.

7. Execute make command and accept all license agreements by entering the number relevant to “Yes”.

execute make command

8. After the completion of make command process, start the vpn client using:

sudo ./vpnclient start

9. Then you will get the following message.

vpn client successfully started

10. Before going to the configuration part please test the VPN client installation.

11. Execute ./vpncmd and select No 3 to enter to Use of VPN Tools (certificate creation and Network Traffic Speed Test Tool) option.

12. Then run check command.

If all tests are passed, you are good to go.

check vpn client installation

13. Press Ctrl+C to terminate that process.

2.Configure SoftEther VPN Client

  1. Execute ./vpncmd on a terminal opened inside the <vpnclient> folder.
connected to vpn localhost

5. Create a virtual interface to connect to the VPN server.

NicCreate <name for virtual interface>

eg : NicCreate vpn_se

6. Create an VPN client account using the following command.

AccountCreate <name>

In this case : AccountCreate CITeS

7. Then setup the account with your details.

Genearlly,

Destination VPN Server Host Name and Port Number:<VPN IP address>:<SoftEther VPN Port>

Destination Virtual Hub Name: <Hub Name>

Connecting User Name: <Username of LMS, Moodle, UoM_Wireless, UoM Email>

Used Virtual Network Adapter Name: <Created virtual interface’s name>

Specifically,

Destination VPN Server Host Name and Port Number:svpn.mrt.ac.lk:443

Destination Virtual Hub Name: <Enter the appropriate one according to the following drop down>

Connecting User Name: <Username of LMS/ Moodle/ UoM_Wireless/ UoM Email>

Used Virtual Network Adapter Name: vpn_se (earlier created one)

You will get The command completed successfully message if you do it correctly.

8. Setup a password to the created account.

AccountPassword <account name>

Set a password and confirm it. SPECIALLY, for CITeS account you should give LMS/ Moodle/ UoM_Wireless/ UoM Email password

For Specify standard or radius: input give radius

9. Now you can connect to the SoftEther VPN clinet account through the created account. For that issue:

AccountConnect <account name>

In this example: AccountConnect CITeS

10. Issue the command AccountList and check the connectivity. If you get Connected status it is good to to for the next step.

Account details

3. Add Route to the Routing Table

  1. Issue cat /proc/sys/net/ipv4/ip_forward to check whether ip forward is enabled in your system.

If you get “1” go to the step №2 .

If you get “0” , Navigate to /etc/sysctl.conf file and uncomment net.ipv4.ip_forward=1 line. Open a terminal and issue command sysctl -p

Then check whether you get “1” for the first step.

2. Open a terminal and issue the command sudo ifconfig . Now you should see the virtual network adapter you created earlier. But you do not have a ip address for it.

3. Issue the command sudo dhclient <virtual_network_adapter_name>

According to the above example : sudo dhclient <vpn_vpn_se>

After few moments you will get an ip address from the VPN Server.

4. Then issue sudo netstat -rn command to see the routing table. You need to add a static route here.

sudo ip route add <gateway of the ip range of your virtual network adapter>/<subnetmask> via <ip you got for the virtual network adapter>

Except the last route adding step all of the above steps are one time work.

Now you should able to connect to the required server through the VPN Client. 😃

Cheers. 🥳

Software Engineer@ WSO2 | Computer Science and Engineering graduate@ University of Moratuwa, SriLanka