Generally, the capital gains pass through to the heirs. The estate reports the gain on the estate income tax return, but then takes a deduction for the amount of the gain distributed to the heirs since this usually happens during the same tax year. Then the estate issues K-1s to the beneficiaries passing through the gain. Schedule K-1 (Form 1041) is an official IRS form that’s used to report a beneficiary’s share of income, deductions, and credits from an estate or trust.
All of that said, estates usually have little or nothing in capital gains to report due to the step-up in basis. When you inherit real estate, the property's tax basis is “stepped up,” which means the value is re-adjusted to its current market value and often reduces or entirely eliminates the capital gains tax owed by the beneficiary.