Problems with file uploads

How to configure and adapt Aimeos based shops as developer
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
flomo
Posts: 52
Joined: 26 Sep 2019, 15:11

Problems with file uploads

Post by flomo » 26 Sep 2019, 15:19

I have this config in my config/shop.php file:

Code: Select all

    ...
    'controller' => [
        'common' => [
            'media' => [
                'standard' => [
                    'files' => [
                        'allowedtypes' => [
                            'image/gif',
                        ],
                    ],
                    'preview' => [
                        'allowedtypes' => [
                            'image/gif',
                        ],
                    ],
                 ],
             ],
         ],
         ... 
However, I can upload all kind of images, when creating a product. Even PDF or Zip files. Why doesn't the Shop prevent those uploads?

Also, is there an option to rename the upload folder and filename (other name instead of "/preview/" and random filename without extension)?

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Problems with file uploads

Post by aimeos » 26 Sep 2019, 19:50

flomo wrote: 26 Sep 2019, 15:19 However, I can upload all kind of images, when creating a product. Even PDF or Zip files. Why doesn't the Shop prevent those uploads?
This configuration are the mime types that are allowed when converting images, not the mime types allowed for uploads (that can be everything).
flomo wrote: 26 Sep 2019, 15:19 Also, is there an option to rename the upload folder and filename (other name instead of "/preview/" and random filename without extension)?
Yes, if you extend and overwrite the media controller class:
https://github.com/aimeos/aimeos-core/b ... #L340-L362
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

flomo
Posts: 52
Joined: 26 Sep 2019, 15:11

Re: Problems with file uploads

Post by flomo » 26 Sep 2019, 20:37

This configuration are the mime types that are allowed when converting images, not the mime types allowed for uploads (that can be everything).
Is there any logic in place to control the upload? Where/how would that be done? I managed to upload a .php file, which is potentially very dangerous.
Yes, if you extend and overwrite the media controller class:
https://github.com/aimeos/aimeos-core/b ... #L340-L362
Perfect, thanks a lot!

User avatar
aimeos
Administrator
Posts: 7866
Joined: 01 Jan 1970, 00:00

Re: Problems with file uploads

Post by aimeos » 27 Sep 2019, 09:22

You can whitelist the mime types you want to allow here:
https://github.com/aimeos/aimeos-core/b ... #L455-L499
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply