-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add requirement for sha256 on upload #12
Conversation
The hash also allows you to skip the upload altogether if the file is already known. On the other hand, why drop the size? You might have authorization to upload files of 1MB but not of 2MB, so by advertising the size, the server could reject it at this point? Why does the |
I think it's fair to assume the HTTP request would have content-length alongside the event headers. The sha provides data integrity so length would just be checked alongside. An http 100-continue could serve this purpose better. I really like the idea of providing content integrity in the signed message. I was going to open an issue last week but I wrongly assumed you already considered that and had a reason not to. Although does the the server really need to care about data integrity since we assume all clients verify blob integrity during a download anyway, or do we trust servers to verify integrity? |
Besides better security, including a hash also has the upside of skipping existing uploads, +1 @Giszmo If it's fast enough on most devices for average uploads, I'd say yes. Q: regarding size, were Blossom servers rejecting outsized files based on the auth event declared size or via request headers? |
Yes, at least my initial implementation. although as I mentioned before it was only there as a really simple security measure to make sure the uploaded blob matched the users auth event
The clients can verify the hash on download, but its also good to verify it in the other direction.
The |
Looks good. https://bouquet.slidestr.net/ is now already adding the Having the hash before the upload allows us to improve the upload performance as well. Currently we store the file in a temp location, calculate the hash on the server and then upload to a blob storage. This leads to significant delay for larger files. When the hash is known beforehand the file can be directly uploaded to the final location in an optimistic way. We would only need to revert the storage when the hash does not match. |
If there are no objections to this Ill merge it tomorrow |
Replace the requirement for the
size
tag with anx
tag containing the sha256 hash of the blob being uploadedThis is much more secure and removes the possibility of an attacker using another users "upload authorization" event with a padded blob