The software that are used for mining is OpenSource, so it has been tried and tested for many years by the best developers out there. I have not seen anyone complaining about any exploits that has been found in the software yet.
The problem comes in when people download the wrong software that are not signed and this software might be exploited by hackers. I talk in general about software and not specifically of Bitcoin, because people are mining with different software.
Here are some basic information <outdated> to get you started,
https://www.coindesk.com/information/how-to-set-up-a-miner