Carl
Level 15

Get your taxes done using TurboTax

As an thought experiment if we had gifted him $10,000 at birth and that was used to buy Apple stock in a custodial brokerage account that would be worth $4.5M today

Now that's a good question I'd like a definitive answer to. Don't see it much; at least I've never seen such a scenario. But never say never.

Keep in mind that IRS Pub 970 is for the education stuff, and really doesn't get into the detail of what qualifies as a dependent. There's a completely unrelated and separate publication for the dependent stuff:  IRS Publication 17. 

Checking Pub 17 I can't find anything that comes even close to what you describe. However, here's my thoughts on it.

If the account is a "custodial" account, meaning that the child does not have direct control of it, I would interpret that as 3rd party income - even if the student is the one reporting gains/losses on their own tax return.  As for other scenarios where the child obtains sole and full control at say, the age of 18, the IRS pub addresses earned income and borrowed money. It does not address investment income for the purpose of determining dependent status; particularly when the initial cost basis of the investment comes from a 3rd party. Hopefully, someone more knowledgeable on this can jump in, and they may even be able to cite a tax court case or two? I don't know.