samboll – I’m using the latest WP (8.4.5?) and its getting hacked. That’s why I assume the vulnerabilities of the code.
The code is not vulnerable. Your site is. Two different things.
The fact that this code is being added to all your files suggests two things: a) your webhosts are idiots and b) you’re being hacked because some code is running on that server that’s searching for all the files it can and inserting that code into them.
This sort of thing happens mostly on shared servers that don’t have proper inter-user security working, so some other website on the server getting hacked can lead to every site on that server getting hacked.
Best advice: Leave that web host immediately.
Only sorta okay advice: Try to work with them to fix their servers. This may be difficult and time consuming.
Either way, WordPress is secure, but it can’t control other means of entry which are not.