It's not a federal law, but it's dictated by the States, etc, and local law. With that said...illegal in New York, but the hell any cop is going to enforce it seriously. You can readily get fireworks in China Town here and it's almost a tradition around my area to have amateur pyrotechnics, lol.
In fact, umm, my neighbor is a cop and he puts on one of the biggest displays every year.
The sad thing about this is that people are rarely injured with Fireworks, sure the idiot kid that blows his finger off is what you hear about on the news, and then everyone gets all up in arms and tries to ruin it for everyone. The funny thing about it is people will make a million friggin' laws for small things that rarely do any harm but will completely neglect the big issues that will really hurt their kids.
Example. Metal Lunchboxes are banned. What? Huh? Who? What? Some zealot PTA mom decides that metal lunchboxes can be used as a weapon. Oh the sharp corners, eek, danger. So all lunchboxes here end up being made of plastic now. It's a good thing they have plastic lunchboxes as the knives and guns that kids carry to school today will rattle less in a plastic lunchbox.

That's the type of stupidity I just can't stand.
So yes illegal in a state by state thing, but rarely enforced.