onion-grater, a Tor Control Port Filter Proxy

From Whonix
< Dev
(Redirected from Dev/CPFP)
Jump to navigation Jump to search

onion-grater, a Tor Control Port Filter Proxy - filtering dangerous Tor Control Port commands - Design Documentation


Onion-grater is a filtering proxy for the Tor Controller listening on Whonix-Gateway internal network interface, which is the interface that the Whonix-Workstation connects when sending controller commands. It acts based on whitelists, denying everything by default and only allowing explicitly specified commands (and their arguments) and events.

According to upstream Tails OS documentationarchive.org, onion-grater is defined as: This filter proxy allows fine-grained access whitelists of commands (and their arguments) and events on a per-application basis.

Contrary to Tails, the fields user and per-application (AppArmor profile) are ignored with the wildcard '*' to include everything, that due to Whonix design of user space and tor daemon separation, these methods are not possible. Instead of that, what provides greater security to further separate applications and their requests to Tor's Control Protocol is using Multiple_Whonix-Workstation, and you can control per Whonix-Workstation hosts directive for the onion-grater profile to match the Whonix-Workstation LAN IP. As using Multiple Whonix-Workstation requires more work as the Whonix-Gateway does not know all the Whonix-Workstation LAN IPs, the hosts defaults to hosts: '*' and if you want to minimize the attack surface of Whonix-Workstation to the Whonix-Gateway Tor Controller, you could set the hosts directive to match your chosen Whonix-Workstation LAN IP.

Tor's control port has in context of Whonix, dangerous features. The answer to the Tor control command GETINFO address will be the real external IP of the Tor client. Other dangerous commands include SETCONF, LOADCONF, GETCONF, GETINFO ns/id/<relay-fingerprint>.

The dangerous commands can only be limited with a proxy, since the feature request Option to limit information Tor's control port disclosesarchive.org against Tor has not been implemented. By the way, this Tor control port feature makes also a Bridge Firewallarchive.org impossible.

Tor Browser by default performs its own control port verificationarchive.org. It checks using Tor's control port(!), that the socks port Tor reports, is the same one as Tor Browser is configured to use. If it fails, and it would fail in Whonix 0.5.6, Tor Button would look like disabled and show a failure message. (To see how this would look like, see this screenshotarchive.org.) (To see how this generates user confusion, see this forum threadarchive.org.) Since Whonix 6 this check is disabled using environment variable to skip TorButton control port verificationarchive.org (export TOR_SKIP_CONTROLPORTTEST=1) by package anon-ws-disable-stacked-torarchive.org. [1]

With Whonix-Workstation having no way of finding its own external IP address, joining Tor Browser's fingerprint for Whonix users, having no access for Whonix-Workstation to Tor's control port with Tor Buttons new requirement to have access to Tor's control port contradicted itself.

onion-grater has been implemented as a solution. It gives Whonix-Workstation access to a limited selection of Tor's control port commands, using whitelisting (not blacklisting). For example, it allows SIGNAL NEWNYM to make Tor Buttons New Identity feature available for users who use Tor Browser in Whonix-Workstation.

onion-grater limits maximum accepted command string length to 128 (configurable) (credits: [2] [3]) for better security.

Advanced users who do not wish to use onion-grater can disable it, see deactivate onion-grater.

Directory of choice[edit]

  • Using /usr/local/etc/onion-grater-merger.d/ because that onion-grater settings folder is persistent in Qubes-Whonix TemplateBased ProxyVMs i.e. Whonix-Gateway (commonly called sys-whonix).
  • Non-Qubes-Whonix users could also utilize /etc/onion-grater-merger.d/.
  • Qubes-Whonix users could also utilize /etc/onion-grater-merger.d/ but then /etc/onion-grater-merger.d/ must be made persistent, which means doing this procedure inside the Whonix-Gateway Template (commonly called whonix-gateway-17) and then restarting the Whonix-Gateway ProxyVM or using bind-dirsarchive.org.

