I've answered something that touches on that slightly before, but will look at it again here:
There are two ways to look at the answer, as you can either consider the full union republics (what would become Russia, Ukraine, Kazkhstan, etc; the 15 independent states of today), or the autonomous republics and regions within the Russian SFSR (what is now Russia). And it should be noted that while both types of states were effectively created on ethnic lines, the term "ethnic republic" is not really used for them, but rather their more formal titles (union republic, or autonomous republic).
As for the former they were legally allowed to secede from the USSR; Article 72 of the 1977 Soviet Constitution stated: "Each Union Republic shall retain the right freely to secede from the USSR." Of course it wasn't that easy, as Articles 74 and 75 (which stated that laws of the USSR superseded laws of the individual republics, and that the USSR was a single entity, respectively) made it complicated, among other things. However these republics had various levels of support for staying within the USSR, with some, like the Baltic states (Estonia, Latvia, Lithuania), and Georgia, very opposed to the Union, while others, namely the Central Asian states (Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Uzbekistan) preferring to stay. The 1991 Soviet referendum, which asked voters if they wanted to stay in the USSR, shows this: while the Baltic states, Armenia, Georgia (excluding Abkhazia and South Ossetia), and Moldova boycotted it, the Central Asian republics had the highest levels of support, with 95% in support in each (it was only 73% in the Russian SFSR by comparison, and 78% across the USSR).
With this uncertain level of support, and the subsequent August coup attempt against Gorbachev, states began to declare their independence (the Baltics and Georgia had done so previously, in 1989, but it was more a formal declaration then; in 1991 it was more de facto). After the coup the remaining states, even the reluctant Central Asian ones, declared independence as well, and the USSR effectively ceased to exist by the end of the year.
As for the autonomous republics within Russia, that is a more difficult question. They did not posses the legal right to secede, with the dissolution of the USSR their status was in legal limbo. This was mostly resolved in 1992 when Yeltsin signed a Federation Treaty with 86 of the 88 federal subjects within Russia, that confirmed their rights vis-à-vis the federal government; only Chechnya and Tatarstan did not sign it. Chechnya of course became a de facto independent republic, the Chechen Republic of Ichkeria, which was allowed to exist due to the weakened state of the Russian government, but ultimately led to the First Chechen War of 1994-96, and second war of 1999-2000. Tatarstan refused to sign the treaty until 1994, owing to its relative wealth (there is a considerable amount of oil in the region), and sought guarantees it would keep a large degree of autonomy and rights, which the 1994 treaty did.
So in conclusion, there were occasions where the so-called "ethnic republics" did break away, and in some cases it was technically legal (depending on how one interprets the laws).