As per its assigned judicial role under the Constitution, (Article III Section 1: "The judicial Power of the United States, shall be vested in one supreme Court, and in such inferior Courts as the Congress may from time to time ordain and establish.") the Supreme Court ruled against the legality of secession. This ruling, by definition, makes secession an impermissible and illegal act under the United States Constitution as defined by the very court that this same Constitution grants authority on which to rule in the matter.
This was reinforced in 1868 in a ruling written by Chief Justice Chase. Texas vs White settled the issue of the legality of secession once and for all.
Chase, [Chief Justice], ruled in favor of Texas on the ground that the Confederate state government in Texas had no legal existence on the basis that the secession of Texas from the United States was illegal. The critical finding underpinning the ruling that Texas could not secede from the United States was that, following its admission to the United States in 1845, Texas had become part of "an indestructible Union, composed of indestructible states". In practical terms, this meant that Texas has never seceded from the United States.[58]
The Constitution is NOT a "simple" contract and contract law does not apply in any way. It is a ceding of power, not a quid pro quo and is by its own definition via the Articles of Confederation, to remain in existence in "perpetuity". It is in fact a charter built upon the Articles of Confederation which clearly assert that the Union of the states is "perpetual". The Constitution, "a more perfect Union", is therefore even more binding.
In the end, the issue could not be settled peacefully. War was waged and won. And thus the issue settled...that secession is not allowed nor legal. So there IS no longer a legal question under U.S. law regarding the legality of secession...the courts and a war have settled the issue...states may not secede and are bound in "perpetuity" to the Union. This does not mean states do not have many other rights...they most certainly do...but secession is not one of them.