saml2 2.2.7 → 2.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f95046518e86db9aca974fb6de4d3ce9da5d74dbd057a7cb72835404506f0e16
4
- data.tar.gz: c2ee8956692d288bb2f1f1de24b5116ff9a79e441d6ad19bc6d2cb47a60923eb
3
+ metadata.gz: c16820ad8709894d30598abdc66c7258eaaa4bcce559a3f540e898226ecad9b7
4
+ data.tar.gz: cb81f7ca257db3e1aa45896749961cfb0ab63473499d70614931b02de5a975cd
5
5
  SHA512:
6
- metadata.gz: bc8d753aa0e783a6f104b6e8eb33f40f06438e955f4e9b71323cc22c15d1ac3e604130a77293e2e67b7dad9cc7669bfce07a8ee35bd0216f52ed11cfb24620eb
7
- data.tar.gz: 54d210d78f6b28627595f7fff05dcc469d4694d3a154ea05a451ff9f8ec9c1a9ba41274593ebfac6fded65852e12068611d7a14f6424d85ea37b39d6bcc6f8f7
6
+ metadata.gz: 9aacff1311c151b1f8e53d9e63f519b5ff4d21c9c664c22ffcaff42519d9e22530445f8f287c8ab797f0ae7df12aee9d35e9ca9539e782262b2ff4c940a0626a
7
+ data.tar.gz: f7287daba3d0a8d5671f109c30deb9dabce202cbe5b0e7d821c50fb09afbc7cbd056dadf43f2d7ef16582a6bf46b271caf14e131b1f622520e48b1bdaa78d26d
@@ -131,6 +131,18 @@ module SAML2
131
131
  response_signed = true
132
132
  end
133
133
 
134
+ assertion = assertions.first
135
+
136
+ # this might be nil, if the assertion was encrypted
137
+ if assertion&.signed?
138
+ unless (signature_errors = assertion.validate_signature(fingerprint: idp.fingerprints,
139
+ cert: certificates,
140
+ allow_expired_certificate: allow_expired_certificate)).empty?
141
+ return errors.concat(signature_errors)
142
+ end
143
+ assertion_signed = true
144
+ end
145
+
134
146
  find_decryption_key = ->(embedded_certificates) do
135
147
  key = nil
136
148
  embedded_certificates.each do |cert_info|
@@ -160,6 +172,8 @@ module SAML2
160
172
  if decypted_anything
161
173
  # have to re-validate the schema, since we just replaced content
162
174
  super()
175
+ # also clear this cached value so that we can see cached assertions
176
+ remove_instance_variable(:@assertions)
163
177
  return errors unless errors.empty?
164
178
  end
165
179
  end
@@ -169,13 +183,15 @@ module SAML2
169
183
  return errors
170
184
  end
171
185
 
172
- assertion = assertions.first
186
+ assertion ||= assertions.first
173
187
  unless assertion
174
188
  errors << "no assertion found"
175
189
  return errors
176
190
  end
177
191
 
178
- if assertion.signed?
192
+ # if we didn't previously check the assertion's signature (because it was encrypted)
193
+ # check it now
194
+ if assertion.signed? && !assertion_signed
179
195
  unless (signature_errors = assertion.validate_signature(fingerprint: idp.fingerprints,
180
196
  cert: certificates,
181
197
  allow_expired_certificate: allow_expired_certificate)).empty?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SAML2
4
- VERSION = '2.2.7'
4
+ VERSION = '2.2.8'
5
5
  end
