The Canadiens will also receive a fifth round draft pick in 2007 while the Stars get a a sixth-round pick in 2008.
Montreal is short of defencemen with injuries to Sheldon Souray, Francis Bouillon and Jean-Philippe Cote.
The Canadiens claimed rearguard Patrick Traverse on waivers from San Jose on Thursday.
The six-foot-one, 220-pound Niinimaa, 31, is a 10-year NHL veteran.
He has 54 goals and 262 assists in 700 career games.
He was traded to Dallas by the New York Islanders last January.
Ribeiro has played 276 career games for Montreal, collecting 50 goals and 103 assists.