Quinn,
My apologies by I seem to miss something obvious here. In this reply you suggested two paths:
1. Use a private API to acquire the audit token of an XPC connection
2. Use PID but rely on that 2nd and forth messages are guaranteed to come from the same connection
While [1] is quite clear I'm completly puzzled by [2].
Which of the following do you suggest:
1. Run peer validation pased on code object created from a PID associated with the connection upon receiving the first message, then, if successful, mark that connection authenticated and perform priviliged work starting with the 2nd message
2. Same as [1] but re-validate the peer for each message
3. Something else
---
The scenario I have in mind is:
1. Malicious process starts, sends 2 messages
2. The system does whaterver it does, processes the messages and enques them for delivery to user's code
3. Malicious process through other means (e.g. timing?) figures out that its messages were enqued for delivery and initiates wrapping
4. Legitimate process takes its places
5. Enqueued messages finally reach user's code. User acquires PID, gets code object of the Legitimate process and responds to the messages. Since both message are already enqueued user has no chance (aside from using private API to get auditToken) to recognize malicious intent.
To avoid the attack, as I understand, the OS must not bulk process messages. Instead it should process them one by one, only picking the next message after user's code is done with the previous one.
In the scenario above it would force the peer to be around up until the moment the 2nd message was passed to user's code. Thus preventing the wrap.
Please guide me!