Time to take the defibrillator paddles to this proposal once again. As per Nick&#39;s request this is a bit more focused on the motivation for getting connection related information. The proposed use cases are just some naive examples I&#39;ve come up with. If anyone with a stronger security background (which wouldn&#39;t take much...) has the time I&#39;d love comments like &quot;WTF?!? This idiot&#39;s looking for the completely wrong things! This is obviously worthless if he doesn&#39;t look for X.&quot;<br>
<br>Also, could we move forward on the other (less controversial) items? For instance, bandwidth totals tend to be a very highly requested piece of information and pipe&#39;s already provided a nice patch to get it (<a href="http://www.mail-archive.com/or-talk@freehaven.net/msg13085.html">http://www.mail-archive.com/or-talk@freehaven.net/msg13085.html</a>). For reference, here&#39;s the not-so-controversial GETINFO options I proposed:<br>
<br>  &quot;info/relay/bw-limit&quot; -- Effective relayed bandwidth limit (currently<br>    RelayBandwidthRate if set, otherwise BandwidthRate).<br><br>  &quot;info/relay/burst-limit&quot; -- Effective relayed burst limit.<br>
<br>  &quot;info/relay/read-total&quot; -- Total bytes relayed (download).<br><br>  &quot;info/relay/write-total&quot; -- Total bytes relayed (upload).<br><br>  &quot;info/uptime-process&quot; -- Total uptime of the tor process (in seconds).<br>
<br>  &quot;info/uptime-reset&quot; -- Time since last reset (startup or sighup signal, in<br>    seconds).<br><br>  &quot;info/descriptor-used&quot; -- Count of file descriptors used.<br><br>  &quot;info/descriptor-limit&quot; -- File descriptor limit (getrlimit results).<br>
<br>  &quot;ns/authority&quot; -- Router status info (v2 directory style) for all<br>    recognized directory authorities, joined by newlines.<br><br>I&#39;m not planning on converting the following to the customary 80-character width until it&#39;s at least past being a first draft for a couple reasons:<br>
  1. I find editing fixed-width documents to be a time consuming pain in the ass.<br>  2. I&#39;ve yet to hear why we do this. Is it just to cater to mail clients too dumb to know how to line wrap?<br><br>that said, keeping my fingers crossed that this starts going somewhere! -Damian<br>
<br>PS. For previous discussions of this proposal see:<br><a href="http://marc.info/?t=126101683100002&amp;r=1&amp;w=1">http://marc.info/?t=126101683100002&amp;r=1&amp;w=1</a><br><br>----------------------------------------<br>
<br>Filename: xxx-connection-getinfo-option.txt<br>Title: GETINFO controller option for connection information<br>Author: Damian Johnson<br>Created: 14-Apr-2010<br>Status: Draft<br><br>Overview:<br><br>    This details an additional GETINFO option for tor controllers that would provide information concerning a relay&#39;s current connections.<br>
<br>Motivation:<br><br>    All Internet facing applications (tor included) are possible vectors for attack on the operator&#39;s system. With hundreds of connections to relatively unknown destinations tor is already the bane of any network based IDS, and unless tor can be proved infallible and bug free (which would be quite a feat!) it cannot be blindly trusted.<br>
    <br>    While it is impossible to guard against every potential future vulnerability, controllers can attempt to mitigate this threat by both auditing tor&#39;s behavior and providing indicator of its activity to savvy users. Connection related information is a useful tool for both of these purposes.<br>
    <br>    In terms of auditing, the following are some conditions controllers can check for with connection information:<br>      - Persistent unestablished circuits. For instance a circuit has an outbound connection without a corresponding inbound counterpart. If such a connection was active (had substantial traffic) this would be troubling enough to alert the user.<br>
      - Relatively asymmetric traffic on circuits. Ie, if the controller sees 10 kb/s inbound on a circuit and 5 mb/s outbound this could be a good indicator that someone&#39;s using tor to issue a dos, fetch data from the local system, etc.<br>
      - Any connections to the local network when ExitPolicyRejectPrivate is set, indicating that tor&#39;s being used to proxy connections to the local lan.<br>      - Peculiar patterns of connections, for instance numerous outbound connections to a single IP, or if 99% of all bandwidth belonging to a single circuit.<br>
      - Scrubbed connection data limits our ability to check for
