My first thought was in the controller. Then after further thinking...... it is uploaded from the controller to the drone.
Why I came to this conclusion is because if the drone drops contact with the controller (and if set ) it has the details stored to enable it to complete the task and then RTH.