Play it!
The only way to make sure that you have a code that decodes the video of the type in question is to look at it (and check there are reasonable results, for example, non-zero duration).
Otherwise, your risks are low:
Non-malicious scenario:
- Uploader downloads video with video / * content.
- You save the octets and content type.
- Downloader downloads the video, and you use the type of content that you received.
- Downloader watches a video (or grumbles about codecs, etc.).
Malicious scenario 1:
- Uploader downloads an unpleasant trojan with video / * content.
- You save the octets and content type.
- Downloader downloads nasty trojan and you are using the type of content you received.
- Downloader opens a nasty trojan in a video player. Nasty trojan does nothing because this is not a video. The user grumbles about codecs. Worse, the script, they write rant on the ubuntu forums about the lack of support for proprietary formats, add unwritten comments on your page about how the site sucks because the video does not work, etc.
Malicious scenario 2:
- Uploader downloads an unpleasant trojan that is recorded in a video that uses some buffer overflow problem with a popular video player.
- You save ...
- Downloader ...
- It can be like one of the above, but it can also be that they fall under the exploit (if they use an infected player).
Three notes about scenario 2:
- Testing this video does not guarantee security, as it may work well in some players.
- Testing this video may make your server vulnerable to exploit if the vulnerability is in ffmpeg!
- Operations of this type are both rare and difficult. The overall risk is the same as downloading and downloading jpeg or png. In fact, this is a bit smaller (there was actually an exploit of this type, affecting the frequently used jpeg libraries for a while).
In general, just make sure that you only output with the types of content you accept and force the addition of file extensions; if the user is downloading a video / mpeg called hahaha.exe, then rename it hahaha.mpg
Edit: Oh, also:
Malicious scenario 3:
Uploader uploads a video that some players use in a way that uses a lot of resources. In this case, the bootloader will just kill-9 / ctrl-alt-delete / your-OSs-kill-them-all-of-choice, but if your server is testing this video, then this may end in troubles, since no one there step in and kill 200 (and grows when the script -kiddies script continues to load more) "videos" that it is trying to interpret.
Just doing the usual video processing may be enough to present DoS to you (video processing is relatively difficult in the end), so testing the file can lead to greater dangers, which will save you from.
source share