obedience to the exit policy, but for strictly
non-exit relays we can still alert the user if any non-relay outbound
connections occur.<br>
    <br>    Of course if we&#39;re working from the assumption that tor has been compromised, then the information provided from the control port cannot be blindly trusted. Hence connection data should be validateable against the system&#39;s connection querying utilities (netstat, ss, lsof, etc - which are more likely to be under a host based IDS, if present). This requires that the system&#39;s been completely compromised (elevated permissions) before controllers can be tricked, rather than just tor.<br>
    <br>    While automated detection is handy for detecting known behavior that might indicate issues, visualization gives us the possibility of finding much more thanks to our tinfoil hat wearing user base. A clear display of tor&#39;s current behavior gives assurance that tor&#39;s functioning as it should, plus a level of transparency desirable from anyone with even the slightest bit of paranoia. Tor is a guest process in the system of relay operators and we should not hide what it does without legitimate reason.<br>
    <br>    Another (albeit unintended) benefit of visualizing tor&#39;s behavior is that it becomes a helpful tool in puzzling out how tor works. For instance, tor spawns numerous client connections at startup (even if unused as a client). As a newcomer to tor these asymmetric (outbound only) connections mystified me for quite a while until until Roger explained their use to me. The proposed TYPE_FLAGS would let controllers clearly label them as being client related, making their purpose a bit clearer.<br>
    <br>    At the moment connection data can only be retrieved via commands like netstat, ss, and lsof. However, fetching it via the control port provides several advantages:<br>      <br>      - scrubbing for private data<br>
          Raw connection data has no notion of what&#39;s sensitive and what is not. The relay&#39;s flags and cached consensus can be used to take educated guesses concerning which connections could possibly belong to client or exit traffic, but this is both difficult and inaccurate.<br>
      <br>      - additional information<br>          All connection querying commands strictly provide the ip address and port of connections, and nothing else. However, for auditing and visualization the far more interesting attributes are the connection&#39;s bandwidth usage, uptime, and the circuit to which it belongs.<br>
      <br>      - improved performance<br>          Querying connection data is an expensive activity, especially for busy relays or low end processors (such as mobile devices). Tor already internally knows its circuits and connections, allowing for vastly quicker lookups.<br>
      <br>      - cross platform capability<br>          The connection querying utilities mentioned above not only aren&#39;t available under Windows, but differ widely among different *nix platforms. FreeBSD in particular takes a very unique approach, dropping important options from netstat and assigning ss to a spreadsheet application instead. A controller interface, however, would provide a uniform means of retrieving this information.<br>
<br>Security Implications:<br><br>    The original version of this proposal left the responsibility of scrubbing connection data with client applications (vidalia, arm, etc). However, this was deemed unacceptable by Sebastian and Nick in previous discussions. The proposal now includes dropping the ip address/port of client and exit connections from the controller&#39;s response. That said, I think it&#39;s a mistake to drop those connections entirely since some of their attributes *are* of legitimate usefulness:<br>
    <br>    - Existence<br>      At the very least it&#39;d be nice if Tor indicated their existence (ie, I&#39;d say &quot;yea, an exit connection exists on this circuit but we won&#39;t tell you where it goes.&quot;). This would be useful, for instance, if the relay operator has misconfigured their firewall to block some of the outbound ports permitted by their exit policy (arm would show this as RELAY -&gt; YOU -&gt; UNESTABLISHED, and provide a warning to indicate the issue).<br>
    <br>    - Bandwidth<br>      For auditing the most interesting attribute of connections, imho, is the bandwidth. If, says 10 KB/s is coming in and 1 MB/s is going out on a circuit that&#39;s a good indicator that something is *very* wrong (I&#39;d start suspecting a security issue, personally). If we rounded all bandwidth measurements (say, to the nearest KB) would this be sufficient to prevent entry/exits from correlating this data to attack anonymity?<br>
    <br>    - Uptime<br>      If connections are being cycled abnormally quickly (say, all connection longevity is under thirty seconds) this could indicate the ISP (or other middlemen like the great firewall) are sending reset packets to kill the relay&#39;s attempts to make exit connections.<br>
<br>Specification:<br><br>   The following addition would be made to the control-spec&#39;s GETINFO section:<br><br>  &quot;conn/&lt;Circuit identity&gt;/&lt;Connection identity&gt;&quot; -- Provides entry for the<br>    associated connection, formatted as:<br>
      CONN_ID CIRC_ID OR_ID IP PORT L_PORT TYPE_FLAGS READ WRITE UPTIME<br><br>    none of the parameters contain whitespace, and additional results must be<br>    ignored to allow for future expansion. Parameters are defined as follows:<br>
      CONN_ID - Unique identifier associated with this connection.<br>      CIRC_ID - Unique identifier for the circuit this belongs to (0 if this<br>        doesn&#39;t belong to any circuit). At most their may be two connections<br>
        (one inbound, one outbound) with any given CIRC_ID except in the case<br>        of exit connections.<br>      OR_ID - Relay fingerprint, 0 if connection doesn&#39;t belong to a relay.<br>      IP/PORT - IP address and port used by the associated connection, 0 if<br>
        connection is used for relaying client or exit traffic.<br>      L_PORT - Local port used by the connection, 0 if connection is used for<br>        relaying client or exit traffic.<br>      TYPE_FLAGS - Single character flags indicating directionality and type<br>
        of the connection (consists of one from each category, may become<br>        longer for future expansion).<br>          Connection Directionality:<br>            I: inbound, i: listening (unestablished inbound),<br>
            O: outbound, o: unestablished outbound<br>          Usage Type:<br>            C: client traffic, R: relaying traffic,<br>            X: control, H: hidden service, D: directory<br>          Destination:<br>            T: inter-tor connection, t: outside the tor network<br>
        For instance, &quot;IRt&quot; would indicate that this was an established<br>        1st-hop (or bridged) relay connection.<br>      READ/WRITE - Total bytes read/written over the life of this connection.<br>      UPTIME - Time the connection&#39;s been established in seconds.<br>
<br>  &quot;conn/all&quot; -- Newline separated listing of all current connections.<br><br>