In a perfect world, the best way to prevent cross-site contamination is to have a server per site setup. Often this sort of setup is just unrealistic with spiraling costs forcing owners or website managers to group websites together.
In which case some basic ‘housekeeping’ practices will vastly help to control and prevent this type of infection:
1. Get rid of anything that you don’t need. If you have an old installation that you are not currently using – zip it until you need it so it is not live and active.
2. Keep separate user, admin and file permissions for every site (this relates to files and database). Where possible create a separate account for each website on the server – so the web user that serves up that site only has file permission access to the files of that site and not the files of any other websites on that server. Do the same for database users. Each account should have permission to work only on that website and thus even if it gets hacked it will not allow automatic connection to all the other websites on the server.