CVE-2020-26254: Authentication Bypass by Spoofing (CWE-290)
value: omniauth-apple is the OmniAuth strategy for "Sign In with Apple" (RubyGem omniauth-apple). In omniauth-apple before version 1.0.1 attackers can fake their email address during authentication. This vulnerability impacts applications using the omniauth-apple strategy of OmniAuth and using the info.email field of OmniAuth's Auth Hash Schema for any kind of identification. The value of this field may be set to any value of the attacker's choice including email addresses of other users. Applications not using info.email for identification but are instead using the uid field are not impacted in the same manner. Note, these applications may still be negatively affected if the value of info.email is being used for other purposes. Applications using affected versions of omniauth-apple are advised to upgrade to omniauth-apple version 1.0.1 or later.
CWE description: This attack-focused weakness is caused by incorrectly implemented authentication schemes that are subject to spoofing attacks.
CVSS v3 base score: 7.7
Published: 2020-12-08T15:15Z
Repository: https://github.com/nhosoya/omniauth-apple
Language: Ruby
Files changed: lib/omniauth/strategies/apple.rb, spec/omniauth/strategies/apple_spec.rb
Commit date: 2020-12-02 19:45:12 +0900
Commit message: Use only verified email address to prevent fake email address

Co-authored-by: David Taylor <david@taylorhq.com>

Diff: diff --git a/lib/omniauth/strategies/apple.rb b/lib/omniauth/strategies/apple.rb
index 49b605c..79c5bd6 100644
--- a/lib/omniauth/strategies/apple.rb
+++ b/lib/omniauth/strategies/apple.rb
@@ -102,11 +102,11 @@ module OmniAuth
 
         @user_info ||= JSON.parse(user)
       end
 
       def email
-        user_info['email'] || id_info['email']
+        id_info['email']
       end
 
       def first_name
         user_info.dig('name', 'firstName')
       end
diff --git a/spec/omniauth/strategies/apple_spec.rb b/spec/omniauth/strategies/apple_spec.rb
index 04eaae8..30cb713 100644
--- a/spec/omniauth/strategies/apple_spec.rb
+++ b/spec/omniauth/strategies/apple_spec.rb
@@ -250,10 +250,25 @@ describe OmniAuth::Strategies::Apple do
         subject.session.delete('omniauth.nonce')
         subject.info
       end
     end
 
+    context 'with a spoofed email in the user payload' do
+      before do
+        request.params['user'] = {
+          name: {
+            firstName: 'first',
+            lastName: 'last'
+          },
+          email: "spoofed@example.com"
+        }.to_json
+      end
+
+      it 'should return the true email' do
+        expect(subject.info[:email]).to eq('something@privatrerelay.appleid.com')
+      end
+    end
   end
 
   describe '#extra' do
     before(:each) do
       subject.authorize_params # initializes session / populates 'nonce', 'state', etc

Vulnerable code:         user_info['email'] || id_info['email']
Fixed code:         id_info['email']
    context 'with a spoofed email in the user payload' do
      before do
        request.params['user'] = {
          name: {
            firstName: 'first',
            lastName: 'last'
          },
          email: "spoofed@example.com"
        }.to_json
      end

      it 'should return the true email' do
        expect(subject.info[:email]).to eq('something@privatrerelay.appleid.com')
      end
    end