News for hackers. Stuff that matters.
Re:SAML Is Insecure by Design by janci on Thursday August 05, 2021 @04:54PM (#28079656)
Isn't this the usual practice with any nontrivial XML handling? You get some WSDL and XSDs of a coarse-grained service (as in having 300 optional input elements with no idea what can be combined or not) so you throw real-world examples on your implementation until it works.
Re:SAML Is Insecure by Design by michaelt on Thursday August 05, 2021 @05:40PM (#28080288)
It is indeed a common way of parsing XML. Unfortunately, it's a bad idea when dealing with SAML.

SAML is a way for exchanging 'security assertions' - for example, if a Alice logs into the AWS Console with her employer's single-sign-on service, the SSO service gives Alice a signed document saying "The bearer of this document can log into AWS as Alice within the next 60 seconds and access accounts B and C" which she hands to AWS. The digital signature on the document is very important.

Unfortunately, SAML uses the 'XML Signature' standard [1]

The people who wrote the XML signature standard didn't just take an XML document and whack a PGP signature around the whole thing! They thought about use cases like 'what if you wanted to only sign part of a document' and 'what if, after signing, the document was processed by something that reordered the attributes' and 'what if you have signatures from multiple sources and want to collate them into the same document'. They decided they wanted to support all of them.

As such, it's entirely legal for a document to contain a valid set of properly signed security assertions and a load of different security assertions that aren't signed.

So SAML documents have to be parsed very carefully - if you naively check the document has a valid signature then read the assertions, an attacker can add extra assertions outside of the signed part of the document, granting them broader permissions than they ought to have.

[1] https://en.wikipedia.org/wiki/XML_Signature

Re:SAML Is Insecure by Design by jrockway on Thursday August 05, 2021 @06:24PM (#28080804)
I feel like we keep making this mistake again and again. Like JWTs can be signed with the "none" algorithm, which as you might guess is very easy to forge. Conformant implementations can see that and say "yup, that's a valid signature" and happily let any user grant themselves any access they want. Big mistake. It probably shouldn't be in the standard.

(I like PASETO instead of JWT, but nobody else in the world does, it seems, so we're stuck with the broken thing forever. Client libraries at least special-case "none" now and make it auto-fail, which has probably saved a few people that didn't actually read the spec.)

Re:SAML Is Insecure by Design by mwcampbell on Thursday August 05, 2021 @07:40PM (#28081483)
Thanks for mentioning PASETO. It looks good, except that it doesn't have a standard way of specifying expiration like JWT. But at least it's easy and safe to roll your own implementation of that part. Edit: My mistake; it's just the Elixir implementation of PASETO that doesn't support expiration.
Re:SAML Is Insecure by Design by tptacek on Thursday August 05, 2021 @10:24PM (#28082602)
PASETO is a bit of an odd duck, and isn't really an answer to the OIDC vs. SAML question. OIDC relies on JWT in the same way that SAML relies on DSIG, but there's a whole authentication protocol build around it. You would probably not be better off replacing an OIDC implementation with a hand-rolled authentication protocol based on PASETO.

The big problem here is that none of this matters. People do abuse OIDC as a general-purpose token for individual applications, but almost nobody does that with SAML. The point of these schemes is to federate authentication. In other words: it only matters what Okta and Google will agree to do. Your options are OIDC or SAML.

If you had to pick between the two, I guess you should pick OIDC, and think about what Ryan Sleevi said downthread about certificate verification; you'll want some kind of pinning scheme (pinning is a mess in client-server situations, but still sane in server-server applications; in fact, server-server pinning long predates browser public key pinning).

If you're not federating authentication, I don't think you should use JSON tokens of any sort.

Re:SAML Is Insecure by Design by bawolff on Thursday August 05, 2021 @05:59PM (#28080544)
> The people who wrote the XML signature standard didn't just take an XML document and whack a PGP signature around the whole thing! They thought about use cases like 'what if you wanted to only sign part of a document' and 'what if, after signing, the document was processed by something that reordered the attributes' and 'what if you have signatures from multiple sources and want to collate them into the same document'. They decided they wanted to support all of them.

You forgot to add the part - what if someone wants to add comments randomly without it changing the signature, even when those comments (mildly) change how the xml doc is parsed!

Re:SAML Is Insecure by Design by stouset on Thursday August 05, 2021 @06:26PM (#28080829)
I did forget. I've spent years trying to.
Re:SAML Is Insecure by Design by nonameiguess on Friday August 06, 2021 @07:28AM (#28085683)
It's too late to reform SAML, but this where TDF shines. [1]

This is what we use in the military to provide provenance assurance, classification markings, and authorize dissemination destinations for digital intelligence products, and also what we use for manifests to enable trusted data transfers from unclassified to classified networks.

It's pretty interesting to be on a network where everyone has a PKI identity. Your client certificate gets sent to your sponsoring agency's personnel database, which returns the exact set of clearances you have, that gets sent to the server you're requesting information from, and you get back a web page with exactly what you're authorized to see and everything else redacted. No need to login and you can access any page you know the name or address for. You just may not see anything on it.

[1] https://www.dni.gov/index.php/who-we-are/organizations/ic-ci...

Re:SAML Is Insecure by Design by tasogare on Thursday August 05, 2021 @07:19PM (#28081331)
> 'what if you wanted to only sign part of a document' and 'what if, after signing, the document was processed by something that reordered the attributes'

Those use cases are valid. The second one is actually the reason why JSON can't be used for a similarly usage (there is not canonization standard, and reading then writing a file could reorder the elements order).

Re:SAML Is Insecure by Design by tptacek on Thursday August 05, 2021 @10:26PM (#28082620)
The problem isn't that there's no valid use case for it; it's that there's no use case for it in SAML, just as there's no valid SAML use case for XML comments (which also broke SAML).

You can defend DSIG in a lot of different ways. I'll disagree with all of them and feel like I could probably win the argument; DSIG is a cursed standard. But that's not the bar you have to clear in this discussion; here you have to establish that DSIG is good for SAML. It clearly isn't.

Re:SAML Is Insecure by Design by stouset on Friday August 06, 2021 @03:21AM (#28084217)
I might be wrong but I vaguely remember that something like “all” of the popular open source SAML libraries in the wild were vulnerable due to DSIG mishandling circa 2012. They’d blindly accept any document as valid as long as there was a signature in place that signed some element, but didn’t bother to check that that element was the set of assertions actually being used.
Re:SAML Is Insecure by Design by rb12345 on Friday August 06, 2021 @11:36AM (#28088616)
There were similar issues more recently (2018/19) with custom XML entities or comments. The XML signature was unaffected, but if code used the equivalent of element.children[0] to get the contents, it was possible for attackers to truncate the attribute values seen by the service provider library.
Re:SAML Is Insecure by Design by tptacek on Friday August 06, 2021 @10:19AM (#28087456)
Yep. You still find variants of that today.
Re:SAML Is Insecure by Design by formerly_proven on Friday August 06, 2021 @04:24AM (#28084547)
The latter is not a valid use case for anything using signatures, because it² is virtually impossible to implement correctly.

The former might be important for something? But generally also very nearly impossible to do correctly. When that is the case, one should contemplate whether the actual business requirements can be fulfilled another way, instead of making things broken by design.

² "canonicalize-encode-sign" as opposed to the correct way of "sign blob, parse blob".

Re:SAML Is Insecure by Design by stouset on Thursday August 05, 2021 @05:32PM (#28080192)
"Throw stuff at it until it looks like it works" is probably not the development practice you want to employ for an authentication service.
Re:SAML Is Insecure by Design by fivre on Thursday August 05, 2021 @09:43PM (#28082361)
and yet, "throw features at it until it meets the client's requested idealized spec, with weird carve-outs for some legacy system that we promise will be gone in a year or so, maybe" while also maybe conforming to some mythological security model drunkenly conceived by Baphomet" is where we arrive at in practice
Re:SAML Is Insecure by Design by janci on Thursday August 05, 2021 @05:39PM (#28080274)
Surely not! I'm just saying I'm not surprised too much.
Re:SAML Is Insecure by Design by jrockway on Thursday August 05, 2021 @06:27PM (#28080836)
I think there's a mismatch between security and software engineering. Software engineers are paid to make things work, but the point of security is to make things not work (for attackers). So there is that fundamental mismatch which leads to a lot of strife, I think. (The real answer, of course, is that the software needs to do two things instead of just one. It needs to permit authorized users AND deny unauthorized users. One is not more important than the other, both must work perfectly. But when testing it, you're mostly happy when you, the authorized user, are allowed to log in, and so tend to forget about the "what if the assertion is malformed" case.)

I think it's funny because engineers are always portrayed as being grumpy and that they hate everything, but if you look at how they handle errors or security, they seem like the type of people that like everything and always imagine the happy path ;)

Re:SAML Is Insecure by Design by stouset on Thursday August 05, 2021 @07:38PM (#28081468)
I've often made this comparison. Software engineering seems primarily focused on making it work correctly, security engineering is about making it fail correctly.

But I also think that latter part should be just given more weight in software engineering in general. A simple example is regex: most people tend to think about writing regexes that positively match expected input, but this generally results in expressions that match things it shouldn't. Writing them is generally easier and more straightforward when you think about not matching what they shouldn't!

Re:SAML Is Insecure by Design by jcranmer on Thursday August 05, 2021 @08:36PM (#28081902)
That's a good point, but I'd actually go a step further and argue that we need to think more generally about actually defining when things should fail. This is exacerbated by a tendency of many people to actually require systems to not fail on bad input but instead try to make as much sense of it as possible so that now compatibility requires you to make the same guesses as to what the user actually meant. See, for example, the tag soup parsing of HTML (which was eventually standardized in HTML5), or the insanity that is trying to parse email messages.
Re:SAML Is Insecure by Design by mooreds on Friday August 06, 2021 @07:38AM (#28085750)
> This is exacerbated by a tendency of many people to actually require systems to not fail on bad input but instead try to make as much sense of it as possible so that now compatibility requires you to make the same guesses as to what the user actually meant.

Isn't this Postel's law in practice? https://en.wikipedia.org/wiki/Robustness_principle

There's a competitive advantage in handling bad input, right? I'm not saying it should always be the primary consideration and certainly not in security situations, but I think that competitive pressures are how we arrived at this situation.

Re:SAML Is Insecure by Design by 1cvmask on Thursday August 05, 2021 @08:22PM (#28081784)
You framed the issue perfectly. A mismatch of competing incentives. That seems to be a problem everywhere beyond just security. it seems that bonuses should be tied to security as well. Then maybe software engineers would be incentivized to build things securely.

A clawback of bonuses for security vulnerabilities might be an interesting idea? Or better yet bigger bonuses if there are no breaches.

Re:SAML Is Insecure by Design by yourapostasy on Thursday August 05, 2021 @09:47PM (#28082382)
> A clawback of bonuses for security vulnerabilities might be an interesting idea? Or better yet bigger bonuses if there are no breaches.

Agency problem. Those who decide budgets and project timelines get the upside in such a bonus scheme, while whose who implement get the downside. Clawback bonuses, and the engineers not only get blamed, they get laid off to make the quarterly numbers for the management who want to make up for lost bonuses.

I suspect the solution lays in the spec complexity. Haven’t thought of this much, so my wrongthink knee jerk reaction is make a set of reference test harnesses part of the SOT of the spec, and that is the first step towards more robust implementations. Would like to hear how others have approached this problem space.

Re:SAML Is Insecure by Design by scrose on Friday August 06, 2021 @02:43AM (#28084015)
All this would accomplish is engineers feeling less like they should report issues with systems.