The way the law is phrased seems to suggest to me that the offence is merely changing places without permission and the only sanction is a yellow card for each player.
That said, there is certainly an ambiguity and it is surprising that it does not cover the eventuality of either player handling the ball inside their penalty area.
In practice, I struggle to see how it could really happen because presumably the outfield player would need to change into a goalkeeper kit and the goalkeeper would need to change into an outfield top. It does half make you wonder if it might be worth a team doing when they send their keeper forward in the last few minutes and leave a small full-back or whoever back to cover but presumably the time involved in doing this means it would be counter-productive.