Preheat the oven to 350°F and line two 9-inch round cake pans with parchment circles and lightly grease the sides.
In a large bowl whisk together flour, granulated sugar, baking soda, salt, and cocoa powder until evenly combined.
In another bowl whisk oil, eggs, buttermilk, vanilla, vinegar, and red food coloring until smooth and uniformly red.
Add the wet ingredients to the dry ingredients and mix with a mixer on low just until a smooth batter forms without overmixing.
Divide the batter evenly between the prepared pans and tap pans gently to release large air bubbles.
Bake the cakes for 28 to 32 minutes until a toothpick inserted in the center comes out with a few moist crumbs.
Cool cakes in pans on a wire rack for 10 minutes, then invert onto the rack, peel parchment, and cool completely.
For the custard, heat milk in a medium saucepan over medium heat until steaming but not boiling.
In a bowl whisk egg yolks, sugar, cornstarch, and a pinch of salt until pale and thick.
Slowly whisk half the hot milk into the yolk mixture to temper, then return the mixture to the saucepan while whisking.
Cook over medium heat, whisking constantly, until thick bubbles pop and the custard holds whisk trails, about 2 to 3 minutes.
Remove from heat and whisk in butter and vanilla, then transfer to a shallow dish, press plastic wrap on the surface, and chill until cold.
For the frosting, beat softened butter and cream cheese on medium speed until creamy and smooth, about 2 minutes.
Add powdered sugar and vanilla to the mixer and beat on low until incorporated, then on medium until fluffy, 2 minutes more.
Level the cooled cake layers with a serrated knife if domed, reserving crumbs for garnish if desired.
Place the first cake layer on a board, pipe a 1/2-inch tall ring of cream cheese frosting around the edge to form a dam.
Spoon and spread the chilled custard inside the frosting dam in an even layer to about 1/2 inch thick.
Top with the second cake layer and press gently to set, then crumb-coat the cake with a thin layer of frosting.
Chill the cake for 20 to 30 minutes to set the crumb coat, then finish frosting smoothly with the remaining frosting.
Garnish with reserved cake crumbs or chocolate shavings if desired, slice with a warm knife, and serve.