@@ -0,0 +1,116 @@
1
+ <samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_9a15e699-2d04-4ba7-a521-cfa4dcd21f44" Version="2.0" IssueInstant="2015-02-12T22:51:29Z" Destination="https://siteadmin.test.instructure.com/saml_consume" InResponseTo="_bec424fa5103428909a30ff1e31168327f79474984">
2
+ <saml:Issuer>issuer</saml:Issuer>
3
+ <samlp:Status>
4
+ <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
5
+ </samlp:Status>
6
+ <saml:Assertion ID="_cdfc3faf-90ad-462f-880d-677483210684" Version="2.0" IssueInstant="2015-02-12T22:51:29Z">
7
+ <saml:Issuer>issuer</saml:Issuer><Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
8
+ <SignedInfo>
9
+ <CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
10
+ <SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
11
+ <Reference URI="#_cdfc3faf-90ad-462f-880d-677483210684">
12
+ <Transforms>
13
+ <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
14
+ <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
15
+ </Transforms>
16
+ <DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
17
+ <DigestValue>r/MVi1aNDe8SSyvsDVmyQHNvl+sW0CjFeCnRnV5KL0w=</DigestValue>
18
+ </Reference>
19
+ </SignedInfo>
20
+ <SignatureValue>jRdOoXHY7uEg/ryIL+o8qXBlIlPJyw3nk27VkXWAOG28n17BDCUm5/qAngTK9eUB
21
+ 4vkudLuRKs7bgSSa7UcAf0lytddqylJ561sb3+xFcggt5g5BDUpgjPOsdETuRyQ8
22
+ IGCPt+dsR2L5qWbZch4JkZwaOqs7EZUJ8dqljPObmYuMNzmyZ6VCIVFvOuVO0a8l
23
+ Ps4rqrwQ4BWGWyT0YPHXCAWWGxgDiWvpFEeTZ4T6XoSQlL+gzwUkBT07Q1l/iWaE
24
+ 7JLrIBt4rglJE+FrWjJp7rV8y3UlFpOjlow6tZiCHUS9b1DhOn02A5dW1KiusmGs
25
+ gnL0yJLDPfDo1+2+YzWo3A==</SignatureValue>
26
+ <KeyInfo>
27
+ <X509Data>
28
+ <X509Certificate>MIID+jCCAuKgAwIBAgIJAIz/He5UafnhMA0GCSqGSIb3DQEBBQUAMFsxCzAJBgNV
29
+ BAYTAlVTMQ0wCwYDVQQIEwRVdGFoMRcwFQYDVQQKEw5Db2R5IFNBTUwgVGVzdDEk
30
+ MCIGA1UEAxMbaHR0cDovL3Nzby5jYW52YXMuZGV2L1NBTUwyMB4XDTE1MDIwOTIy
31
+ MTkxOVoXDTE1MDMxMTIyMTkxOVowWzELMAkGA1UEBhMCVVMxDTALBgNVBAgTBFV0
32
+ YWgxFzAVBgNV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Lc2KY0vrqu/R5c8RbmCxMZyss9
48
+ 5y5OLZblsTw3CPgxgMcCiBSYXnO0VTpT9ANW/SpeSE8XnfumxUjsUtxO4qN4O2es
49
+ ZtltN+yN40INHGRWnHc=</X509Certificate>
50
+ </X509Data>
51
+ </KeyInfo>
52
+ </Signature>
53
+ <saml:Subject>
54
+ <saml:EncryptedID>
55
+ <EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#" Type="http://www.w3.org/2001/04/xmlenc#Element">
56
+ <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
57
+ <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
58
+ <X509Data>
59
+ <X509Certificate>MIID+jCCAuKgAwIBAgIJAIz/He5UafnhMA0GCSqGSIb3DQEBBQUAMFsxCzAJBgNV
60
+ BAYTAlVTMQ0wCwYDVQQIEwRVdGFoMRcwFQYDVQQKEw5Db2R5IFNBTUwgVGVzdDEk
61
+ MCIGA1UEAxMbaHR0cDovL3Nzby5jYW52YXMuZGV2L1NBTUwyMB4XDTE1MDIwOTIy
62
+ MTkxOVoXDTE1MDMxMTIyMTkxOVowWzELMAkGA1UEBhMCVVMxDTALBgNVBAgTBFV0
63
+ YWgxFzAVBgNVBAoTDkNvZHkgU0FNTCBUZXN0MSQwIgYDVQQDExtodHRwOi8vc3Nv
64
+ LmNhbnZhcy5kZXYvU0FNTDIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
65
+ AQCwlbZhVkDi6YAHFpkxSoInc9Jrmezv0XKi8YzrDzO9Y7zHJlYygUQmgvD4I5fQ
66
+ tVW8sbp7gS5cCBmjbGJRXx3996qLq12//WLYMDkHktrbU1zZ6vsJ8ajHyQv4OFvq
67
+ qBnForSkuJbNi/QVTKiwbbBOZ75CbNBs1InoMN5MY2S5NhG9JhLjpktxNKfXFEi5
68
+ Wr0rc2T0lSbTHv7L6DUFKeKX7uK9bNREozZDwkyYUHZl1Vez88WiJw7CmzNEnm5v
69
+ 13M6e60788M7E5FZBkTDkFK5+RV10ycYYNN7E8l0HzWSaB4+aJhKsK/Q7Yv+MG/j
70
+ Oj8KMeZvEJfhxx1Dz8idgy8RAgMBAAGjgcAwgb0wHQYDVR0OBBYEFOvkP77RRJET
71
+ X//KwdohNVfZBSvbMIGNBgNVHSMEgYUwgYKAFOvkP77RRJETX//KwdohNVfZBSvb
72
+ oV+kXTBbMQswCQYDVQQGEwJVUzENMAsGA1UECBMEVXRhaDEXMBUGA1UEChMOQ29k
73
+ eSBTQU1MIFRlc3QxJDAiBgNVBAMTG2h0dHA6Ly9zc28uY2FudmFzLmRldi9TQU1M
74
+ MoIJAIz/He5UafnhMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAQ6
75
+ iucYVoOHBXHGybLUj8i3yZEI8C0mZQ/NBsihMGBP58vNSSKUJr4JPvYUIudwkLVH
76
+ T1FWdfMVVVUxqJvCFWfWcpCyKTe4FQ0WyTasq1F9LtCaeMczlkpK+E2XBlNyPGoo
77
+ 1fCDO6pXD7EIOprIFl3blspb5ROF8lCESjFKmyxVGHEOMs2GA0cX3xvW+AvCbYUC
78
+ Cg8Yo62X9vWW6PaKXHs3N+g1Ig16NwjdVIYvcxLc2KY0vrqu/R5c8RbmCxMZyss9
79
+ 5y5OLZblsTw3CPgxgMcCiBSYXnO0VTpT9ANW/SpeSE8XnfumxUjsUtxO4qN4O2es
80
+ ZtltN+yN40INHGRWnHc=</X509Certificate>
81
+ </X509Data>
82
+ <EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
83
+ <EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
84
+ <CipherData>
85
+ <CipherValue>N0tORClqCAyqs4XhId26gk7HpP4ApuqwYuzy/VrkRACAsWZeM4OXfjcrFfJPlcf1
86
+ gLx5tV/tTW/mHw98hXsGCGul/8LVazqGfsjTOtHXkO0i/RPgwVw/aa5+/Ggb+PQ9
87
+ o09y2HII5cmlCSJyUMaqk4g653y6PWF1emRtI6OxMK2St5YKQGzVq5KeWkiV7d7b
88
+ A6ZeR/n0qzjJ2z/qJzzOul4jjlz0/XR2Xb7FrkImza9zS2L7AwRqCpVkRw64/XAM
89
+ /d/SnpgbcNo/RAJzjbOCndBGu6G161nOnQF1+rrVBsDx4HIuImzuvbNBOz0YFe0F
90
+ DyLeXfOpHKgikh4wKa2okQ==</CipherValue>
91
+ </CipherData>
92
+ </EncryptedKey>
93
+ </KeyInfo>
94
+ <CipherData>
95
+ <CipherValue>TTwKeCn5Kqlhjqcj3XFZQ8o64rpYG8uohhBMAwxtqBojTOHe0Itn720Mb7BHHXwI
96
+ KrQn29N8SfC18/daWcNwGTH5njZFYYkHlhBXvb9q8z97jYTiTlNEi1GoWhalLYex
97
+ GnfLxpoBl2EaJw1j2mibbA==</CipherValue>
98
+ </CipherData>
99
+ </EncryptedData>
100
+ </saml:EncryptedID>
101
+ <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
102
+ <saml:SubjectConfirmationData NotOnOrAfter="2015-02-12T22:54:29Z" Recipient="https://siteadmin.test.instructure.com/saml_consume" InResponseTo="_bec424fa5103428909a30ff1e31168327f79474984"/>
103
+ </saml:SubjectConfirmation>
104
+ </saml:Subject>
105
+ <saml:Conditions NotBefore="2015-02-12T22:51:24Z" NotOnOrAfter="2015-02-12T22:51:59Z">
106
+ <saml:AudienceRestriction>
107
+ <saml:Audience>http://siteadmin.instructure.com/saml2</saml:Audience>
108
+ </saml:AudienceRestriction>
109
+ </saml:Conditions>
110
+ <saml:AuthnStatement AuthnInstant="2015-02-12T22:51:29Z">
111
+ <saml:AuthnContext>
112
+ <saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:unspecified</saml:AuthnContextClassRef>
113
+ </saml:AuthnContext>
114
+ </saml:AuthnStatement>
115
+ </saml:Assertion>
116
+ </samlp:Response>
@@ -278,6 +278,12 @@ module SAML2
278
278
  expect(response.errors).to eq []
