NfNitLoop / feoblog

A distributed, cryptographically-verifiable blog / social network
Other
71 stars 4 forks source link

Don't trust File objects from browser #122

Closed NfNitLoop closed 1 year ago

NfNitLoop commented 1 year ago

Our upload process is:

But I'm pretty sure I caught Safari changing the size/bytes of a File after we originally got its size/bytes and included them in the Item. This broke the signature/size checks for file attachments, and the file couldn't be uploaded.

Solution:

Immediately get the bytes/name/size out of the File object and store them in our own object. Throw away the original so that it can't get changed out from under us.

I might wait until I see this happen again, though. I haven't been able to reproduce it yet. OTOH it's probably good practice anyway, given the strict signature constraints? Probably easier to implement than #120.