News for hackers. Stuff that matters.
Re:# of days since the last alg=none JWT vulnerability by hinkley on Tuesday September 01, 2020 @06:29PM (#24347868)
I worked on some code signing code, and one of the internal customers, who had a lot of clout (but not as much as they thought) were adamant that I needed to provide them a way to pluck data out of the payload without verifying the signature first. I told them, in a variety of extremely diplomatic ways, to politely fuck off. In fact I did a sweep of the code to make extra sure that none of the data paths gave you anything before verification had finished (there were not barn doors but there were soft spots). When your dog is sniffing around, it's time to hide the treats.

The only reason you want to look at a payload is to make decisions about it, before you can trust those decisions are rational. What I did promise them is that I would continue to try to make the checks cheaper, which we did.

Ten years later, I still trust that I made the right call. Never expose a function from a security library that gives you the data without verifying it first. You are doing violence to the user, the team, the company, possibly an entire industry.

Re:# of days since the last alg=none JWT vulnerability by lmilcin on Tuesday September 01, 2020 @07:25PM (#24348300)
In general I don't see any reason to look at any data in the payload before the signature is verified. If anything, a good reason is that increases attack surface by giving attacker ability to interact with my system without the signature.

I don't know what exactly you mean by improving performance by looking at the payload before the cost of signature verification. If you mean that for some reason you could discard large portion of messages without actually verifying the signature then this is generally false.

In a DoS situation the attacker might want to consume your resources without bothering to forge the signature but just as well he can forge the content so potentially easy fix to their fake content will cause you to pay for the signature verification anyway.

