Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove v2 onion service support; fix Whonix repo list filename #694

Merged
merged 1 commit into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ Clone this repo to your preferred location on that VM.

Next we need to do some SecureDrop-specific configuration:

- Create a `config.json` file based on `config.json.example` and include your values for the hidserv fields: `hostname` (the Journalist Interface Onion URL) and `key` (the fingerprint for the SecureDrop Submission key). To find the Journalist Interface Onion URL, you can run `sudo cat /var/lib/tor/services/journalist/hostname` on your server. The values for `hostname` and `key` in `config.json.example` are set to the default values for the SecureDrop staging instance.
- Create a `config.json` file based on `config.json.example` and include your values for the hidserv fields: `hostname` (the Journalist Interface Onion URL) and `key` (the private key for client authentication). Set `submission_key_fpr` to the submission key fingerprint.

- On your Admin Workstation, you can find the Journalist Interface onion address and private key in `~/Persistent/securedrop/install_files/ansible-base/app-journalist.auth_private`, and the submission key fingerprint in `~/Persistent/securedrop/install_files/ansible-base/group_vars/all/site-specific` (`securedrop_app_gpg_fingerprint`).

- Create an `sd-journalist.sec` file in the root directory with the ASCII-armored GPG private key used to encrypt submissions in your test SecureDrop instance. The included key `sd-journalist.sec` is the one used by default in the SecureDrop staging instance.

Expand Down
4 changes: 2 additions & 2 deletions config.json.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"submission_key_fpr": "65A1B5FF195B56353CC63DFFCC40EF1228271441",
"hidserv": {
"hostname": "avgfxawdn6c3coe3.onion",
"key": "Il8Xas7uf6rjtc0LxYwhrx"
"hostname": "sdolvtfhatvsysc6l34d65ymdwxcujausv7k5jk4cy5ttzhjoi6fzvyd.onion",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

securedrop.org website onion service

"key": "5U4JPYSZ34N2ZDSOUAL2YLEX2NPI5BLL2Y66QJW24KLSH7R3FEPQ"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

randomly generated key in base32

},
"environment": "prod",
"vmsizes": {
Expand Down
29 changes: 4 additions & 25 deletions scripts/validate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
TOR_V3_HOSTNAME_REGEX = r"^[a-z2-7]{56}\.onion$"
TOR_V3_AUTH_REGEX = r"^[A-Z2-7]{52}$"

TOR_V2_HOSTNAME_REGEX = r"^[a-z2-7]{16}\.onion$"
TOR_V2_AUTH_COOKIE_REGEX = r"^[a-zA-z0-9+/]{22}$"

# CONFIG_FILEPATH = "/srv/salt/sd/config.json"
CONFIG_FILEPATH = "config.json"
SECRET_KEY_FILEPATH = "sd-journalist.sec"
Expand Down Expand Up @@ -59,25 +56,17 @@ def confirm_environment_valid(self):

def confirm_onion_config_valid(self):
"""
We support both v2 and v3 onion services, so if the values
in the config file match either format, the configuration is considered
valid. A deprecation warning is shown if v2 services are in use.
Only v3 onion services are supported.
"""
v2_config = False
try:
self.confirm_onion_v3_url()
self.confirm_onion_v3_auth()
except AssertionError:
self.confirm_onion_v2_url()
self.confirm_onion_v2_auth()
v2_config = True

if v2_config:
print(
"WARNING: v2 onion service configuration found.\n"
"Support for v2 onion services will be removed from SecureDrop in February 2021.\n"
"Migration guide: https://securedrop.org/v2-onion-eol/"
"ERROR: Onion service configuration missing or does not match expected format.\n"
"Please note that only v3 onion services are supported.\n"
)
raise
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this script shouldn't display tracebacks during expected validation errors, but that's the current pattern. See #683 as well for suggested refactoring of this whole logic.


def confirm_onion_v3_url(self):
assert "hidserv" in self.config
Expand All @@ -89,16 +78,6 @@ def confirm_onion_v3_auth(self):
assert "key" in self.config["hidserv"]
assert re.match(TOR_V3_AUTH_REGEX, self.config["hidserv"]["key"])

def confirm_onion_v2_url(self):
assert "hidserv" in self.config
assert "hostname" in self.config["hidserv"]
assert re.match(TOR_V2_HOSTNAME_REGEX, self.config["hidserv"]["hostname"])

def confirm_onion_v2_auth(self):
assert "hidserv" in self.config
assert "key" in self.config["hidserv"]
assert re.match(TOR_V2_AUTH_COOKIE_REGEX, self.config["hidserv"]["key"])

def confirm_submission_privkey_file(self):
assert os.path.exists(self.secret_key_filepath)
gpg_cmd = ["gpg", self.secret_key_filepath]
Expand Down
2 changes: 2 additions & 0 deletions tests/test_proxy_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def test_whonix_ws_repo_absent(self):
Guard against regressions by ensuring the old Whonix apt list
is missing.
"""
# Whonix project changed the repo filename ~2021-05, so check both.
assert not self._fileExists("/etc/apt/sources.list.d/whonix.list")
assert not self._fileExists("/etc/apt/sources.list.d/derivative.list")

def test_logging_configured(self):
self.logging_configured()
Expand Down
15 changes: 1 addition & 14 deletions tests/test_sd_whonix.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,10 @@
from base import SD_VM_Local_Test


def v2_onion_services():
"""
Returns True if v3 address is not setup
"""
with open("config.json") as c:
config = json.load(c)
if len(config["hidserv"]["hostname"]) == 22:
return True
else:
return False


class SD_Whonix_Tests(SD_VM_Local_Test):
def setUp(self):
self.vm_name = "sd-whonix"
self.whonix_apt_list = "/etc/apt/sources.list.d/whonix.list"
self.whonix_apt_list = "/etc/apt/sources.list.d/derivative.list"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what fixes #693

super(SD_Whonix_Tests, self).setUp()

def test_accept_sd_xfer_extracted_file(self):
Expand All @@ -36,7 +24,6 @@ def test_accept_sd_xfer_extracted_file(self):

self.assertFileHasLine("/usr/local/etc/torrc.d/50_user.conf", line)

@unittest.skipIf(v2_onion_services(), "Onion v3 address is not setup")
def test_v3_auth_private_file(self):
with open("config.json") as c:
config = json.load(c)
Expand Down