Requiring a valid SS number to get a child credit is a sensible first step. But the best solution is to limit any tax refund to the amount of taxes actually paid, whether the worker is in the country legally or not.
And the long-term solution to the illegal immigrant problem is to make foreign workers legal again.
All the current problems can be traced back to the elimination of the Bracero program. Millions of Mexican green card holders crossed the border back and forth under that program. They came to pick crops and do day labor and went back home to their families when there was no work. When the program ended after working perfectly for over 30 years, millions of Mexican families were left with no livelihood. You know the rest.