[Rt-commit] rt branch, 4.4-trunk, updated. rt-4.4.4-244-gae488f3123

? sunnavy sunnavy at bestpractical.com
Mon Feb 8 12:53:07 EST 2021


The branch, 4.4-trunk has been updated
       via  ae488f31230a7689abf7707b16ce26b66706b8c6 (commit)
       via  5fa0bfda3980747e1d4625fdc46060c351b47f5b (commit)
       via  b753aa411bf3f5946eeeea09aff8471b446f3d7e (commit)
       via  6d6304741f8b15466261ea010a944a498e258a8a (commit)
       via  be277569dd34e5cf36895a572257bfa899772133 (commit)
       via  92aff8842dd62df5623384cf25097076876d7df8 (commit)
       via  b1e6dfd2f8dc71ba70aaf00e7c11d55fe133b6d0 (commit)
       via  124db83e80913c661fda4e53ba7730bf0f4696ca (commit)
      from  0116ce10e86c697fb3df3f1737364cc9f5baa58b (commit)

Summary of changes:
 lib/RT/Crypt/GnuPG.pm                              |  2 +-
 lib/RT/Crypt/SMIME.pm                              | 53 ++++++++++++++++++++++
 lib/RT/User.pm                                     | 23 +++++++++-
 share/html/Admin/Users/Keys.html                   |  2 +-
 .../Crypt/{GetGPGPubkey.html => GetSMIMECert.html} | 45 ++++++++++++------
 share/html/Elements/CryptStatus                    | 13 +++---
 t/mail/smime/incoming.t                            |  2 +
 t/security/CVE-2012-4735-sign-any-key.t            |  2 +-
 t/web/admin_user.t                                 |  7 ++-
 t/web/smime/outgoing.t                             |  2 +-
 10 files changed, 123 insertions(+), 28 deletions(-)
 copy share/html/Crypt/{GetGPGPubkey.html => GetSMIMECert.html} (58%)

- Log -----------------------------------------------------------------
commit b753aa411bf3f5946eeeea09aff8471b446f3d7e
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Feb 6 06:33:17 2021 +0800

    Switch from key to fingerprint for user PrivateKey
    
    This is consistent with other GnuPG key selects.

diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index 90bf6c3700..9350f7f806 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -2091,7 +2091,26 @@ sub PrivateKey {
     }
 
     my $key = $self->FirstAttribute('PrivateKey') or return undef;
-    return $key->Content;
+    my $content = $key->Content;
+
+    # RT used to identify keys using the key ID, but now identifies them
+    # using the key fingerprint, which is 160 bits long and avoids a
+    # collision attack against keys with short IDs.
+    if ( length $content < 40 ) {
+        # not fingerprint, try to update it
+        my %tmp = RT::Crypt->GetKeysForSigning( Signer => $content, Protocol => 'GnuPG' );
+        if ( !$tmp{exit_code} && $tmp{info} && $tmp{info}[0] ) {
+            my $user = RT::User->new( RT->SystemUser );
+            $user->Load( $self->Id );
+            $user->SetPrivateKey( $tmp{info}[0]{Fingerprint} );
+            return $tmp{info}[0]{Fingerprint};
+        }
+        else {
+            RT->Logger->warning("Couldn't find private key for $content");
+        }
+    }
+
+    return $content;
 }
 
 sub SetPrivateKey {
@@ -2117,6 +2136,8 @@ sub SetPrivateKey {
         my %tmp = RT::Crypt->GetKeysForSigning( Signer => $key, Protocol => 'GnuPG' );
         return (0, $self->loc("No such key or it's not suitable for signing"))
             if $tmp{'exit_code'} || !$tmp{'info'};
+        # In case $key is key id instead of fingerprint
+        $key = $tmp{'info'}[0]{Fingerprint};
     }
 
     my ($status, $msg) = $self->SetAttribute(
diff --git a/share/html/Admin/Users/Keys.html b/share/html/Admin/Users/Keys.html
index 36b9a7e353..bbef3d376f 100644
--- a/share/html/Admin/Users/Keys.html
+++ b/share/html/Admin/Users/Keys.html
@@ -101,7 +101,7 @@ my $email = $UserObj->EmailAddress;
 
 if (RT::Config->Get('GnuPG')->{Enable}) {
     my %keys_meta = RT::Crypt->GetKeysForSigning( Signer => $email, Protocol => 'GnuPG' );
-    @potential_keys = map $_->{'Key'}, @{ $keys_meta{'info'} || [] };
+    @potential_keys = map $_->{'Fingerprint'}, @{ $keys_meta{'info'} || [] };
 
     $ARGS{'PrivateKey'} = $m->comp('/Widgets/Form/Select:Process',
         Name      => 'PrivateKey',

commit 5fa0bfda3980747e1d4625fdc46060c351b47f5b
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Sat Feb 6 07:37:06 2021 +0800

    Update tests for the "key => fingerprint" change of PrivateKey select

diff --git a/t/security/CVE-2012-4735-sign-any-key.t b/t/security/CVE-2012-4735-sign-any-key.t
index 78e9d1bace..16b22fde97 100644
--- a/t/security/CVE-2012-4735-sign-any-key.t
+++ b/t/security/CVE-2012-4735-sign-any-key.t
@@ -19,7 +19,7 @@ my %secret_keys;
     for my $key (@{$info{info}}) {
         my $user = $key->{User}[0]{String};
         $user = (Email::Address->parse( $user ))[0]->address;
-        $secret_keys{$user} = $key->{Key};
+        $secret_keys{$user} = $key->{Fingerprint};
     }
 }
 
diff --git a/t/web/admin_user.t b/t/web/admin_user.t
index 4ada807d94..1079598f8c 100644
--- a/t/web/admin_user.t
+++ b/t/web/admin_user.t
@@ -43,7 +43,7 @@ is( $form->find_input('PrivateKey')->value,
     '__empty_value__', 'default no private key' );
 $m->submit_form_ok(
     {
-        fields => { PrivateKey => 'D328035D84881F1B' },
+        fields => { PrivateKey => 'F0CB3B482CFA485680A4A0BDD328035D84881F1B' },
         button => 'Update',
     },
     'submit PrivateKey form'
@@ -52,7 +52,7 @@ $m->submit_form_ok(
 $m->content_contains('Set private key');
 $form = $m->form_with_fields('PrivateKey');
 is( $form->find_input('PrivateKey')->value,
-    'D328035D84881F1B', 'set private key' );
+    'F0CB3B482CFA485680A4A0BDD328035D84881F1B', 'set private key' );
 $m->submit_form_ok(
     {
         fields => { PrivateKey => '__empty_value__' },

commit ae488f31230a7689abf7707b16ce26b66706b8c6
Merge: 0116ce10e8 5fa0bfda39
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Tue Feb 9 01:51:55 2021 +0800

    Merge branch '4.4/crypt-minor-fixes' into 4.4-trunk


-----------------------------------------------------------------------


More information about the rt-commit mailing list