Both techniques are more complicated than simply using /usr/local/etc/onion-grater-merger.d/, since it is persistent either way. Further, it even allows multiple Whonix-Gateway ProxyVMs based on the same Whonix-Gateway Template; for example, one Whonix-Gateway ProxyVM extending and relaxing onion-grater's whitelist and the other Whonix-Gateway ProxyVM having the default onion-grater whitelist which is more restrictive.

Onion-grater will only evaluate *.yml files.

Whonix connection[edit]


onion-grater listens on Whonix internal network interface [4], port 9051, filters (whitelist) incoming control port messages and forwards them to the real Tor Control Port listening on ControlSocket /run/tor/control. onion-grater itself uses cookies authentication to authenticate Tor's control port. The latter is not important, since Whonix-Gateway only purpose is running Tor, its not a multi user operating system, and if it were compromised, cookie authentication wouldn't be of help anymore either.


Whonix sets appropriate environment variables for the controller via unix domain socket TOR_CONTROL_IPC_PATH=/run/anon-ws-disable-stacked-tor/, which is the socket Tor Browser uses.

This functionality is implemented by the anon-ws-disable-stacked-torarchive.org package. See also Dev/anon-ws-disable-stacked-tor.

Attack Scenarios[edit]

Once Whonix-Workstation has been compromised, the adversary could continuously and/or using a pattern, send whitelisted commands to Tor. At the moment, only NEWNYM would be of interest. When the adversary is also an ISP level adversary, the adversary might be able to see the pattern being produced.

However thinking that an attacker requires access to Tor's Controller to try to deanonymize you is wrong, there are numerous attacks that are possible without needing to extract information and manipulate tor configuration. The attacker can simply download code from any website including his own and begin to run his code. He could also make very unique patterns on the network and through traffic analysis to learn more about the paths the tor client is using.

More worrying is the extended attack surface that allowing commands to be sent from a compromised Whonix-Workstation to a Whonix-Gateway, such as an unsafe parsing of commands, daemon C code memory leaks etc.

Information from this kinda of attacks were asked upstream but had no manifestation of interestarchive.org (web archivearchive.org).

Imitating real Tor Control Connection[edit]

Should Tor close the connection, onion-grater will also close client connection. (Same for a real Tor control connection.)

Both real Tor control connection and onion-grater close the connection if commands are sent when the client is not yet authenticated. (With the exception of authenticate, authchallenge and protocolinfo so there is parity.)

Should Tor authentication fail, this is logged and onion-grater closes client connection.

Talking to the real Tor Controller[edit]

If instead of connecting to onion-grater, you want to talk directly with the Tor Controller, it should be done on the Whonix-Gateway and using the host, see Talking to the real Tor Controller for more information.

How to do onion-grater profiles[edit]

As an exercise, try building a profile for an application already supported by Whonix, if you have trouble, you can always learn from the examples available at /usr/share/doc/onion-grater-merger/examples in your Whonix-Gateway.

For third-party projects with Tor friendly applications[edit]

Please document the controller commands, give hints to the scripts that send Tor commands, this can greatly increase the chance of your application being included to Whonix and used by real users.

Make your application handle unexpected replies such as 510 Command filtered without crashing, onion-grater is a whitelist filter, not a blacklist, this means that there is a great change the necessary commands your application requires may be filtered if not whitelisted. If your program crashes, that would lead to bad usability.

Profile format[edit]

There is no need to explain every directive in details as it is better to read the code commentsarchive.org for more up to date information. The following sections only mentions about differences in directive usage on Whonix in comparison with Tails OS.

A filter is matched if for each of the relevant qualifiers at least one of the elements match the client, the qualifiers being apparmor-profiles, users and hosts. It is very common for multiple qualifiers to match on Whonix, as apparmor-profiles and users can't be set and setting hosts requires user intervention.

