Change default preferences for Tor Browser in DispVM using policies.json

I wanted to change the default search engine for Tor Browser in disposable VMs but it’s not possible to do this using user.json file in /usr/local/etc/torbrowser.d/user.js. But it’s possible to do this using policies.json file.
In Whonix-Workstation disposable template (whonix-ws-xx-dvm) add these lines to the /rw/config/rc.local file:

mkdir /var/cache/tb-binary/.tb/tor-browser/Browser/distribution
cat > /var/cache/tb-binary/.tb/tor-browser/Browser/distribution/policies.json <<EOF
{
  "policies": {
    "SearchEngines": {
      "Default": "DuckDuckGoOnion"
    }
  }
}
EOF
chown -R user:user /var/cache/tb-binary/.tb/tor-browser/Browser/distribution

And shutdown the disposable template.
After this all the disp VMs based on this disposable template will use these policies.
It’s also possible to set the security slider using policiy file but it’ll only work if it’s locked and you won’t be able to change the security slider in Tor Browser.

{
  "policies": {
    "SearchEngines": {
      "Default": "DuckDuckGoOnion"
    },
    "Preferences": {
      "browser.security_level.security_slider": {
        "Value": 1,
        "Status": "locked"
      }
    }
  }
}
2 Likes

Nice!

Or alternatively create

/var/cache/tb-binary/.tb/tor-browser/Browser/distribution/policies.json

in Template. But that won’t survive when tb-updater updates Tor Browser after being in in Template.

tb-starter /usr/bin/torbrowser(by Whonix developers) at time of writing doesn’t have a hook system to automate such user custom patches.

  • A) The policies file placement is one thing. Versus:

  • B) The actual content of the policies file is a different topic.

Quote Tor browser: set security slider to safest, javascript.enabled to false by default in a TemplateVM - #2 by Patrick

Tor Browser doesn’t have an API / documented setting for that. That feature request was rejected by its upstream (original) developers.

This is unspecific to Whonix:

This is best investigated as per:

The name, functionality of of the settings, is completely up to upstream. Upstream’s here are The Tor Project that developers Tor Browser and by extension Mozilla that developed Firefox, which Tor Browser is based on.

Therefore the advanced topic of the settings in a Tor Browser / Firefox policies file, it’s best to redirect it to upstream(s).