Moses
Genesis 40:4ESV·traditional attribution

The captain of the guard appointed Joseph to be with them, and he attended them. They continued for some time in custody.

Matthew Henry Presbyterian @wholebiblehenry

We should not have had this story of Pharaoh's butler and baker recorded in scripture if it had not been serviceable to Joseph's preferment. The world stands for the sake of the church, and is governed for its good. Observe, 1. Two of the great officers of Pharaoh's court, having offended the king, are committed to prison.

Commenting on Genesis 40:1-4

John Gill Reformed Baptist @doctorgill

And the captain of the guard charged Joseph with them,.... Committed them to his care and custody, he being very probably recommended to him by the keeper of the prison for his prudence and fidelity; and if it was Potiphar, he knew his character full well, and might be now reconciled unto him, as having had a more full and clear account of the affair...

Jamieson-Fausset-Brown Reformed @jfbcommentary

The captain of the guard charged Joseph with them--not the keeper, though he was most favorably disposed; but Potiphar himself, who, it would seem, was by this time satisfied of the perfect innocence of the young Hebrew; though, probably, to prevent the exposure of his family, he deemed it prudent to detain him in confinement (see Psa 37:5).