The new deal will keep Foster - who has also played for London Broncos - at the club until the end of the 2019 season.
Foster, 23, joined Tigers on trial in February after Bradford Bulls’ liquidation and then agreed a full-time contract until the end of this season.
He made his Castleford debut against Huddersfield Giants in May and also played in the recent Magic Weekend victory over Leeds and last weekend’s home win against St Helens.
Foster, who has been named in Tigers’ squad for Sunday’s visit of Warrington Wolves, said: “I’m over the moon to sign here for another two years.
“It’s a great place to be at the moment and everyone can see why with how well the boys are doing on the field.
“I’m really happy to be working with this group of players and the staff as well and I can’t wait for the next two years.”
Tigers coach Daryl Powell said: “I’ve been really impressed with Alex since he arrived at the club.
“He hasn’t had a pre season and he’s had minimal game time, but he’s battled his way through all of that and a couple of injuries and he looks like he’s going to be a really strong player for us
“The games that he has played he has been tough and aggressive. He’s got some work to do on his skill sets and understanding our game, but his defensive mentality is absolutely superb and some of his line running is great and he’s only going to get better within our environment.”