Ugandan striker Umaru Kasumba converted from the penalty spot to hand the visitors the win in what was a fiercely fought match.
Both sides managed to create clear-cut chances in the first half but none could make any one of them count.
Sofapaka's chances came through John Avire in the 17th minute and Stephen Waruru in the 25th minute but neither player could put the ball at the back of the net.
KCB's chances were spurned by Simon Munala and Chrispinus Onyango, whose shots just went off target in the 23rd and 34th minutes.
The entertaining match in Machakos ended with the score still pegged at 0-0 but Justin Ndikumana, Sofapaka's goalkeeper, was responsible for keeping KCB's incessant attacks at bay in the first 45 minutes.
Kepha Aswani appealed for a penalty in the 52nd when he was caught by a high boot from Michael Mutinda inside KCB's box. His appeal fell on deaf ears as the referee waved play on, leaving Aswani infuriated.
Onyango did not connect well with a cross delivered by Mutinda in the hour mark. Onyango's first touch let him, which allowed the advancing Ndikumana to close the space and the KCB's forward could only fire shot wide of the left-hand post.
Michael Kibwage fouled Waruru in the third minute of added time and the referee pointed to the spot to award Sofapaka a penalty. Kasumba took the spot-kick and scored the goal that secured the three points
Kasumba , who was introduced in the second half in place of Avire, handed Batoto ba Mungu victory in the first leg meeting with a solitary strike.
Sofapaka has managed to win four matches of the last six when they played KCB, with the league debutants managing just one win
They have drawn just once (1-1 on 29th April 2015) since they first met in 2013.