Bailey, a junior, picked off a pass by Cardinal quarterback Kevin Hogan with 10 minutes 39 seconds left in the fourth quarter on a third-and-goal from the 10.
Cravens, a freshman, intercepted a tipped pass with 3:02 left to give the Trojans the possession that ended in the game-winning field goal.
Bailey and Cravens each have four interceptions this season.
Bailey has 10 career interceptions.
Linebacker Anthony Sarao had a team-best 12 tackles, linebacker Hayes Pullard 11.
Leonard Williams plays
USC defensive end Leonard Williams played despite a shoulder injury that could require surgery after the season.
The 6-foot-5, 290-pound sophomore from Florida made four tackles in the first half and finished with seven.
Soma Vainuku catching on
Fullback Soma Vainuku has been a special teams standout for USC, blocking two punts, including one that was returned for a touchdown last week against California.
Vainuku stepped up in the first quarter, catching a one-yard touchdown pass from quarterback Cody Kessler to give USC a 6-0 lead.
Vainuku also had a 15-yard reception that started the Trojans' second scoring drive.
Tre Madden returns
USC tailback Tre Madden, who played sparingly at Oregon State and sat out against Cal because of a hamstring injury, entered the game in the second quarter.
The third-year sophomore gained 11 yards in six carries.
Madden, however, remains the Trojans' leading rusher with 682 yards.
Jordan Williamson sat out because of an apparent leg injury, so former Loyola High kicker Conrad Ukropina handled kicking for Stanford.
Ukropina, a sophomore from Pasadena, kicked a 27-yard field goal in the second quarter to pull the Cardinal to within 17-10.
His 30-yard field-goal attempt in the third quarter was blocked by USC lineman Chad Wheeler.
Pac-12 Commissioner Larry Scott, when asked about NCAA sanctions that USC continues to operate under, said, "by any objective measure" USC was "treated in an unduly harsh" fashion compared with schools that have come under NCAA scrutiny since.
Scott spoke with reporters in the press box before the game.
Scott reiterated that the conference was not close to reaching a deal with DirecTV to carry the Pac-12 Networks.
He said he was a fan of the four-team College Football Playoff that will begin next season. "I love the playoff from the Pac-12's perspective," he said.
Asked to assess Pac-12 officiating, Scott said, "Generally very strong, but certainly far from perfect."