The Orlando Pirates striker smashed his shot goalwards on 73 minutes and the ball clattered against the crossbar and down. There was some debate over whether the ball crossed the line, but the goal was awarded.
South Africa are level at the head of the pool with North African guest nation Egypt, who beat Mozambique 1-0 on the opening day on Wednesday, though they top the table on goal-difference.
Luvuyo Mkatshana missed a good headed chance early on for the South Africans, who had Mauritius pinned in their own half. Foster hit the woodwork in the second period before scoring his first.
He made the points safe deep into injury-time when he beat the offside trap and as the Mauritians stopped playing, the Pirates youngster blasted the ball into the back of the net. He was also involved in a nasty incident after being punched by Mauritius captain Alex Ferre, but none of the match officials spotted the incident.
Meanwhile, Lesotho and Zimbabwe played to a goalless draw in the earlier game in Group C, with Angola and Namibia to clash in the other fixture in that pool on Friday (kick-off 11h30 local; 09h30 GMT).
Lesotho were unlucky early on when Raboama Koloti’s shot hit the outside of the post and deflected away behind. John Mohai then forced a fine save from Tinotenda Ali as Lesotho had the better of the first half action.
It was the defences on top in the second period as both teams failed to create clear-cut chances and resorted to shooting from long-range. The other games on Friday are both in Group A as hosts and holders Zambia will seek redemption for their opening day loss to Uganda.
They take on Malawi in their second clash at the Arthur Davies Stadium (kick-off 5.30pm local; 3.30pm GMT) knowing that a second defeat would put them out of the tournament at the first hurdle.
Malawi won their opening match with a fine 3-2 success over Swaziland, with the latter now in action against Uganda at 2.30pm local; 12.30pm GMT).
Only the top team in each pool and the best runner-up advance to the semifinals that will be played on December 14.
Lesotho 0 Zimbabwe 0
South Africa 2 (Foster 73’, 90’) Mauritius 0