Support » Plugin: AWPCP - Classifieds Plugin » Way to Prevent Users From Uploading Images With Double Extensions

  • Resolved MickeyRoush


    Pretty much what the title says. A user tried uploading an image that was something like 12.13.12.jpg

    I believe that’s poor file name formatting anyways. Can’t remember the exact details right now. But I do not allow files of any sort that have a double extension to be uploaded. Too many possibilities for something malicious to happen. Especially when some server configurations allow double extensions, meaning either can be interpreted as the legit file extension. I don’t need anyone trying to upload something like script.php.jpg

    See here:

    Is there any way you can create a warning message or something to that affect that if they try to upload a file with more than one literal period, that they need to rename the file. Message “The file you are trying to upload has more than one literal period/dot in the file name. This is improper format for uploading a file here. Please rename the file with only one literal period/dot so the system can determine if it is an acceptable file.”


    Also I tried posting this on your own forums, but every time I try to login, I get a 404 Not Found.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author awpcp


    Hi Mickey,

    I checked the forum–seems OK to me. Maybe you caught it at a bad time?

    For multiple extensions, the last extension wins (per the link you sent above). If they use a bad multiple extension (like foo.jpg.php), we flat out reject it. If they use a bad file with a fake image extension (like a PHP file named foo.jpg or foo.php.jpg), we reject it again because it doesn’t meet the JPG format specifications.

    Bottom line: AWPCP is safe from this kind of attack–having these extra extensions is not an issue.

    If you have evidence to the contrary, I’d be interested in seeing it.

    Hello, yes this is the second time I tried to login to your forums and got sent to a 404 Not Found page. I previously sent you a message via your contact form. That’s okay, I can still read your forums. I’ll just have to post here.

    Here you go:

    Why File Upload Forms are a Major Security Threat

    Also, I would like to mention that this is only a suggestion. If it’s too much trouble don’t worry about it. If my users make this mistake I can just go in there and edit the image file name myself. It’s just a hassle to do so, and trying to explain it to them is out of the question.

    For any of my clients that only upload images, I create an .htaccess file to white-list what files can be access via HTTP. There’s just too many possibilities to cover. A php file extension is not the only executable file on most of the web servers out there.

    I use something like this in .htaccess:

    Order Allow,Deny
    <FilesMatch "^[\w()+-]{1,99}\.(?i:jpe?g|png|gif)$">
    Allow from all

    There are other bad things that can be done with double extensions. Some of those “how to’s” are on “White Hat” forums, which I think would frown upon me if I posted links to them on here.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Way to Prevent Users From Uploading Images With Double Extensions’ is closed to new replies.