The 31-year-old prop or back-rower has been with the Tigers since the age of 15 and made his 250th senior appearance against Salford a fortnight ago.
Massey said: “I am obviously over the moon because I’ve made it no secret that I wanted to stay here.
“This next two years is going to be big for me and it will take me to near the end of my career. I’ve said that if it was possible to finish my career here and this contract might take me to that.
“I am proud to play for this club and I feel privileged to pull the shirt on every week and hopefully the next two years are going to be another good few years for the club.”
Lee Radford, who will take over as head coach when Daryl Powell leaves the club at the end of the season, says he is looking forward to working with the hard-working Massey.
Radford said: “He epitomises what Castleford is all about really. He is honest, hard-working and does things that the untrained eye doesn’t see.
“He’s really tidy in and around the ruck and it’s because of players like him that Castleford have been as successful as they have been in seasons gone by. I’m really looking forward to working with him.”