You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by Tom Chiverton <tc...@extravision.com> on 2018/03/08 12:06:10 UTC

[security] Protections against Duo Labs type attacks

I was reading [1] and wondered if there is either specific protections 
already in place in Apache Santuario's XML security implementation, or 
if it's up to callers of the API to make sure they use it in just the 
right way ?


As a concrete example, implementations maybe doing something like 
calling o.a.x.security.signature.XMLSignature's checkSignatuteValue() 
with a reference to either the SAML's X509 certificate and/or the 
Signature node.
If the latter is being extracted with 
doc.getElementsByTagNameNS(SignatureSpecNS, "Signature") is this 
sufficient protection against the new attack ?


[1] 
https://duo.com/blog/duo-finds-saml-vulnerabilities-affecting-multiple-implementations

-- 
*Tom Chiverton*
Lead Developer
e: 	tc@extravision.com <ma...@extravision.com>
p: 	0161 817 2922
t: 	@extravision <http://www.twitter.com/extravision>
w: 	www.extravision.com <http://www.extravision.com/>

Extravision - email worth seeing <http://www.extravision.com/>
Registered in the UK at: First floor, Tomorrow, MediaCityUK, Manchester, 
M50 2AB.
Company Reg No: 0‌‌5017214 VAT: GB 8‌‌24 5386 19

This e-mail is intended solely for the person to whom it is addressed 
and may contain confidential or privileged information.
Any views or opinions presented in this e-mail are solely of the author 
and do not necessarily represent those of Extravision Ltd.


RE: [security] Protections against Duo Labs type attacks

Posted by "Cantor, Scott" <ca...@osu.edu>.
> Is there any reason why the standard allowed #WithComments? I cannot think
> a single reason why would you want comments in SAML elements. It makes life
> so much more complicated.

That's not what breaks it. In fact, using #WithComments can harden it, it's the omission of comments from the c14n stream that opens up the attack. It's counter-intuitive.

For the record, SAML metadata often includes comments.

The "bug" is XML Signature. It is a hopeless goal to make anything safe in the face of how it works unless you use Enveloping, and that's still not really safe, just safer. We're all just left doing the best we can do and reacting the best we can. The real lesson is "do not implement SAML yourself", and I have never stopped saying that in the 17 years I've been doing it.
 
-- Scott


RE: [security] Protections against Duo Labs type attacks

Posted by George Stanchev <Gs...@serena.com>.
<quote>
> Do you know what the Java settings are that would make it vulnerable 
> to this attack?

Ignoring comments, the usual entity expansion and DTD issues, and a setting to coalesce CDATA into Text nodes are the ones that can create or prevent problems. That in combination with the actual DOM calls being done can interact in various ways that create problems or prevent them.

The "safe" mode, insofar as anything is safe, is to ignore comments (*), prevent DTDs from appearing and block entity expansion, and to coalesce CDATA so it never appears in the DOM.

-- Scott

(*) This of course prevents signing comments. You can still use #WithComments c14n methods, but if any comments were in the DOM when signed, the other end will fail to validate.

</quote>

Is there any reason why the standard allowed #WithComments? I cannot think a single reason why would you want comments in SAML elements. It makes life so much more complicated. 

RE: [security] Protections against Duo Labs type attacks

Posted by "Cantor, Scott" <ca...@osu.edu>.
> Do you know what the Java settings are that would make it vulnerable to this
> attack?

Ignoring comments, the usual entity expansion and DTD issues, and a setting to coalesce CDATA into Text nodes are the ones that can create or prevent problems. That in combination with the actual DOM calls being done can interact in various ways that create problems or prevent them.

The "safe" mode, insofar as anything is safe, is to ignore comments (*), prevent DTDs from appearing and block entity expansion, and to coalesce CDATA so it never appears in the DOM.

-- Scott

(*) This of course prevents signing comments. You can still use #WithComments c14n methods, but if any comments were in the DOM when signed, the other end will fail to validate.


Re: [security] Protections against Duo Labs type attacks

Posted by Colm O hEigeartaigh <co...@apache.org>.
Hi Scott,

Do you know what the Java settings are that would make it vulnerable to
this attack?

Colm.

On Thu, Mar 8, 2018 at 2:40 PM, Cantor, Scott <ca...@osu.edu> wrote:

> > This attack does not appear to apply to the Java DOM implementation, as
> the
> > entire node value is parsed - and not just the bit up to the comment.
>
> That's not universally true, it's a function of the parser settings used.
> Java parsing can be vulnerable or not, it's outside the scope of Santuario
> unless Santuario explicitly configures a parser. I didn't think it did, but
> I didn't look.
>
> -- Scott
>
>
>


-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com

RE: [security] Protections against Duo Labs type attacks

Posted by "Cantor, Scott" <ca...@osu.edu>.
> This attack does not appear to apply to the Java DOM implementation, as the
> entire node value is parsed - and not just the bit up to the comment.

That's not universally true, it's a function of the parser settings used. Java parsing can be vulnerable or not, it's outside the scope of Santuario unless Santuario explicitly configures a parser. I didn't think it did, but I didn't look.

-- Scott



Re: [security] Protections against Duo Labs type attacks

Posted by Colm O hEigeartaigh <co...@apache.org>.
This attack does not appear to apply to the Java DOM implementation, as the
entire node value is parsed - and not just the bit up to the comment. I
added a sanity test to WSS4J (which depends on Santuario) here to check
that it works OK:

https://svn.apache.org/viewvc?view=revision&revision=1825555

However, I definitely encourage downstream projects to incorporate these
types of tests into their builds - other Java based XML parsing libraries
might be vulnerable.

Colm.

On Thu, Mar 8, 2018 at 12:06 PM, Tom Chiverton <tc...@extravision.com> wrote:

> I was reading [1] and wondered if there is either specific protections
> already in place in Apache Santuario's XML security implementation, or if
> it's up to callers of the API to make sure they use it in just the right
> way ?
>
>
> As a concrete example, implementations maybe doing something like calling
> o.a.x.security.signature.XMLSignature's checkSignatuteValue() with a
> reference to either the SAML's X509 certificate and/or the Signature node.
> If the latter is being extracted with doc.getElementsByTagNameNS(SignatureSpecNS,
> "Signature") is this sufficient protection against the new attack ?
>
>
> [1] https://duo.com/blog/duo-finds-saml-vulnerabilities-
> affecting-multiple-implementations
> --
> *Tom Chiverton*
> Lead Developer
> e:  tc@extravision.com
> p:  0161 817 2922
> t:  @extravision <http://www.twitter.com/extravision>
> w:  www.extravision.com
> [image: Extravision - email worth seeing] <http://www.extravision.com/>
> Registered in the UK at: First floor, Tomorrow, MediaCityUK, Manchester,
> M50 2AB.
> Company Reg No: 0‌‌5017214 VAT: GB 8‌‌24 5386 19
>
> This e-mail is intended solely for the person to whom it is addressed and
> may contain confidential or privileged information.
> Any views or opinions presented in this e-mail are solely of the author
> and do not necessarily represent those of Extravision Ltd.
>



-- 
Colm O hEigeartaigh

Talend Community Coder
http://coders.talend.com