Skip to content

Allow mounting USBs to sd-admin-usb - #1966

Open
legoktm wants to merge 2 commits into
mainfrom
admin-usb
Open

legoktm wants to merge 2 commits into
mainfrom
admin-usb

Conversation

@legoktm

@legoktm legoktm commented Nov 2, 2026

Copy link
Copy Markdown
Member

This needs freedomofpress/securedrop#7972 to be merged first.

For the purpose of creating Export Devices.

The primary purpose of this PR is to add the necessary RPC rule, however most of the code is adapting the existing USB attachment tests to support verifying sd-admin can also mount USBs.

Fixes #1942

Test plan

  • OpenQA passes.

Checklist

This change accounts for:

  • any necessary RPM packaging updates (e.g., added/removed files, see rpm-build/SPECS/securedrop-workstation-dom0-config.spec)
  • any required documentation

@legoktm
legoktm added this pull request to stack #1944 November 2, 2026 21:53
@legoktm legoktm moved this to In Progress in SecureDrop Nov 2, 2026
@legoktm legoktm added the 4.3-openqa-admin Run on OpenQA in Qubes 4.3 deploying the journalist workstation label Nov 2, 2026
@legoktm

legoktm commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

OpenQA should fail because the corresponding securedrop-admin PR hasn't been merged yet...

@ChumOfChance ChumOfChance moved this from In Progress to Ready For Review in SecureDrop Nov 3, 2026
Base automatically changed from tests-needs-dom0 to main November 10, 2026 15:29
@nathandyer nathandyer moved this from Ready For Review to In Progress in SecureDrop Nov 10, 2026
@legoktm legoktm removed the 4.3-openqa-admin Run on OpenQA in Qubes 4.3 deploying the journalist workstation label Nov 10, 2026
@legoktm legoktm added the 4.3-openqa-admin Run on OpenQA in Qubes 4.3 deploying the journalist workstation label Nov 10, 2026
Comment thread admin_salt/sd-admin-usb.sls Resolved
@legoktm legoktm changed the title Allow mounting USBs to sd-admin Allow mounting USBs to sd-admin-usb Nov 12, 2026
@legoktm legoktm moved this from In Progress to Ready For Review in SecureDrop Nov 12, 2026
@legoktm
legoktm marked this pull request as ready for review November 12, 2026 17:01
@legoktm
legoktm requested a review from a team as a code owner November 12, 2026 17:01
@nathandyer nathandyer assigned vickiniu and unassigned deeplow Nov 12, 2026
@nathandyer
nathandyer requested a review from vickiniu November 12, 2026 17:05
@deeplow

deeplow commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

@vickiniu I ended up finding the time to take a look at this today. So I'll grab it, if you don't mind.

@vickiniu

Copy link
Copy Markdown
Contributor

sounds great, thanks @deeplow !

@deeplow deeplow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I appreciate the generalization already done of the USB testing. I've suggested a few changes.

Comment thread admin_salt/sd-admin-usb.sls Resolved
Comment thread files/31-securedrop-admin.policy Outdated
Comment on lines +12 to +14
# sd-admin-usb: USB devices attached manually from dom0 (e.g. via the devices
# widget). Unlike sd-devices, sys-usb doesn't auto-attach (qubes.USBAttach).
qubes.USB * sd-admin-usb sys-usb allow

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
# sd-admin-usb: USB devices attached manually from dom0 (e.g. via the devices
# widget). Unlike sd-devices, sys-usb doesn't auto-attach (qubes.USBAttach).
qubes.USB * sd-admin-usb sys-usb allow

When the user attaches via dom0, this permission is already temporarily allowed, for the specified device. So, we shouldn't have this here.

More details in the usb-proxy's README.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

TIL. Will remove.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This actually had a side-effect. OpenQA failed here. It seems that our general deny rule is interfering with this.

The "temporary allowing" done by Qubes USB proxy is implemented with the legacy policy rules, where it should actually just be calling something like what qubes-video-companion does. I filed an issue: QubesOS/qubes-issues#11282.

Our immediate options to work around this:

  1. remove the qubes.USB deny rule and leave it up for defaults
  2. explicitly allow (reverting my suggestion)

I think option 1. is preferable since:

  • when doing attaching via GUI or qvm-attach the USB proxy ends up creating a rule per device instead of an overly-generic rule
  • we've also ran into problems in the past with these hard-coded USB rules for qubes.USBAttach

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I would kind of prefer to to do 2 since that was working before

IIUC, once QubesOS/qubes-issues#11282 is resolved, then we can keep the deny rule and let it correctly create the allow rule?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Per discussion w/ deeplow I'm going to go with option 1 for now.

Comment thread tests/test_rpc_policy.py Resolved
Comment thread tests/test_rpc_policy.py Resolved
Comment thread tests/test_vm_sd_admin_usb.py Resolved
Comment thread tests/test_vm_sd_admin_usb.py Resolved
Comment thread tests/test_vm_sd_admin_usb.py Resolved
@legoktm
legoktm force-pushed the admin-usb branch 2 times, most recently from 2c2b621 to 2bc4459 Compare November 13, 2026 19:04
This VM will be used for whenever the admin needs to mount USBs,
e.g. formatting drives, or importing/exporting config.

Abstract the USB mounting tests in sd-devices to be reusable for
this VM without relying on the auto-attach logic.

Fixes #1942
@legoktm legoktm moved this from Ready For Review to Under Review in SecureDrop Nov 13, 2026
Comment on lines +28 to +30
@pytest.fixture(scope="module")
def qube_sd_admin_usb() -> QubeWrapper:
return QubeWrapper("sd-admin-usb")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

OpenQA failed due to a missing qube fixture:

file /home/user/securedrop-workstation/tests/base.py, line 302
      def test_vm_config_keys(self, qube: QubeWrapper) -> None:
E       fixture 'qube' not found

The reason that's needed is because common tests in base.py, need to know what was the qube under testing. So in order to avoid needing test classes and subclassing, we need this qube fixture.

Two suggestions:

Suggested change
@pytest.fixture(scope="module")
def qube_sd_admin_usb() -> QubeWrapper:
return QubeWrapper("sd-admin-usb")
@pytest.fixture(scope="module")
def qube() -> QubeWrapper:
return QubeWrapper("sd-admin-usb")

or

Suggested change
@pytest.fixture(scope="module")
def qube_sd_admin_usb() -> QubeWrapper:
return QubeWrapper("sd-admin-usb")
@pytest.fixture(scope="module")
def qube_sd_admin_usb() -> QubeWrapper:
return QubeWrapper("sd-admin-usb")
@pytest.fixture(scope="module")
def qube(qube_sd_admin_usb: QubeWrapper) -> QubeWrapper:
return qube_sd_admin_usb

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I do admit it's a bit non-intuitive. Maybe renaming it everywhere tested_qube helps? 🤔 #1983

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll rename it to qube for now.

@deeplow

deeplow commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Thanks for addressing this thorough review! Tests are failing, one specifically because of my suggestion. Please see my review comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.3-openqa-admin Run on OpenQA in Qubes 4.3 deploying the journalist workstation

Projects

Status: Under Review

Development

Successfully merging this pull request may close these issues.

Create Export Devices on Admin Workstation

3 participants