[UNIX] Crypt::ECB Block Zero Truncation

From: SecuriTeam (support_at_securiteam.com)
Date: 12/21/04

  • Next message: SecuriTeam: "[EXPL] Ultrix dxterm -setup Buffer Overflow"
    To: list@securiteam.com
    Date: 21 Dec 2004 18:20:30 +0200
    
    

    The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com
    - - promotion

    The SecuriTeam alerts list - Free, Accurate, Independent.

    Get your security news from a reliable source.
    http://www.securiteam.com/mailinglist.html

    - - - - - - - - -

      Crypt::ECB Block Zero Truncation
    ------------------------------------------------------------------------

    SUMMARY

    There is a bug in the Crypt::ECB module that affects the way it processes
    blocks of data. It appears that Crypt::ECB incorrectly processes the last
    block of data if it contains a single ASCII "0". This has been tested
    using the Blowfish, Rijndael, TripleDES, DES, and IDEA algorithms. Below
    is some proof-of-concept code to demonstrate the problem. The problem is
    produced where the plain-text data length is one more than ((n % 8) == 0).

    DETAILS

    Proof of Concept:
    #!/usr/local/bin/perl

    use Crypt::ECB;

    my $cipher = "Blowfish";
    my $key = "pb25YTt7d5b55711fd50bffcec4058d3e6c86bfc4c796bec2249b447";
    my $plain = "12345678123456780";

    my $crypt = Crypt::ECB->new;

    $crypt->padding(PADDING_AUTO);
    $crypt->cipher($cipher) or die $crypt->errstring;
    $crypt->key($key);

    printf "Plain = '%s'\n", $plain;

    my $enc = $crypt->encrypt_hex($plain);
    printf "Encrypted = '%s'\n", $enc;

    my $dec = $crypt->decrypt_hex($enc);
    printf "Decrypted = '%s'\n", $dec;

    Patch:
    ###
    ### Diff for ECB fix (output from diff -u)
    ###
    ### Test Data:
    ### Plain: ILlW1nr30
    ### Key:
    pb25YTt7d5b55711fd50bffcec4058d3e6c86bfc4c796bec2249b447
    ### Pad: AUTO
    ###
    --- ECB.pm 2000-12-23 13:16:38.000000000 -0500
    +++ ECB2.pm 2004-12-06 12:45:23.000000000 -0500
    @@ -1,4 +1,4 @@
    -package Crypt::ECB;
    +package Crypt::ECB2;

     # Copyright (C) 2000 Christoph Appel, cappel@debis.com
     # see documentation for details
    @@ -274,7 +274,7 @@
         $crypt->{Mode} = '';
         $crypt->{buffer} = '';

    - return '' unless $data;
    + return '' unless length($data) > 0;

         my $cipher = $crypt->_getcipher;

    ADDITIONAL INFORMATION

    The information has been provided by <mailto:brs@fsproduce.com> Bennett
    R. Samowich.

    ========================================

    This bulletin is sent to members of the SecuriTeam mailing list.
    To unsubscribe from the list, send mail with an empty subject line and body to: list-unsubscribe@securiteam.com
    In order to subscribe to the mailing list, simply forward this email to: list-subscribe@securiteam.com

    ====================
    ====================

    DISCLAIMER:
    The information in this bulletin is provided "AS IS" without warranty of any kind.
    In no event shall we be liable for any damages whatsoever including direct, indirect, incidental, consequential, loss of business profits or special damages.


  • Next message: SecuriTeam: "[EXPL] Ultrix dxterm -setup Buffer Overflow"

    Relevant Pages