Star sensor is imaging the space weak star point. The background noise from stray light will badly affect the extracting accuracy of image. So baffle design is the key technology of the star sensor. In this paper,the principle of baffle design is listed,the formula of the optimum length for two-stage baffle is deduced and an example of baffle design of a star sensor is cited. It is indicated that the new design has shorter length and better performance in stray light attenuation than the traditional barrel baffle.