Skip to content
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

Image filename is remembered #207

Closed
hikari-no-yume opened this issue Nov 22, 2016 · 11 comments
Closed

Image filename is remembered #207

hikari-no-yume opened this issue Nov 22, 2016 · 11 comments

Comments

@hikari-no-yume
Copy link
Contributor

hikari-no-yume commented Nov 22, 2016

Probably minor: Mastodon remembers, and makes public the filename of avatars and banners uploaded. This might be sensitive in some cases.

@hikari-no-yume hikari-no-yume changed the title Image metadata is not stripped Image filename is remembered Nov 22, 2016
@hikari-no-yume
Copy link
Contributor Author

Oh, this also happens for media in posts.

@jhauberg
Copy link

jhauberg commented Nov 23, 2016

As a user, I would prefer if metadata was stripped (most sensitive would probably be gps-coordinates), and that the filename was given a UUID instead.

@hikari-no-yume
Copy link
Contributor Author

Mastodon already strips EXIF metadata from JPEG images, at least, including GPS coördinates.

@hikari-no-yume
Copy link
Contributor Author

hikari-no-yume commented Nov 23, 2016

Solving this would appear to be relatively easy. Paperclip actually has built-in support for URL obfuscation. So we only need to edit /app/models/media_attachment.rb and insert this after line 13:

                    url: "/system/:class/:attachment/:id_partition/:style/:hash.:extension",
                    hash_secret: Rails.env.development? ? "foobar" : ENV["PAPERCLIP_SECRET"]

This works great. Now all the new attachment URLs are obfuscated. I'm not sure if it works properly in “production” mode, but it does in development.

However, there's a catch: apparently, this change is retrospective and now it looks at that URL for existing media. That media didn't use the same URL format, so you get a 404. That's pretty bad.

I'm not sure how to fix this. One way would be to perform a migration wherein all existing media is renamed, but that would break links from federated sites. Or, perhaps there's a way to make Paperclip use two different URL formats, one for old media, one for new media. But I don't know what that way would be.

:S

@alyssais
Copy link
Contributor

There's a small amount of discussion on how to migrate in thoughtbot/paperclip#416 (comment).

@hikari-no-yume
Copy link
Contributor Author

Oh, that's interesting. Solution might be to make MediaAttachment into, say, LegacyMediaAttachment or something, and have a new MediaAttachment with the new code.

@hikari-no-yume
Copy link
Contributor Author

We'd also need to touch the has_attached_file instances for avatars and headers.

@Gargron
Copy link
Member

Gargron commented Nov 23, 2016

Migrating would mean transferring over 5GB of files back and forth over S3 so not an option (costly and ineffective). Perhaps there is a solution that renames the file a-priori in Paperclip

@hikari-no-yume
Copy link
Contributor Author

That's what I'm currently working on, actually ^^

@hikari-no-yume
Copy link
Contributor Author

Done: https://github.com/Gargron/mastodon/pull/242

Hacky, but it works great.

@hikari-no-yume
Copy link
Contributor Author

hikari-no-yume commented Nov 23, 2016

This is obvious, but it bears pointing out: If that's merged, bear in mind it's a workaround to avoid migration. Any future uses of has_attached_file should do things the proper way.

Gargron added a commit that referenced this issue Nov 24, 2016
Rename media to avoid exposing filename (fixes #207)
Nyoho referenced this issue in Nyoho/mathtodon Apr 25, 2017
Rename media to avoid exposing filename (fixes #207)
alpaca-tc added a commit to pixiv/mastodon that referenced this issue Apr 28, 2017
abcang added a commit to pixiv/mastodon that referenced this issue Jul 3, 2017
takayamaki pushed a commit to takayamaki/mastodon that referenced this issue Mar 10, 2018
admin_announcementコンポーネントおよび関連機能を削除
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants