my $id = $q->param('id');
DisplayPrivateMessage($id);
While the program properly exits if authentication fails, it does not ensure that the message is addressed to the user. As a result, an authenticated attacker could provide any arbitrary identifier and read private messages that were intended for other users.
One way to avoid this problem would be to ensure that the "to" field in the message object matches the username of the authenticated user.