Risks to set permissions 777
Some things you should check:


Check if the owner of the sites/default/files is the proper user and groups. The user and group usually is www-data, but it depends on your webserver.
Since you mention temporary folder, you should check if the temporary directory at admin/config/media/file-system section of administrator interface is configured properly.



  What risks are there to set permissions 777?


It is a very very bad practice. There are tons of materials on the net you can look at, but long story short: Setting the permission to 777 means that anyone can write and execute anything in that folder, including malicious codes.