This is a bit like asking if the NFL has a procedure in place to prevent someone who secretly can't play football from playing as a quarterback. The answer is yes, but it's impossible to explain in full detail how this works. Here's a rough idea, though:
At the very least, the would-be pope would undergo the scrutiny of: his fellow priests, his own bishop, various parishioners, various fellow scholars, various bishops, those in the Holy See who check up on candidate bishops, priests over which he would gain authority, fellow bishops including cardinals, and the present pope. He would also spend a fair bit of his life being busy in the Church.
Then, at some unpredictable point in time, he would need to be considered not only "good enough", but the best candidate by 2/3 of the cardinals during a papal conclave. This is an event that, due to modern media coverage, can be followed by up to over a billion praying Catholics. And also non-Catholics.
The Holy Spirit surely plays no small role in all aspects of this process, a process which has been developed over a period of about 2000 years. Many of the stages are specifically aimed at attempting to ensure that the devil does not succeed in having a non-believer elected as pope.
This process was, of course, not used by Christ when he intentionally chose Judas as one of the twelve, knowing that Judas would betray him. (Judas should not to be confused with St Peter, the first pope.)
As for "firing" the pope, this is a separate question, but the short answer is: no.