If, on the other hand, the application somehow relies on this to be viable then very likely this is a design fault. I can imagine for example that you might want to discard messages with outdated tokens but there are better ways to solve this (just don't send outdated tokens?)

Re:# of days since the last alg=none JWT vulnerability by hinkley on Tuesday September 01, 2020 @07:39PM (#24348399)
In one case they were trying to categorize the content based on inspecting the manifest, shall we call it. If you start making decisions based on non-authoritative information, my experience is that you very quickly forget that it's non-authoritative. That slippery slope is universal, rather than particular to any examples in this thread. If it can happen, it will happen.

If you decide things without checking with a higher authority, then you are the Confused Deputy, and that typically ends badly. It's not Barney's fault he keeps getting locked in the jail cell. It's Andy's.

Re:# of days since the last alg=none JWT vulnerability by jimktrains2 on Tuesday September 01, 2020 @06:56PM (#24348089)
The only case I've come across so far of needing the unverified claims is when you need to verify the signature based on a key dependent on the token issuer (iss claim).

You could arguably define another means of out-of-band signalling, though, but it would also be unauthenticated.

Edit: That said, getting the unauthenticated data should be very explicit and impossible to do "accidentally", if the library allows it at all.

Re:# of days since the last alg=none JWT vulnerability by hinkley on Tuesday September 01, 2020 @07:16PM (#24348232)
I'm not terribly familiar with the implementation details here.

Are you essentially talking about having different strategies to verify the token? Would it make sense to provide some sort of filter function as a parameter that the library can call to clarify what operations need to be performed?

That would allow you to peek at the records in a context where your role is clear, and where the code flow makes it awkward to take the data and run with it. If the code feels wrong enough, it's hard for the developer to claim ignorance, and if it's clear from the outset that ignorance is not an explanation, that leaves malice and stupidity. Most developers won't admit to either, but if forced they'd rather be seen as malicious than stupid, and malicious gets you a meeting with HR.

Re:# of days since the last alg=none JWT vulnerability by jimktrains2 on Tuesday September 01, 2020 @07:23PM (#24348276)
Yes, some libraries provide a key callback function where the unauthenticated token is provided for this type of thing, but the result of the function is supposed to be the key used to verify the token and nothing else is supposed to happen as a side effect.
Re:# of days since the last alg=none JWT vulnerability by hinkley on Tuesday September 01, 2020 @07:41PM (#24348411)
Oh good, that's what I hoped.

Yes, you could have side effects, but it's pretty damned obvious you're being naughty. That's mostly what I want. The obviousness of the cheating makes people think twice, ask questions. Slow down.

Re:# of days since the last alg=none JWT vulnerability by cortesoft on Tuesday September 01, 2020 @07:12PM (#24348205)
I can imagine it might be useful in debugging situations... to see who is sending incorrectly signed tokens. A buggy client? A hacker?
Re:# of days since the last alg=none JWT vulnerability by hinkley on Tuesday September 01, 2020 @07:35PM (#24348368)
But are you going to do that triage programmatically or in a debugger?

A lot of libraries could be better if the authors spent some time sitting at breakpoints in their own code. You could, I'm sure, arrange a JWT parser so that the data you need for triage is hanging out in a very clearly named stack frame a couple steps into the library.

In my case the format was simple enough that I trained a couple people to be able to inspect these things by hand and tell what went wrong. The happy path for the format was stupid simple. Anyone could have written their own parser for the happy path. It was the rules enforcement that made the code I had worth anything. We were the source of authority, and I took that seriously, on the Precautionary Principle if nothing else (and there were plenty of other reasons).

Re:# of days since the last alg=none JWT vulnerability by notJim on Tuesday September 01, 2020 @07:33PM (#24348351)
I think with JWTs, you sometimes need to do this because the JWT itself stores the id of the key used to create the JWT. For example, if you have a multi-tenant application where each tenant has their own key, or for key rotation (although in the key rotation case, I guess you might be able to try every key instead.)
Re:# of days since the last alg=none JWT vulnerability by atonse on Tuesday September 01, 2020 @08:39PM (#24348814)
But you can get this in other ways (like maybe the subdomain used?)
Re:# of days since the last alg=none JWT vulnerability by gavinray on Tuesday September 01, 2020 @06:35PM (#24347912)
In this vein I wonder if it wouldn't be a bad choice to underscore the non-verified decode methods in token API's. Surely people would still abuse them but at least there's an immediate visual warning if you choose not to read the docs, "Why is this method underscored but the other one not?"
Re:# of days since the last alg=none JWT vulnerability by hinkley on Tuesday September 01, 2020 @06:55PM (#24348084)
It's still booby-trapping. I'm finding as I get older that a lot of programmers use their own mistakes to rationalize why they are the only ones who should be trusted with certain things.

Well, of course I'm in charge. Last time Steve did something he pushed the big red button that shut down the whole server room. If I weren't in charge, then it would just be "Steve"s everywhere. Anarchy. Who put the red button there? Who thought having the big red button there might be a stupid idea? That's not important. What's important is that Steve fucked up and I didn't. Remember: never trust Steve.

When people sit down to write open source, they write it the same way they would write code at work, because they've either never experienced anything better, or it was drowned out by the din. So their OSS is always almost as toxic as the situation I illustrated above.

If, for some reason, you want to leave dangerous things laying around, you need way more safety interlocks than an underscore. If you should never call a function, what's the harm in making it expensive to call? Use a function name where the only reasonable interpretation of calling it is that the developer consented, with full knowledge. Make the function name 60 characters long with some colorful adjectives. Name it after the OWASP recommendation that says what a bad fucking idea it is to call this method. Giant neon lights. Fireworks. And a marching band.

Do not look into laser with remaining eye.

Re:# of days since the last alg=none JWT vulnerability by gizmo686 on Tuesday September 01, 2020 @08:20PM (#24348685)
If you enjoy sharing an address space with a malevolent agent of chaos, try accursedUnutterablePerformIO.

https://hackage.haskell.org/package/bytestring-0.10.12.0/doc...

Re:# of days since the last alg=none JWT vulnerability by judge2020 on Tuesday September 01, 2020 @07:08PM (#24348172)
Python's approach seems reasonable, where you have to go out of your way to learn about and perform this workaround: https://stackoverflow.com/a/9145524/3878893
Re:# of days since the last alg=none JWT vulnerability by hinkley on Tuesday September 01, 2020 @07:22PM (#24348266)
ES6 has a way to name functions with Symbols, and Symbols with the same name are not equal. It's not used often but I've seen it used to give a secret back entrance to an object. Like a very limited version of friend functions/classes.

If the symbol is not exposed, then you can't get anywhere in the neighborhood of calling it accidentally. I think if you do enough object introspection you can still get the function handle, but you could never mistake the resulting code for being anything other than farm fresh, Grade-A Cheese.