For D-glyceraldehyde, I would expect the cyanide to attack the carbonyl opposite of the C2 OH due to electrostatic repulsion of the hydroxyl group, yielding the S configuration at the new stereocenter. I'm unsure about what happens when the carbohydrate is configured in a ring structure, however. Looking at glucose, where all hydroxyls are axial, there is no obvious steric or electrostatic reasoning for selectivity, as observed here.