Transparent Proxy: Enhancement Requests for setMetadata API

In our setup, our Transparent Proxy (call it TP1) funnels traffic to a helper process running on the same machine (call it Helper), which then actually sends out the traffic to the wider Internet. Now say there's another Transparent Proxy, TP2, on the same machine.

Assuming TP1 gets hold of the traffic first, the sequence would look like so: Safari --> TP1 --> Helper --> TP2

We want to make it appear to TP2 that the incoming traffic is from Safari, rather than from the Helper process.

We are aware of the Network framework's setMetadata API, but this does not look appropriate for us to use here. The Helper process is pre-existing Golang code, which at best can interface with "pure" (ie BSD) sockets-based C code. In order to use the setMetadata API, looks like we will need to rewrite the entire networking logic to use nw_connection_t (or similar) API, which is too much work, so is infeasible for us to use.

Is there a way to make the setMetadata API work at a socket level? e.g., associate the metadata with a socket so that whatever data is sent out on the socket by the Helper will seem to TP2 to be coming from the desired source process.

Assuming there isn't such a way, please consider this an Enhancement Request to make it so!

Also, this reveals another complication: If and when this Enhancement is implemented, our own TP1 (which interepted the traffic in the first place) would end up thinking that the traffic is from Safari, so ends up re-intercepting it, causing a loop.

Safari --> TP1 --> Helper (invokes setMetadata) --> TP1 --> Helper ...

Which leads to the next Enhancement Request: Please extend the API to allow setting of the "last-hop" source process in addition to the original source application. If the last-hop source process info is set, our TP1 can query this property, see that it's coming from our own Helper process, and skip interception.

In summary, here are the Enhancement Requests:

  1. Allow setMetadata API to work at a socket level
  2. Allow setting of "last-hop" source process in the metadata, in addition to the original source application

More succinctly, please allow setting of metadata to cater to cases where the actual egress happens via a (different) helper process that uses pure C sockets based API.

I have also filed this as a Feedback with Apple, at FB16048393.

Answered by DTS Engineer in 816952022
Is there a way to make the setMetadata API work at a socket level?

I don’t think so, but I’m going to confirm that.

I have also filed this as a Feedback with Apple, at FB16048393.

Thanks. That is the best way to get these requests in front of the right folks.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is there a way to make the setMetadata API work at a socket level?

I don’t think so, but I’m going to confirm that.

I have also filed this as a Feedback with Apple, at FB16048393.

Thanks. That is the best way to get these requests in front of the right folks.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

I don’t think so, but I’m going to confirm that.

Sadly, it seems that my initial impression is correct.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Transparent Proxy: Enhancement Requests for setMetadata API
 
 
Q