I was giving for granted that it behave that way, then today I made an integration test over my signup API to see taht it would fail under an "attack" with a modified event.

The test failed and I got scared so I did dig deeper and wrote that test.

The whole library assembles in the "finalized event" both the original event and the sig/pub/hash properties. So when you call verifyEvent it uses the hashes that one pass as "id" rather than recalculate the hash from scratch from the original event properties.

I am no security expert but that look *very* bad to me.

Reply to this note

Please Login to reply.

Discussion

TBC: the integration test "failed" means that the signup HTTP worked despite the modified event being sent through, while it should have returned 401.

What? No. "verifyEvent" checks that the actual hash matches the id. What is bad there?

If it does that, as one would expect, why the check returns true while it should be false?

I just explained it three notes above.

The note starting with "It should indeed return false"? :)

My point is that the library should not assume that everything has been done properly, quite the opposite.

"You should not change the event" is one thing. Assuming that will not happen and returning that an altered event is verified is another.

The semantic of "verified" here becomes: there is a property set as verified: true in the json. While it should not what it should be or at least what I was expecting.