School cheer junior high coach here. :) Junior high for our program was considered 5th-8th grade for years and years (this year it has been changed to 6th-8th grade). However, unlike you, all of the kids do attend the same school. It is a K-12 school, which is how we are able to combine both elementary and middle school on our team; for us, average age is taken to determine that we belong in the junior division.
I find it interesting that there are kids on the team that don’t technically go to your daughter’s school, I’ve not seen anything like that in my coaching career so far. If I had to guess, what they’re doing likely is illegal for school cheer, as something like that would disqualify a varsity level high school team. However, my guess is they get away with it because most competitions won’t look that deep into a junior team. Of course it could vary by state, but where I am, varsity is subject to much stricter rules (including things like transfer students, no-contact periods, etc.) than junior high ever is. If I’ve learned anything, it’s that frankly no one cares about junior high except for coaches like me and parents like you. So to answer the question, I’m pretty sure that is in fact illegal, or at least it would be where I live.
Competitions offer their rules online, so if you want to be sure you could search up the name of the competition followed by “rules pdf” and read through it to see. :)