The 28-year-old moved to the Welsh capital from Norwich City in 2009 and helped the club clinch promotion to the Premier League by winning the Championship title last season.
"I'm delighted to have committed my future to Cardiff City," said the Scotland international.
"I've had a fantastic four and half years here already.
"It's a privilege to be part of what we're trying to achieve and the fans have been brilliant to me from day one.
"We've a lot of hard work left to do this season, but we're a confident group and have plenty of ability and belief."
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.