279
279
  end
280
280
 
281
+ it "doesn't break the signature by decrypting elements first" do
282
+ response = Response.parse(fixture("response_with_signed_assertion_and_encrypted_subject.xml"))
283
+ sp_entity.valid_response?(response, idp_entity, verification_time: Time.parse('2015-02-12T22:51:30Z'))
284
+ expect(response.errors).to eq []
285
+ expect(response.assertions.first.subject.name_id.id).to eq 'jacob'
286
+ end
281
287
  end
282
288
  end
283
289
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: saml2
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.7
4
+ version: 2.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cody Cutrer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-06 00:00:00.000000000 Z
11
+ date: 2018-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -194,6 +194,7 @@ files:
194
194
  - spec/fixtures/response_tampered_signature.xml
195
195
  - spec/fixtures/response_with_attribute_signed.xml
196
196
  - spec/fixtures/response_with_encrypted_assertion.xml
197
+ - spec/fixtures/response_with_signed_assertion_and_encrypted_subject.xml
197
198
  - spec/fixtures/service_provider.xml
198
199
  - spec/fixtures/test3-response.xml
199
200
  - spec/fixtures/test6-response.xml
@@ -267,6 +268,7 @@ test_files:
267
268
  - spec/fixtures/noconditions_response.xml
268
269
  - spec/fixtures/entities.xml
269
270
  - spec/fixtures/xml_signature_wrapping_attack_duplicate_ids.xml
271
+ - spec/fixtures/response_with_signed_assertion_and_encrypted_subject.xml
270
272
  - spec/fixtures/othercertificate.pem
271
273
  - spec/fixtures/xslt-transform-response.xml
272
274
  - spec/fixtures/response_with_encrypted_assertion.xml