The incident happened just after noon near the intersection of Revere Avenue and Ingalls Street in the Bayview District, according to Muni spokeswoman Kristen Holland.
According to police spokesman Sgt. Wilfred Williams, the boy and a few other boys with him got off the bus following the attack and ran away.
Police responding to the area detained four boys, but they were later found not to have been involved.
"They were not identified as the ones who did the original assault," Williams said.
However, one of the boys officers stopped, a 16-year-old, had a BB rifle hanging from a rope beneath his jacket, and was taken into custody on charges of carrying a concealed weapon and possession of an air gun, according to Williams. The three others were released.
Williams said the Muni driver was not seriously injured.
The reason for the attack was not known, Williams said.