How onion-grater parses files[edit]

Parsing stops at the first match, this means that it is not possible to override files by user a name with higher precedence such as 50_user.yml over 30_whonix-default.yml, what onion-grater does is sort the files in reverse lexical order, so if 50_user.yml matches, it will stop there, else continue to 30_whonix-default.yml.


We are not using the name directive because it is optional and the script names are already making the names unique.


For local (loopback) clients.

We can't use the apparmor-profiles directive because as per Whonix design, the user programs are run on the Whonix-Workstation and the controller is on the Whonix-Gateway.

Because of this, we default to:

    - '*'


For local (loopback) clients.

We can't use the users directive because as per Whonix design, the user programs are run on the Whonix-Workstation and the controller is on the Whonix-Gateway.

Because of this, we default to:

    - '*'


For remote (non-local) clients.

We can use the hosts directive, but the Whonix-Gateway doesn't know which of your Multiple Whonix-Workstation requires the whitelist.

Because of this, we default to:

    - '*'

You can optionally change that directive to allow only the IP of your chosen Whonix-Workstation, therefore you can choose per host the rules you want to be whitelisted.

Application Support[edit]

Some applications that uses the commands and events whitelisted by default don't need to worry about setting profiles. Some applications might already have profiles for other applications that already cover their usage.

Tor Browser[edit]


Bitcoin Core[edit]





  • Page: systemcheckarchive.org
  • Profile: asks onion-grater status/bootstrap-phase [5] as well as status/circuit-established [6] in Tor Bootstrap Status Check [7] (usability feature).


To get a list of Tor ControlPort commands, that TorLauncher uses, get into TorLauncher source code, extract TorLauncher, then run.

grep -r -i getconf


TorButton commands[edit]

To get a list of Tor ControlPort commands, that TorButton uses, get into TorButton source code, extract TorButton, then run.

grep -r -i torbutton_send_ctrl_cmd *

grep -r -i sendCommand *

TorButton Network Settings[edit]

TorButton &rarr; Open Network Settings...

Is using.

"GETCONF Socks4Proxy" "GETCONF Socks5Proxy" "GETCONF HTTPSProxy" "GETCONF ReachableAddresses" "GETCONF ReachableAddresses" "GETCONF UseBridges" "GETCONF Bridge"

As the next logical step by the way, they are likely going to add.


We are settingarchive.org environment variable export TOR_NO_DISPLAY_NETWORK_SETTINGS=1archive.org to disable the "TorButton" → "Open Network Settings..." menu item. It is not useful and confusing to have on a workstation, because Tor must be configured on the gateway, which is for security reasons forbidden from the workstation.

TorButton issues[edit]

Looking for contributor!

Clock skew[edit]

In the future, Tor Button will likely also use something like GETINFO clockskewarchive.org. Tor Browser developer rejectedarchive.org the idea of not adding the statement require no access to Tor's control port to Tor Browser's design.

