Does the Catholic Church have a contingency plan for the case that the pope and all cardinals are dead? Most modern democratic countries have a chain of command which can be triggered in case of disastrous events and is intended to ensure the continuity of the functioning of the country.

This chain of command also relies on the fact that there is a plan to get back to normality. This usually means that the person in command has a set of elections to call (at a gouvernemental level) or people are automatically promoted to the missing positions (army, companies, ...).

How would that work with the Catholic Church?

Let's imagine a case that during papal election all the electors (cardinals) die (accident, terrorist attack, ...). Let's also imagine that all of the cardinals are present (which is likely).

Is there a plan for such situation? 

I am curious about that fact because in a democratic country the solution are popular elections (which bring in new rulers, from an extensive pool of candidates, though the voices of the population), in other institutions people would be automatically promoted to the new functions promotion. In contrast, the Catholic Church  only has a handful of electors (compared to the whole Church) and cardinals are explicitly nominated by the Pope (and nobody else). The candidate for Pope is also from the ranks of the cardinals.
Does the Catholic Church have a contingency plan for the case that the pope and all cardinals are dead?

There is no known official contingency plan for the Catholic Church in the case that if God forbid the pope and the entire College of Cardinals were to perish due to some unforeseen catastrophic event such as a terrorist attack or some highly contagious pandemic like the coronavirus during a papal election!

Ultimately, the Holy Spirit would through his inspirations would guide the Church in choosing another pope and thus a new pope could name cardinals of his choosing.

First of all let us remember what Our Lord said to St. Peter in Matthew 16:17-19:


  17 And Jesus answering, said to him: Blessed art thou, Simon Bar-Jona: because flesh and blood hath not revealed it to thee, but my Father who is in heaven.
  
  18 And I say to thee: That thou art Peter; and upon this rock I will build my church, and the gates of hell shall not prevail against it.
  
  19 And I will give to thee the keys of the kingdom of heaven. And whatsoever thou shalt bind upon earth, it shall be bound also in heaven: and whatsoever thou shalt loose upon earth, it shall be loosed also in heaven.


Thus as Catholics, we are assured that the Church will exist to the end of time and will be guided and protected through the inspirations of the Holy Spirit.

But how could this possibly be if the papacy and the entire body of the Sacred College of Cardinals were to die simultaneously?

Obviously there can not be many possible solutions as to how a new pope could be named and thus new cardinal electors could be forthcoming. However a few possible scenarios could happen.


There is no guarantee that there would be any need for a pope or cardinals at the moment of Our Lord’s second coming, according to Sacred Scriptures which guaranties only that the gates of hell shall not prevail against her. Thus this could simply be a prelude to the end of the world. The pope and cardinals would certainly not be necessary when the Jesus returns as Head of the Church!    
Each pope generally makes a last will and testament. A particular pope could under his unique apostolic authority name his successor if he so wish to. A pope does not have to be chosen from the ranks of the cardinals. Any baptized Catholic male could in theory be elected pope. At one time, it had been rumoured that Pope Pius XII wrote a letter that was to be published in the case he was taken prisoner by the Germans during World War II. In it he supposedly stated that he rescinded his rights as Pope Pius X if he was taken by the Nazis and was to once again Cardinal Eugenio Pacelli. For more information about this possibility see this post: Can a pope name his successor?
The most viable solution, would be that either the remaining Roman clergy and/or local bishops surrounding Rome would elect a successor to the See of St. Peter, in lieu of the College of Cardinals. In fact this was how the pope was elected for centuries before Canon Law and various papal documents defined how a papal election was to be handled.  (If need be the choice of naming a new bishop could be extended to all the remaining bishops of Italy.)



  In 1059, the right of electing the pope was reserved to the principal clergy of Rome and the bishops of the seven suburbicarian sees. In the 12th century the practice of appointing ecclesiastics from outside Rome as cardinals began, with each of them assigned a church in Rome as his titular church or linked with one of the suburbicarian dioceses, while still being incardinated in a diocese other than that of Rome.
  
  The term cardinal at one time applied to any priest permanently assigned or incardinated to a church, or specifically to the senior priest of an important church, based on the Latin cardo (hinge), meaning "pivotal" as in "principal" or "chief". The term was applied in this sense as early as the 9th century to the priests of the tituli (parishes) of the diocese of Rome.


Seeing that Canon Law is silent on this situation, simply because it is simply speculative and highly doubtful of actually occurring, the most simple solution would be that the world’s bishop would opt to this most ancient form of voting for a new Bishop of Rome.

If only the pope and the Roman Curia where destroyed as if a hydrogen bomb was detonated in the Colosseum of Rome, effectively wiping out the entire Roman Curia, there would still remain enough cardinals worldwide to elect a pope and start rebuilding!

In any case the Church would find a way and it would be aided by the Holy Spirit.

Here follows a couple of related questions which although similar, are not duplicates to this particular question:


What would the Catholic Church's hierarchy look like without the Vatican?
What would happen to the Catholic Church if all of the bishops get wiped out?
Existence of Catholic Church without hierarchy


Nota Bene: Perhaps a future pope reading this post could make amends to Canon Law accordingly to include such dire situation scenarios for the papal elections as mentioned above?