The best thing is to look for references from people who worked *with you* at those companies but weren't your direct bosses - coworkers, people from other departments, someone from HR if you got along with them. If you really can't find anyone from that time, you can use references from clients, suppliers, or people from specific projects you worked on; employers understand that contacts get lost over time and it's not unusual for someone not to have references from their most recent jobs. What matters is that whoever recommends you can speak to your actual performance, without needing to be your boss. Another option is not to put those companies in your references but still include them in your CV, that way you show your experience without exposing yourself to a toxic manager sabotaging you.