Therefore when onion-grater gets asked GETINFO net/listeners/socks, it lies, and answers 250-net/listeners/socks="". This makes Tor Button happy and therefore it shows a "Congratulations!" (success) welcome page on its default homepage about:tor and not the failure page, which would confuse users. Since bug TorButton about:tor fails when using additional socks listenersarchive.org has been fixed by Tor Tor Project, that lie wouldn't be necessary anymore. We're keeping it, because it is not necessary for Tor Button get a full list of all ports Tor is listening on. If an attacker compromised Whonix-Workstation, hiding that list has an advantage. The attacker can probe what ports are available to that Whonix-Workstation, but if the user added extra ports not available to the compromised Whonix-Workstation (only available to another Whonix-Workstation listening on another IP), at least those remain secret. (This is a bit theoretical, because a compromised Whonix-Workstation can spoof its LAN IP and most likely very few users are using ARP spoofing defenses. Should we add ARP spoofing defenses by default at some point, we at least don't have to worry about this point.)

For further eventual Tor control port access requirements by Tor Button, the configuration file of accepted commands has to be extended. If Tor Button would ever ask for anything which violates Whonix design (Whonix-Workstation has no way of finding out its own external IP address in particular), such as GETINFO address, for example if Tor Button wanted to ensure, that the user is not using its own external IP address, a new lie would have to be added to the onion-grater script. In case many more lies are required, lies should go into the config file as well, for now, hard coding is sufficient.

Circuit View[edit]

TODO: Make Tor Circuit View screenshot with redacted IPs, fingerprints, locations work with Tor Browser in Whonix through filtered Tor control port access (onion-grater). Purpose: do not confuse Tor Browser to fix onion authentication through Tor Browser.

Regular Expression RegEx

Required for onion-grater.

rewrite source




rewrite source




rewrite source

    81 BUILT $89FD4FB2A5FD73B50F2E5D85C4707883F8CD5130~VisitFrance,$9EB3FD84065E5622A57EFEF14E41A01B5B99A022~whatconfig,$E7EF73B4722CFAF0E8AA2151D3AA78701DE5F19B~Silverwing,$9B1BE5D20FB9069523EF4889027325CE89B42460~scha1k BUILD_FLAGS=IS_INTERNAL,NEED_CAPACITY,NEED_UPTIME PURPOSE=HS_CLIENT_REND HS_STATE=HSCR_JOINED REND_QUERY=crypty22ijtotell TIME_CREATED=2020-06-05T18:00:41.170815


    81 BUILT $redacted~redacted,$redacted~redacted,$redacted~redacted,$redacted~redacted BUILD_FLAGS=NEED_CAPACITY PURPOSE=HS_CLIENT_REND HS_STATE=HSCR_JOINED REND_QUERY=redacted TIME_CREATED=2020-00-00T00:00:00.000000

rewrite source

r dragonhoard JKF6TB+owhCKzeO+aBsHMThL86U hrPrav+cqzyxUd0uNuXEA1U56xk 2020-06-05 09:21:43 8080 8008
a [2a01:4f8:1c1c:2e49::1]:8080
s Fast Guard Running Stable V2Dir Valid
w Bandwidth=13000
250 OK


r redacted redacted redacted 2020-00-00 00:00:00 8080 8008
a [0000:0000:0000:0000::1]:8080
s Fast Guard Running Stable V2Dir Valid
w Bandwidth=00
250 OK

Syntax example

        - pattern:     '650 HS_DESC CREATED (\S+) (\S+) (\S+) \S+ (.+)'
          replacement: '650 HS_DESC CREATED {} {} {} redacted {}'
  • Curent state:

For the Tor Circuit View to appear, it requires valid credentials replied from the SENTCONNECT eventarchive.org and if they are not the same credentials the Tor Browser sent by that tab, the circuits will not be shownarchive.org. Tor Browser wants to get the same SOCKS_USERNAME and SOCKS_PASSWORD it send for that tab in the first place, if it doesn,t the whole tab is not shown, you can check the reply with the Browser Console (Ctrl+Shift+J): Torbutton NOTE: no SOCKS credentials found for current document.

The interest is not showing the circuits per se, but at least showing literally Hop1, Hop2 and Hop2 to not confuse users why the tab is not shown. Another side effect is that it also hides the button New circuit for this site, but still available in the supermenu, but less convenient and not expected by the user to be this way.

If someone with JavaScript knowledge could patch upstream, at least showing the New circuit for this site even if the credentials don't match would be a start, but it currently is not shown because either the Tor Button shows completely or doesn't show at all. A more difficult task would be to instead of not showing the circuit view, if the browser fails to get the correct credentials, it could show a helpful text that it can't show the circuits because it could not determine the stream. There is a lower chance of rewriting the countries and IPs of the circuits to fake data if it can't establish the link because upstream could consider this a workaround. Anyway, a better user experience is expected from the Tor Circuit View, even if an error message, so at least it is understood by non-developers or for people not familiarized with the Tor Button and Tor Browser source code.

Trials with onion-grater:

- hosts:
    - '*'
      - 'STREAM'
      - 'NEWNYM'
      - pattern: 'bridge'
        - pattern: '250 Bridge.*'
          replacement: '250 Bridge'
      - 'status/circuit-established'
      - 'version'
      - 'consensus/valid-after'
      - 'consensus/valid-until'
      - 'consensus/fresh-until'
      - pattern: 'net/listeners/socks'
        - pattern:     '250-net/listeners/socks=".*"'
          replacement: '250-net/listeners/socks=""'
      - pattern: 'circuit-status'
        - pattern: '.*,.*'
          replacement: '10 BUILT $1~a,$2~b,$3~c BUILD_FLAGS=NEED_CAPACITY PURPOSE=redacted REND_QUERY=redacted TIME_CREATED=2020-00-00T00:00:00.000000'
      - pattern: 'ns/id/1'
        - pattern:     '551 .*'
          replacement: "250+ns/id/1=

r redacted redacted redacted 2020-00-00 00:00:00 8080 8008


s Fast Guard Running Stable V2Dir Valid

w Bandwidth=00

      - pattern: 'ns/id/2'
        - pattern:     '551 .*'
          replacement: "250+ns/id/2=

r redacted redacted redacted 2020-00-00 00:00:00 8080 8008


s Fast Guard Running Stable V2Dir Valid

w Bandwidth=00

      - pattern: 'ns/id/3'
        - pattern:     '551 .*'
          replacement: "250+ns/id/3=

r redacted redacted redacted 2020-00-00 00:00:00 8080 8008


s Fast Guard Running Stable V2Dir Valid

w Bandwidth=00

      - pattern: 'ip-to-country/'
        - pattern: '250-ip-to-country/.*'
          replacement: '250-ip-to-country/'
      - pattern: 'ip-to-country/'
        - pattern: '250-ip-to-country/.*'
          replacement: '250-ip-to-country/'
      - pattern: 'ip-to-country/'
        - pattern: '250-ip-to-country/.*'
          replacement: '250-ip-to-country/'
        - pattern: '650 STREAM (\S+) SENTCONNECT .*'
        - pattern: '650 STREAM .*'
      suppress: true
      suppress: true
      suppress: true
    restrict-stream-events: true

Onion-grater logs:

(filter: /usr/local/etc/onion-grater-merger.d/50_user): rewrote received event:
(filter: /usr/local/etc/onion-grater-merger.d/50_user): -> getconf bridge
(filter: /usr/local/etc/onion-grater-merger.d/50_user): <- 250 Bridge
(filter: /usr/local/etc/onion-grater-merger.d/50_user): -> getconf bridge
(filter: /usr/local/etc/onion-grater-merger.d/50_user): <- 250 Bridge
(filter: /usr/local/etc/onion-grater-merger.d/50_user): -> getconf bridge
(filter: /usr/local/etc/onion-grater-merger.d/50_user): <- 250 Bridge
(filter: /usr/local/etc/onion-grater-merger.d/50_user): -> getinfo ns/id/1
(filter: /usr/local/etc/onion-grater-merger.d/50_user): rewrote response:
    551 Data not decodeable as hex
    r redacted redacted redacted 2020-00-00 00:00:00 8080 8008
    s Fast Guard Running Stable V2Dir Valid
    w Bandwidth=00
    . (filter: /usr/local/etc/onion-grater-merger.d/50_user): <- (multi-line)
    r redacted redacted redacted 2020-00-00 00:00:00 8080 8008
    s Fast Guard Running Stable V2Dir Valid
    w Bandwidth=00

After the first query of the relay info, it doesn't query the other nodes for unknown reasons. Note that the command getinfo ip-to-country was never issued, unknown reason. After that, only redacted streams were replied.

Folder with other examples already using this type of regex:


Direct links to profiles using similar regex:

Functionality support[edit]

Indicator for current Circuit Status and Exit IP[edit]

- apparmor-profiles:
    - '*'
    - '*'
    - '*'
      - 'NEWNYM'
      - pattern: 'circuit-status'
        - pattern: '250(.+)circuit-status=(\S+) (\S+) (.+) (\S+) (\S+)'
        - replacement: '250+circuit-status='
      - pattern: 'bridge'
        - pattern:     '250-Bridge=(.+) (\S+) (\S+) (\S+) (\S+)'
          replacement: '250-Bridge='
        - pattern:     '250 Bridge=(.+) (\S+) (\S+) (\S+) (\S+)'
          replacement: '250 Bridge='
  restrict-stream-events: true


Example command for Tor control protocol: onion_client_auth_add m5bmcnsk64naezc26scz2xb3l3n2nd5xobsljljrpvf77tclmykn7wid x25519:uBKh6DGrkcFxB1adYuyKQltUDDUT9IZrOsne3nfHbHI=

Test key that can be entered into browser. XAJKD2BRVOI4C4IHK2OWF3EKIJNVIDBVCP2IM2Z2ZHPN456HNRZA

UI for ExitNode country selection in tor-launcher[edit]


Feedback mechanism for clock-skew and other bad problems[edit]


Debugging Inspiration[edit]

onion-grater debug mode[edit]

On Whonix-Gateway.

Open file /lib/systemd/system/onion-grater.service.d/50_user.conf in an editor with root rights.


This box uses sudoedit for better security.


NOTE: When using Qubes-Whonix, this needs to be done inside the Template.

Others and Alternatives

  • This is just an example. Other tools could achieve the same goal.
  • If this example does not work for you or if you are not using Whonix, please refer to this link.

sudoedit /lib/systemd/system/onion-grater.service.d/50_user.conf


[Service] ## Clear onion-grater default file '/lib/systemd/system/onion-grater.service'. ExecStart= ## Same as above but enable debug mode. ExecStart=/usr/lib/onion-grater --listen-interface eth1 --listen-port 9051 --debug ## Same as above but enable complain mode which permits everything (insecure in production). #ExecStart=/usr/lib/onion-grater --listen-interface eth1 --listen-port 9051 --complain


Reload systemd daemon:

sudo systemctl daemon-reload

Restart onion-grater service:

sudo systemctl restart onion-grater

Done, debug mode is now enabled.

Watch onion-grater's logs while using it in a separate terminal tab: sudo journalctl -f -u onion-grater

onion-grater passthrough mode[edit]

This disables filtering (allows all commands) and should be used during development only. Because this mode allows everything, we will not be running as a service, but as a command on the terminal, this means that if the program receives and interrupt signal of the machine reboots, it will enable the standard onion-grater service.

On Whonix-Gateway.

sudo systemctl stop onion-grater

sudo /usr/lib/onion-grater-merger

sudo -u onion-grater /usr/lib/onion-grater --listen-interface eth1 --listen-port 9051 --complain

On Whonix-Workstation.

tor-ctrl GETINFO status/bootstrap-phase

Press Enter.

AppArmor issues[edit]

Watch kern.log for eventual iptables log messages, run this on Whonix-Gateway.

sudo apparmor-info

Connect to onion-grater from Whonix-Gateway[edit]

To connect to onion-grater from a Non-Qubes-Whonix-Gateway: tor-ctrl -s GETINFO config-file

To connect to onion-grater from a Qubes-Whonix-Gateway: tor-ctrl -s $(qubesdb-read /qubes-ip):9051 GETINFO config-file

Connect to onion-grater from Whonix-Workstation[edit]

On the Whonix-Workstation you should be able to run without setting the interface:

tor-ctrl GETINFO address

Type GETINFO address. Enter. Should reply 510 Command filtered.

tcpdump - Less Important[edit]

Only in case of suspected fundamental issues with low level networking.

To see what's being send to onion-grater's port, run this on Whonix-Gateway.


sudo tcpdump -i eth1 -l -s0 -w - tcp dst port 9051

Qubes-Whonix-Gateway: (Note: replace vif18.0 with the device found with the command ip route.)

sudo tcpdump -i vif18.0 -l -s0 -w - tcp dst port 9051

Comparison of Control Port Filters[edit]

onion-grater by Tails[edit]

onion-graterarchive.org by Tails (config folderarchive.org)

  • Written in python3.
  • All dependencies already inside Debian.
  • Wildcard / regex support.
  • Supports rewriting client requests.
  • Supports rewriting Tor replies.
  • Parallel connections support.
  • Can reply to getinfo net/listeners/socks with the lie '250-net/listeners/socks=""'.
  • Logs to journal.
  • Honors signals sigterm, sigint.
  • Supports subscribing Tor ControlPort events (setevent).

onion-grater by Tails forked by Whonix[edit]

onion-graterarchive.org (config folderarchive.org) (additional onion-grater-merger example profilesarchive.org) (issue trackerarchive.org)

  • mostly same as #onion-grater by Tails
  • different config parsing mechanism
  • Debian packaging
  • systemd unit file
  • systemd-notify support - https://mailman.boum.org/pipermail/tails-dev/2017-March/011327.html submitted patch upstream
  • systemd seccomp hardening [9]
  • AppArmor profile

roflcoptor by subgraph os[edit]

roflcoptorarchive.org by subgraph os

  • Many golang dependencies that are not packaged for Debian.
  • Event support.
  • Wildcard support.
  • TODO: expand

surrogate.go by Yawning Angel[edit]

surrogate.go (tor project gitweb)archive.org by Yawning Angel

  • golang (build dep, not run dep)
  • AGPL (Achtung!)
  • Part of new/upcoming Sandboxed Tor Browserarchive.org
  • "Tor control/socks port surrogates." (quoting top comment) Intended to proxy/filter both ControlPort and SOCKSPort of tor process in one bubblewrapped sandbox, while actual Tor Browser runs in another bubblewrapped sandbox.
  • Observed version: 6ff4802archive.org
  • So, official TPO Tor Browser variant also has this problem. Oops!

legacy control-port-filter-python by Whonix[edit]

legacy [https://github.com/{{project_name_short}}/control-port-filter-python control-port-filter-python] ([https://github.com/{{project_name_short}}/control-port-filter-python/blob/master/usr/sbin/cpfpd main script]) [{{project_name_short}} 10 to {{project_name_short}} 13 ([https://github.com/{{project_name_short}}/control-port-filter-python/releases/tag/1.7-1 version 1.7-1]] (last git commit [https://github.com/{{project_name_short}}/control-port-filter-python/commit/99e8395fbafcb7789c7d1b5cbf7410ed65192e9a up to 99e8395fbafcb7789c7d1b5cbf7410ed65192e9a]) ([https://phabricator.whonix.org/tag/control-port-filter-python/ issue tracker]) [deprecated]

  • A fork of (very early) [https://gitlab.tails.boum.org/tails/tails/-/blob/master/config/chroot_local-includes/usr/local/sbin/tor-controlport-filter tor-controlport-filter] by Tails. (See above.)
  • Written in python2.7.
  • Configurable by dropping .d-style[10] configuration snippets into /etc/cpfpy.d.
  • Support to answer getinfo net/listeners/socks with the lie '250-net/listeners/socks=""'.
  • Supports logging.
  • Honors signals sigterm, sigint, keyboard interrupt.
  • Supports parallel connections.
  • Supports wildcards, which is for tools such as onionshare that are using add_onion *.
  • Injects workstation IP into add_onion. For example will transform from / to:
    • add_onion new:best port=80,17600
    • add_onion new:best port=80,
  • Support subscribing Tor ControlPort events (setevent). (Whonix 14 and above.) [11]
  • Complete systemd unit file.
  • Lintian clean /debian packaging folder.
  • Will be deprecated when Whonix 14 get released.

legacy2 control-port-filter by Whonix[edit]

legacy^2 control-port-filter [up to Whonix 9.x] [deprecated]

  • Supports parallel connections.
  • Written in bash. (githubarchive.org) (archive only)
  • White lists multiple useful Tor ControlPort commandsarchive.org.
  • Configurable using /etc/controlportfilt.d drop-in files.
  • Support to answer getinfo net/listeners/socks with the lie '250-net/listeners/socks=""'.
  • Supports logging.
  • Honors signals sigterm, sigint.
  • Does not support wildcards.
  • Does not support subscribing Tor ControlPort events (setevent).
  • Complete sysvinit script.
  • Lintian clean /debian packaging folder.
  • Deprecated since the release of Whonix 10.

Old method to manage profiles[edit]

Previously manual instructions. No longer needed. onion-grater-add automates that.

Add profile[edit]

1. Create folder /usr/local/etc/onion-grater-merger.d.

sudo mkdir -p /usr/local/etc/onion-grater-merger.d

2. Symlink the onion-grater profile to the onion-grater settings folder.

sudo ln -s 40_onion_authentication.yml /usr/local/etc/onion-grater-merger.d/

3. Restart onion-grater. sudo service onion-grater restart

Remove profile[edit]

1. Remove symlink from the onion-grater profile

sudo unlink /usr/local/etc/onion-grater-merger.d/40_onion_authentication.yml

2. Restart onion-grater. sudo service onion-grater restart

Whonix Forum Discussion[edit]

Source Code[edit]

Original upstream by Tails:

Fork by Whonix:

Whonix supplementary:

See Also[edit]


  1. https://github.com/Whonix/anon-ws-disable-stacked-tor/blob/master/usr/libexec/anon-ws-disable-stacked-tor/torbrowser.sharchive.org
  2. As done by Tails.archive.org
  3. Thanks to HulaHoop for [https://www.whonix.org/old-forum/index.php/topic,342.0.html suggesting this].
  4. https://github.com/Whonix/whonix-gw-network-conf/blob/master/usr/lib/systemd/system/onion-grater.service.d/30_cpfpy.confarchive.org
  5. Find out what status/bootstrap-phase answers yourself in Whonix-Gateway. /usr/lib/helper-scripts/tor_bootstrap_check.py 9051 1 Example answer. NOTICE BOOTSTRAP PROGRESS=100 TAG=done SUMMARY="Done"
  6. Find out what status/circuit-established answers yourself in Whonix-Gateway. /usr/lib/helper-scripts/tor_circuit_established_check.py 9051 1 Example answer. 1
  7. https://github.com/Kicksecure/systemcheck/blob/master/usr/libexec/systemcheck/check_tor_bootstrap.bsharchive.org whonixcheck --function check_tor_bootstrap whonixcheck --function check_tor_bootstrap --verbose --debug
  8. https://git-tails.immerda.ch/onion-grater/commit/?id=33ae20850329930bd1a3686cca2a9ac4dc766aea +* EVENTS: Tor Browser is subscribed to all STREAM events for its + implementation of the circuit view. This means it will know + basically everything Tor is doing which is pretty bad in case Tor + Browser is compromised.
  9. https://phabricator.whonix.org/T631archive.org
  10. Kicksecure logo Style Configuration Folders The Web Archive Onion Version
  11. https://phabricator.whonix.org/T448archive.org

We believe security software like Whonix needs to remain open source and independent. Would you help sustain and grow the project? Learn more about our 12 year success story and maybe DONATE!