Suppose a hypothetical person makes $100K/year. He doesn't put any money into tax advantaged accounts (for simplicity). He pays about $17K in federal income taxes.
But the last year before retirement, he sets his state withholding crazy-high - $25K extra for the year. As a result he gets an extra $6500 back on his federal income taxes (because he itemizes deductions and deducts his state income taxes). He also gets a $25K refund on his state income taxes, obviously.
The next year that $25K state income tax refund counts as income but he's in a lower tax bracket - according to the TurboTax Taxcaster webpage, if he has no other income that next year he'll owe about $1750.
So this technique saved him about $5K in federal taxes.
But is it legal?