Updated

Glendale, AZ (SportsNetwork.com) - Drew Stanton threw two touchdown passes to rookie John Brown and the Arizona Cardinals remained unbeaten with a 23-14 win over the San Francisco 49ers on Sunday.

The 49ers could hardly stay out of their own way, losing for the second week in a row partly because of a slew of costly penalties.

The Cardinals (3-0) have won their first three games for the second time in the last three years and are 10-2 in their last 12 dating back to last season.

Stanton started again for Carson Palmer, who is still dealing with a shoulder injury he suffered in Week 1, and passed for 244 yards with touchdown strikes to Brown in the third quarter to take the lead.

"When you see guys get opportunities and the guys that make the most of it stay in the league," said Stanton. "I kept saying my time will come, my time will come, just being patient."

Brown, a third-round pick from Pittsburgh State, has three touchdown catches in his first three games going into Arizona's bye week. He caught four passes for 52 yards and Michael Floyd led all receivers with 114 yards on five grabs.

Andre Ellington rushed for 62 yards on 18 carries for the Cardinals, who were without deactivated second-stringer Jonathan Dwyer as he faces assault charges in Arizona.

The 49ers had nine penalties for 107 yards a week after committing 16 for 118 in a loss to Chicago. Several of them came in key situations down the stretch, including back-to-back 15-yarders leading to Brown's go-ahead touchdown catch in the third quarter.

They scored on their first two possessions of the game and were shutout the rest of the way. They have been outscored 52-3 in the second half this season.

Colin Kaepernick threw for 245 yards and rushed for a team-high 54 for San Francisco (1-2). Michael Crabtree had 10 catches for 80 yards and a 2-yard touchdown and Steve Johnson gained 103 yards on nine receptions.

"We should have two wins," said Kaepernick. "These games were close games that we should have won."

Brown scored on consecutive Arizona drives in the third quarter to give the Cardinals a 20-14 lead.

His 24-yard score was set up by Stanton's 45-yard pass to Floyd on third down and his 21-yard touchdown catch with 4:39 left in the quarter came after the 49ers committed unnecessary roughness and roughing the passer penalties.

Longtime Cardinals receiver Anquan Boldin had the next penalty for the 49ers, for unnecessary roughness to knock the 49ers back to the Arizona 21. That led to Cardinals defensive end Tommy Kelly blocking Phil Dawson's 45-yard field goal attempt.

Larry Fitzgerald had his first three catches of the game on Arizona's ensuing possession, and 49ers linebacker Patrick Willis was whistled for his second 15-yard penalty for hitting the Cardinals star in the helmet.

But Fitzgerald fumbled on his next catch when he was hit inside the 5-yard line by linebacker Michael Wilhoite, giving the 49ers a much-needed reprieve and the ball deep in their own territory with 6:54 remaining, but they punted.

Chandler Catanzaro capped the scoring with a 35-yard field goal, his third of the game.

Earlier, after Catanzaro kicked a 51-yard field goal for Arizona, the 49ers took a 7-3 lead on Crabtree's touchdown catch in the front-left corner of the end zone with under seven minutes left in the first quarter.

Catanzaro had a 32-yarder in the second quarter but San Francisco led 14-6 at halftime after Carlos Hyde took a toss out to the left and ran over a defender near the left pylon with 5:07 remaining.

Game Notes

Fitzgerald has at least one catch in 152 straight games ... Kaepernick completed his first 10 passes ... The Cardinals have a league-best 19 blocks since 2008 -- 17 on field goals and one each on a punt and an extra point ... Stanton made his first start since 2010 last week, completing 14-of-29 passes for 167 yards in a win over the Giants ... Arizona placed linebacker John Abraham, the NFL's active sack leader with 133 1/2, on injured reserve this week due to continued symptoms from a Week 1 concussion ... The 49ers are home against Philadelphia next Sunday and the Cardinals are on a bye.