#6008 - Convert _url_to_filename to using a base64 salted sha256

  • By
  • Added
  • 2 views
Identifier #6008
Issue type Feature request or suggestion
Title Convert _url_to_filename to using a base64 salted sha256
Status Completed
Tags

Roadmap: v11 (custom)

Handling member PDStig
Version 11 beta4
Addon core
Description I originally changed _url_to_filename to use an md5 hash of the image URL to avoid issues with filenames being too long. But this wasn't a good idea:

- MD5 is not secure; its collision potential means we could theoretically generate the same MD5 for two different images which means we leak the thumb of one (potentially restricted) image when viewing another.
- We were not salting the MD5, so people could run direct requests to images to try and find thumbs.

This fix changes the function to using hash_hmac with the sha256 algorithm and salting with the site salt. It then takes that binary data and base64-encodes it (but making it URL appropriate).

This will be much more secure (makes collisions a lot less likely and makes guessing thumb names much harder).

We have reached the point in time where we cannot reasonably say because MD5 is faster, we should be using it. A large majority of servers today can now handle a motherload of sha256 hashes just fine. And the security of SHA256 outweighs MD5's speed advantage.

I may add a separate issue about changing all use of md5 in the future.
Steps to reproduce

Funded? No
Commits

Implemented MANTIS-6008 (Convert _url_to_filename to using a base64 salted sha256) (c038c120) · Commits · Composr ecosystem / Composr · GitLab

The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".

Rating

Unrated