I’m sure many of you have heard by this point that there is a reported vulnerability in openSSL and openSSH.  The basis of this is that they keys that are generated when you use these tools (ie; installing openssh-server, etc) are generated in a weak manner and can be prone to simple brute force attacking.

If you’ve never installed openssh-server, used openssh-clients or generated an X.509 certificate you should be safe.  If you have done any of the above keep reading for a validation and fix instructions.  It can’t hurt to run the validation script in either case, just to be safe.

Security patches have been deployed to the Ubuntu archives so the first step is to, of course, apply any security patches available.

Am I Affected?

The first item at hand is verifying whether or not you have been affected by the vulnerability.  As mentioned above there are some common tasks that would qualify, but lets test your machine to make sure.

Download the script linked below and run it using the example syntax below:

dowkd.pl.gz (Download this file and unzip)

dowkd.pl PGP signature (Optionally verify the signature of the script)

Cut-n-Paste command-line example of downloading and running the test:

wget -c http://security.debian.org/project/extra/dowkd/dowkd.pl.gz
gunzip dowkd.pl.gz
chmod u+x dowkd.pl
./dowkd.pl user
./dowkd.pl host <hostname>

If you see output similar to:

/home/username/.ssh/id_dsa.pub:1: weak key

…then you have been affected by the vulnerability.  If you do not see “weak key” reported then you are OK.

How Do I Fix My Machine?

To update your machine and patch the vulnerability the first thing you want to do is check for and apply any system updates available.  The main Ubuntu archives have been updated with the fixes.  If you are using an alternate mirror the fix may not have propagated yet, so you may not see it available for another few hours.

Apply any updates:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

You should see an update for openssl and openssh packages (along with anything else available).

After these new packages have been applied you’ll want to regenerate any keys that you’ve generated (ie; openssh keys, CA cert, etc).

UPDATE: The latest package release will automagically re-create any server-side ssh keys for you and notify you of the reason. Also, there is a new utility built into the latest release that will check keys for you. After your updates are applied try the tool:

ssh-vulnkey

To generate a new openssh key for your user: (This only required if ‘./dowkd.pl user‘ reports weak)

ssh-keygen -t dsa -b 1024

To generate a new openssh key for your server: (This only required if ./dowkd.pl host <hostname> reports weak)

sudo rm /etc/ssh/ssh_host_{dsa,rsa}_key*
sudo dpkg-reconfigure -plow openssh-server

You should now run the validation script again and make sure it does not report any errors.  If you still see reported warnings such as:

/home/username/.ssh/authorized_hosts:1: weak key

…this means that you have authorized_host keys saved that are still affected.  Open the .ssh/authorized_hosts file with a text editor and delete the affected line (:1: means line 1, etc).

Continue to run the ./dowkd.pl script until no weaknesses are reported.

These steps should be run on any system that you manage to ensure they are sufficiently patched.

I post tutorials very regularly on this site. You may want to consider subscribing to the RSS feed. Or if you'd prefer these tips sent to your inbox you can use Email Subscriptions.

Related Posts

Random Posts

-->

Comments

14 Responses to “OpenSSL & OpenSSH Vulnerabilities : Confirm & Fix Instructions”

  1. Trevor Creech on May 13th, 2008 5:39 pm

    Thanks for keeping my Ubuntu box safe from the internets!
    You rock.

  2. Antonino Sabetta on May 14th, 2008 4:34 am

    Sorry, I got it now. By user you mean the literal string “user”, it’s not supposed to be changed with my actual username.

  3. Dave G on May 14th, 2008 5:04 am

    Thanks for the quick run-down!

    Possibly a silly note, but I had to do:

    sudo apt-get dist-upgrade

    to get the new packages. Openssh-server and client were kept back otherwise. Dunno if this is because I was doing this WITHIN an ssh session but thought I’d drop it.

  4. Luciano on May 14th, 2008 5:58 am

    Hey,
    I would like to make you a little but important correction.

    > If you do not see “weak key”
    > reported then you are OK.’

    That’s not totally true. dowkd.pl is really susceptible to have false positives.

  5. lefty.crupps on May 14th, 2008 7:06 am

    I don’t get it; which file do we substitute for ‘host’ above? What is ‘host’ and ‘hostname’ relation? Which file do we enter in place of ‘user’?

    i ran
    ./dowkd.pl lefty
    and it failed; so did both
    ./dowkd.pl ./.ssh/authorized_keys2
    ./dowkd.pl ./.ssh/known_hosts

    What am I missing??

  6. Roy Schestowitz on May 14th, 2008 8:13 am

    Thanks. That was handy.

  7. Manfred on May 14th, 2008 8:40 am

    When I tried your script I got the following message:

    ./dowkd.pl user
    /home/jonny/.ssh/authorized_keys:1: warning: unparsable line

    Is that indicating a problem?

  8. Nick M on May 14th, 2008 2:12 pm

    Wow, thanks! I think I just found my new favorite Ubuntu site! :)

  9. Yazz D. Atlas on May 15th, 2008 12:28 pm

    !/bin/bash
    wget http://security.debian.org/project/extra/dowkd/dowkd.pl.gz && \
    gzip -d dowkd.pl.gz && \
    for i in $(/bin/ls -1 /home ); do perl dowkd.pl user $i; done && \
    for i in $(/bin/ls -1 /etc/ssh/*.pub) ; do perl dowkd.pl file $i; done

  10. Thomas on May 16th, 2008 12:10 am

    Oh the irony, a fix for a security vulnerability that downloads a script using HTTP and then runs it…

    Download the signature too, then verify it!

    wget http://security…./dowkd.pl.gz.asc
    gpg dowkd.pl.gz.asc

    You’ll probably get a ‘key not found’ error. Import the key (it’ll tell you the RSA key ID):

    gpg –recv-keys 02D524BE

    Now when you run it again. It should tell you that the signature matches, but that the key is untrusted.

    Now the real fun begins :-)

    You need to verify the key signature, then you need to decide if you actually trust this “Florian Weimer” guy, and _THEN_ you can run the script!
    (I can tell you, but that’d be pointless ‘cos then you’d have to decide whether or not you trust me :-)

    Security is NOT easy, but failing to do the above means that you’re on par with the guy who runs “WindowsSecurityPatch.exe” attachments he gets in the mail.

  11. Rafael on May 19th, 2008 5:43 am

    I have followed all the instructions but I have two problems:

    1)I don’t have the tool: ssh-vulnkey

    2)When I run ./dowkd.pl host , I get the following error:
    server: 2048 bits DSA key not recommended

    ¿any idea?

    Thnks in advance

  12. Gecko on May 19th, 2008 10:07 am

    Thank you so much for your help on this. As a relative newbie, I wasn’t too sure what the heck I was supposed to do other than update in the face of this issue. Thanks again.

  13. Christer Edwards on May 19th, 2008 5:17 pm

    @Rafael - you should be seeing a new openssh upgrade soon that will include an openssh blacklist and the new vulnkey tool. This was not included in the first batch of patches. My guess is your mirror isn’t up to date just yet.

    Also, (see: man ssh-keygen), “DSA keys must be exactly 1024 bits as specified by FIPS 186-2.”, which is why you get that output.

  14. Gravin on May 26th, 2008 11:04 pm

    Thanks!

Leave a Reply




    OSCON


    OSCON 2008

    Subscribe to the RSS feed!


    subscribe to the ubuntu tutorials RSS feed

    Polls


  • Regarding the Ads on Ubuntu Tutorials...

    View Results

    Loading ... Loading ...

  • Blogroll

  • Ads by Google