One way to look at this question is with analysis of past precedents and authorities regarding the substance of the question, as done by Andrew in his answer.
Another way to look at the issue is through a procedural lens.
As noted in answers to this question at Law.SE, the management of the Roman Catholic church is vested in the College of Cardinals at times when there is no living pope, and the College of Cardinals is given the authority to make that appointment.
Thus, anyone appointed by the College of Cardinals is conclusively legitimate and qualified. There is no one to whom their decision can be appealed unless the person who was appointed by them to be Pope declines to accept the appointment on the grounds that the person appointed does not feel that he is qualified to do so.
The cases where there have been ambiguities over whether a successor pope was properly appointed have given rise, over the last two thousand years, to the various antipopes who served at various times during the Middle Ages, overlapping with legitimate popes. There are many individual stories about how this happened in particular cases where popes and antipopes were in place at the same time. But most involve someone who either declared themselves to be the pope and received considerable backing after doing so, or someone who was declared by a secular emperor or king to be pope without the blessing of the legitimate college of cardinals. This is set out at further detail at the link:
Hippolytus of Rome (d. 235) is commonly considered to be the earliest
antipope, as he headed a separate group within the Church in Rome
against Pope Callixtus I. Hippolytus was reconciled to Callixtus's
second successor, Pope Pontian, and both he and Pontian are honoured
as saints by the Catholic Church with a shared feast day on 13 August.
Whether two or more persons have been confused in this account of
Hippolytus and whether Hippolytus actually declared himself to be the
Bishop of Rome remains unclear, since no such claim by Hippolytus has
been cited in the writings attributed to him.
Eusebius quotes from an unnamed earlier writer the story of
Natalius, a 3rd-century priest who accepted the bishopric of the Adoptionists, a heretical group in Rome. Natalius soon repented and
tearfully begged Pope Zephyrinus to receive him into communion.
Novatian (d. 258), another third-century figure, certainly claimed
the See of Rome in opposition to Pope Cornelius, and if Natalius and
Hippolytus were excluded because of the uncertainties concerning them,
Novatian could then be said to be the first antipope.
The period in which antipopes were most numerous was during the
struggles between the popes and the Holy Roman Emperors of the 11th
and 12th centuries. The emperors frequently imposed their own
nominees to further their own causes. The popes, likewise, sometimes
sponsored rival imperial claimants (anti-kings) in Germany to overcome
a particular emperor.
The Western Schism – which began in 1378, when the French cardinals,
claiming that the election of Pope Urban VI was invalid, elected
antipope Clement VII as a rival to the Roman Pope – led eventually
to two competing lines of antipopes: the Avignon line as Clement VII
moved back to Avignon, and the Pisan line. The Pisan line, which began
in 1409, was named after the town of Pisa, Italy, where the (Pisan)
council had elected antipope Alexander V as a third claimant. To end
the schism, in May 1415, the Council of Constance deposed antipope
John XXIII of the Pisan line. Pope Gregory XII of the Roman line
resigned in July 1415. In 1417, the council also formally deposed
antipope Benedict XIII of Avignon, but he adamantly refused to resign.
Afterwards, Pope Martin V was elected and was accepted everywhere
except in the small and rapidly diminishing area of influence of
Benedict XIII.
None of those permutations of succession issues seems likely in the 21st century.
But it isn't too hard to imagine a dispute over which people were legitimately members of the college of cardinals (i.e. a credentials fight) resulting in ambiguity over whether someone was a legitimate pope, or some irregularity in the proceedings of the Conclave in which someone was almost elected pope until there was a change of heart at the last moment due to some new information about that person, and there was a dispute over whether the Conclave had made its final determination in favor of that person or not.
For example, in the current Conclave, this issue has come up with respect to Cardinal Angelo Becciu, who was convicted of embezzlement by the Vatican criminal court and is currently serving a sentence of more than five years in prison. It is highly unlikely that a dispute over the right of a single Cardinal to participate in the Conclave would be outcome determinative, but it isn't impossible.
But since the College of Cardinals is the authoritative and final adjudicator of matters of Roman Catholic canon law in periods between the terms of living popes, ultimately, their resolution of the issue would be final and binding, if there was no dispute regarding what it had decided.
The only way that a pope selected by the Conclave's legitimacy and eligibility could be cast into doubt would be for there to be some sort of irregularity or dispute regarding the membership of the College of Cardinals, or over who the Conclave actually elected.