49ers receiver Brandon Aiyuk scored his fifth touchdown of the season, matching his touchdown total from his 2020 and 2021.
The 49ers receiver caught a 7-yard touchdown pass from Jimmy Garoppolo with 13:35 remaining in the second quarter. It has given the 49ers their first lead, 7-3, after the Cardinals got an early field goal.
San Francisco went 82 yards in nine plays, only their second 80-plus-yard drive of the season.
Garoppolo is 7-of-10 for 57 yards and a touchdown. Deebo Samuel has three catches for 28 yards, and McCaffrey has five carries for 31 yards and two catches for 16 yards.
The Cardinals got a 40-yard field goal from Matt Prater in the first quarter.