One time, the IRS "lost" the cost basis for my investments during a year of heavy trading. They sent me a bill for $400k. After fighting with them for over two years, I eventually had to pay them ($180 for something else I had overlooked and never got the records for). I went back and forth with them three times, and they kept claiming that I owed them smaller amounts, but still much larger than anything I actually owed.
Most recently, I accidentally over-withheld on my 2024 income. They owe me about $30k and they're in no hurry to pay me. Fortunately, I learned that they must pay interest (7%!) on my over-payment. Hopefully I'll get this settled before next April 15th, but if I don't, I'll be sure to under-withhold on some of my deferred income this year to balance it out.
What I've learned from all of this is that the IRS is less concerned with what is legal than with how much of your money they can grab. If you're wealthy enough to afford a good tax attorney, you can usually fight them and win.