Planets that orbit their parent star at less than about one astronomical unit (1 AU is the Earth–Sun distance) are expected to be engulfed when the star becomes a red giant1. Previous observations have revealed the existence of post-red-giant host stars with giant planets2,3,4orbiting as close as 0.116 AU or with brown dwarf companions5,6in tight orbits, showing that these bodies can survive engulfment. What has remained unclear is whether planets can be dragged deeper into the red-giant envelope without being disrupted and whether the evolution of the parent star itself could be affected7,8,9. Here we report the presence of two nearly Earth-sized bodies orbiting the post-red-giant, hot B subdwarf star KIC 05807616 at distances of 0.0060 and 0.0076 AU, with orbital periods of 5.7625 and 8.2293 hours, respectively. These bodies probably survived deep immersion in the former red-giant envelope. They may be the dense cores of evaporated giant planets that were transported closer to the star during the engulfment and triggered the mass loss necessary for the formation of the hot B subdwarf, which might also explain how some stars of this type did not form in binary systems.