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

new device API #32

Merged
merged 23 commits into from
Jun 21, 2024
Merged

new device API #32

merged 23 commits into from
Jun 21, 2024

Conversation

piotrbartman
Copy link
Member

@piotrbartman piotrbartman commented Feb 6, 2024

Comment on lines 225 to 280
untrusted_device_desc = untrusted_device_desc.decode(
'unicode_escape', errors='ignore')
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this really safe for untrusted input? I’d expect this is normally used for trusted input. I recommend reimplementing this in pure Python. Alternatively, is there a reason that this is needed at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

To be honest, I'm not sure, but what type of attack could be conducted here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Assuming this is implemented in C (which I suspect it is), the C code might be vulnerable to e.g. buffer overflows. I’m not saying it is vulnerable, but it is extra attack surface.

Also, unicode_escape is not a very efficient codec, and results in backslashes (which are special in various places) in strings. What about using base64 instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I convinced that decode is used in many places within Qubes itself and has never been considered non-tursted, so I do not see reason to change that.

Regarding unicode_escape, you're right, which is why you have the string sanitation right below it (lines 227-229), which filters out any malicious characters.

Copy link
Contributor

Choose a reason for hiding this comment

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

I convinced that decode is used in many places within Qubes itself and has never been considered non-tursted, so I do not see reason to change that.

decode calls into different C functions depending on what codec is used, so it is possible that it is safe with one codec (such as ascii) but not with another (such as unicode_escape). The code in CPython actually has undefined behavior (out-of-bounds pointer arithmetic) on strings such as \x due to an incorrect bounds check (s+1 < end instead of end - s > 1), but otherwise looks okay. Making sure the string does not end with \x should be enough to prevent the undefined behavior.

Copy link
Contributor

Choose a reason for hiding this comment

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

The concern is that malicious input might be able to attack the C implementation of unicode_escape before the character set filtering happens. Character set filtering will not protect against memory corruption that happens earlier.

Do you want me to provide a simple pure-Python reimplementation?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's a realistic concern.

Copy link
Member

Choose a reason for hiding this comment

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

But semantic-wise, what's the intended supported encoding? if just \xXX escaping, then maybe it really should support just this one?

Copy link
Contributor

Choose a reason for hiding this comment

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

That would be my preference indeed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I implemented a simple parser in pure Python

Comment on lines 178 to 231
result = {"vendor": unknown,
"product": unknown,
"manufacturer": unknown,
"name": unknown,
"serial": unknown}
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that this does not include the port the device is attached through. Qubes Manager will need this to display a GUI asking the user what device they plugged into a port.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is only data provided by the device itself (possibly fake/malicious), the port number is contained within 'ident' and is independent of the device itself (the device does not inform us which port it is connected to).

@qubesos-bot
Copy link

qubesos-bot commented Mar 29, 2024

OpenQA test summary

Complete test suite and dependencies: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2024062013-4.3&flavor=pull-requests

Test run included the following:

New failures, excluding unstable

Compared to: https://openqa.qubes-os.org/tests/overview?distri=qubesos&version=4.3&build=2024052808-4.3&flavor=update

  • system_tests_extra

    • TC_00_QVCTest_whonix-gateway-17: test_020_webcam (failure)
      AssertionError: 'qubes-video-companion webcam' exited early (0): b'...
  • system_tests_devices

    • TC_00_List_whonix-gateway-17: test_001_list_loop_mounted (failure)
      AssertionError: Device test-inst-vm:loop0 (/tmp/test.img) should no...

Failed tests

12 failures
  • system_tests_basic_vm_qrexec_gui

    • [unstable] TC_20_AudioVM_Pulse_whonix-workstation-17: test_220_audio_play_pulseaudio (failure)
      AssertionError: too short audio, expected 10s, got 9.31430839002267...

    • [unstable] TC_20_AudioVM_Pulse_whonix-workstation-17: test_222_audio_rec_unmuted_pulseaudio (failure)
      AssertionError: too short audio, expected 10s, got 9.28435374149659...

  • system_tests_pvgrub_salt_storage

    • TC_41_HVMGrub_fedora-40-xfce: test_000_standalone_vm (error)
      qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...

    • TC_41_HVMGrub_fedora-40-xfce: test_010_template_based_vm (error)
      qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...

  • system_tests_splitgpg

  • system_tests_extra

    • [unstable] TC_00_QVCTest_fedora-40-xfce: test_020_webcam (failure)
      AssertionError: 'qubes-video-companion webcam' exited early (0): b'...

    • TC_00_QVCTest_whonix-gateway-17: test_020_webcam (failure)
      AssertionError: 'qubes-video-companion webcam' exited early (0): b'...

  • system_tests_network_updates

    • [unstable] TC_11_QvmTemplateMgmtVM_debian-12-xfce: test_010_template_install (failure)
      AssertionError: libvirt event impl drain timeout
  • system_tests_devices

    • TC_00_List_whonix-gateway-17: test_001_list_loop_mounted (failure)
      AssertionError: Device test-inst-vm:loop0 (/tmp/test.img) should no...
  • system_tests_basic_vm_qrexec_gui_xfs

  • system_tests_suspend@hw1

    • [unstable] suspend: wait_serial (wait serial expected)
      # wait_serial expected: qr/0DNLB-\d+-/...

    • [unstable] suspend: Failed (test died + timed out)
      # Test died: command 'qvm-run -p sys-firewall "curl https://www.qub...

Fixed failures

Compared to: https://openqa.qubes-os.org/tests/101100#dependencies

37 fixed
  • system_tests_basic_vm_qrexec_gui

  • system_tests_pvgrub_salt_storage

    • StorageFile: test_001_non_volatile (error)
      subprocess.CalledProcessError: Command '/usr/lib/qubes/destroy-snap...
  • system_tests_extra

    • TC_00_QVCTest_debian-12-xfce: test_020_webcam (failure)
      AssertionError: 'qubes-video-companion webcam' exited early (0): b'...

    • TC_00_QVCTest_whonix-workstation-17: test_010_screenshare (failure)
      self.assertNotEqual(vm.run('test -e /dev/vid... AssertionError: 0 == 0

    • TC_00_QVCTest_whonix-workstation-17: test_020_webcam (failure + cleanup)
      AssertionError: 'qubes-video-companion webcam' exited early (0): b'...

  • system_tests_guivm_gui_interactive

    • update_guivm: Failed (test died)
      # Test died: command '(set -o pipefail; qubesctl --all --show-outpu...
  • system_tests_usbproxy

  • system_tests_network_updates

    • TC_00_Dom0Upgrade_whonix-gateway-17: test_006_update_flag_clear (failure)
      Error: Failed to download metadata for repo 'test': Cannot download...

    • TC_10_QvmTemplate_debian-12-xfce: test_010_template_install (failure)
      AssertionError: qvm-template failed: Downloading 'qubes-template-de...

    • TC_10_QvmTemplate_fedora-40-xfce: test_010_template_install (failure)
      AssertionError: qvm-template failed: Downloading 'qubes-template-de...

    • TC_10_QvmTemplate_whonix-gateway-17: test_010_template_install (failure)
      AssertionError: qvm-template failed: Downloading 'qubes-template-de...

    • TC_11_QvmTemplateMgmtVM_fedora-40-xfce: test_010_template_install (failure)
      AssertionError: qvm-template failed: Downloading 'qubes-template-de...

    • TC_11_QvmTemplateMgmtVM_whonix-gateway-17: test_010_template_install (failure)
      AssertionError: qvm-template failed: Downloading 'qubes-template-de...

  • system_tests_basic_vm_qrexec_gui_zfs

  • system_tests_basic_vm_qrexec_gui_btrfs

  • system_tests_basic_vm_qrexec_gui_ext4

  • system_tests_basic_vm_qrexec_gui_xfs

    • TC_20_AudioVM_Pulse_whonix-workstation-17-pool: test_220_audio_play_pulseaudio (failure)
      AssertionError: Command 'timeout 20s paplay --format=float32le --ra...

    • TC_20_AudioVM_Pulse_whonix-workstation-17-pool: test_222_audio_rec_unmuted_pulseaudio (failure)
      AssertionError: only silence detected, no useful audio data

    • TC_20_AudioVM_Pulse_whonix-workstation-17-pool: test_223_audio_play_hvm (failure)
      AssertionError: Command 'timeout 20s paplay --format=float32le --ra...

  • system_tests_basic_vm_qrexec_gui@hw1

Unstable tests

  • system_tests_basic_vm_qrexec_gui

    TC_20_AudioVM_Pulse_whonix-workstation-17/test_220_audio_play_pulseaudio (2/2 times with errors)
    • job 101109 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
    • job 101758 AssertionError: too short audio, expected 10s, got 8.73532879818594...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_222_audio_rec_unmuted_pulseaudio (2/2 times with errors)
    • job 101109 AssertionError: only silence detected, no useful audio data
    • job 101758 AssertionError: too short audio, expected 10s, got 9.36446712018140...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_223_audio_play_hvm (1/2 times with errors)
    • job 101109 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_252_audio_playback_audiovm_switch_hvm (1/2 times with errors)
    • job 101109 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
  • system_tests_pvgrub_salt_storage

    TC_41_HVMGrub_debian-12-xfce/test_000_standalone_vm (1/2 times with errors)
    • job 101773 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
    StorageFile/test_001_non_volatile (1/2 times with errors)
    • job 101124 subprocess.CalledProcessError: Command '/usr/lib/qubes/destroy-snap...
    TC_41_HVMGrub_debian-12-xfce/test_010_template_based_vm (1/2 times with errors)
    • job 101773 qubes.exc.QubesVMError: Cannot connect to qrexec agent for 120 seco...
  • system_tests_extra

    TC_00_QVCTest_whonix-workstation-17/test_010_screenshare (1/2 times with errors)
    • job 101116 self.assertNotEqual(vm.run('test -e /dev/vid... AssertionError: 0 == 0
    TC_00_QVCTest_debian-12-xfce/test_020_webcam (1/2 times with errors)
    • job 101116 AssertionError: 'qubes-video-companion webcam' exited early (0): b'...
    TC_00_QVCTest_fedora-40-xfce/test_020_webcam (1/2 times with errors)
    • job 101765 AssertionError: 'qubes-video-companion webcam' exited early (0): b'...
    TC_00_QVCTest_whonix-workstation-17/test_020_webcam (1/2 times with errors)
    • job 101116 AssertionError: 'qubes-video-companion webcam' exited early (0): b'...
  • system_tests_usbproxy

    TC_20_USBProxy_core3_whonix-gateway-17/test_070_attach_not_installed_front (1/2 times with errors)
    • job 101101 qubesusbproxy.core3ext.QubesUSBException: Device attach failed: 202...
  • system_tests_network_updates

    TC_00_Dom0Upgrade_whonix-gateway-17/test_006_update_flag_clear (1/2 times with errors)
    • job 101123 Error: Failed to download metadata for repo 'test': Cannot download...
    TC_10_QvmTemplate_debian-12-xfce/test_010_template_install (1/2 times with errors)
    • job 101123 AssertionError: qvm-template failed: Downloading 'qubes-template-de...
    TC_10_QvmTemplate_fedora-40-xfce/test_010_template_install (1/2 times with errors)
    • job 101123 AssertionError: qvm-template failed: Downloading 'qubes-template-de...
    TC_10_QvmTemplate_whonix-gateway-17/test_010_template_install (1/2 times with errors)
    • job 101123 AssertionError: qvm-template failed: Downloading 'qubes-template-de...
    TC_11_QvmTemplateMgmtVM_debian-12-xfce/test_010_template_install (1/2 times with errors)
    • job 101123 AssertionError: qvm-template failed: Downloading 'qubes-template-de...
    TC_11_QvmTemplateMgmtVM_fedora-40-xfce/test_010_template_install (1/2 times with errors)
    • job 101123 AssertionError: qvm-template failed: Downloading 'qubes-template-de...
    TC_11_QvmTemplateMgmtVM_whonix-gateway-17/test_010_template_install (1/2 times with errors)
    • job 101123 AssertionError: qvm-template failed: Downloading 'qubes-template-de...
  • system_tests_dispvm

    TC_20_DispVM_fedora-40-xfce/test_100_open_in_dispvm (1/2 times with errors)
    • job 101764 AssertionError: './open-file test.txt' failed with ./open-file test...
  • system_tests_basic_vm_qrexec_gui_btrfs

    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_220_audio_play_pulseaudio (1/2 times with errors)
    • job 101110 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_222_audio_rec_unmuted_pulseaudio (1/2 times with errors)
    • job 101110 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_223_audio_play_hvm (1/2 times with errors)
    • job 101110 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
    TC_20_AudioVM_Pulse_fedora-40-xfce-pool/test_225_audio_rec_unmuted_hvm (1/2 times with errors)
    • job 101782 AssertionError: too short audio, expected 10s, got 6.28875283446712...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_252_audio_playback_audiovm_switch_hvm (2/2 times with errors)
    • job 101110 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
    • job 101782 AssertionError: pacat for test-inst-vm1 (xid 90) running(False) in ...
  • system_tests_basic_vm_qrexec_gui_ext4

    TC_00_Basic/test_141_libvirt_objects_reconnect (1/2 times with errors)
    • job 101111 AssertionError: libvirt event impl drain timeout
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_220_audio_play_pulseaudio (1/2 times with errors)
    • job 101111 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_222_audio_rec_unmuted_pulseaudio (1/2 times with errors)
    • job 101111 AssertionError: only silence detected, no useful audio data
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_223_audio_play_hvm (1/2 times with errors)
    • job 101111 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_252_audio_playback_audiovm_switch_hvm (1/2 times with errors)
    • job 101111 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
  • system_tests_basic_vm_qrexec_gui_xfs

    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_220_audio_play_pulseaudio (2/2 times with errors)
    • job 101112 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
    • job 101781 AssertionError: too short audio, expected 10s, got 8.33947845804988...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_222_audio_rec_unmuted_pulseaudio (2/2 times with errors)
    • job 101112 AssertionError: only silence detected, no useful audio data
    • job 101781 AssertionError: too short audio, expected 10s, got 8.17784580498866...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_223_audio_play_hvm (2/2 times with errors)
    • job 101112 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
    • job 101781 AssertionError: too short audio, expected 10s, got 7.71551020408163...
    TC_20_AudioVM_Pulse_whonix-workstation-17-pool/test_252_audio_playback_audiovm_switch_hvm (1/2 times with errors)
    • job 101112 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
  • system_tests_basic_vm_qrexec_gui@hw1

    TC_20_AudioVM_Pulse_whonix-workstation-17/test_220_audio_play_pulseaudio (2/2 times with errors)
    • job 101109 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
    • job 101758 AssertionError: too short audio, expected 10s, got 8.73532879818594...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_222_audio_rec_unmuted_pulseaudio (2/2 times with errors)
    • job 101109 AssertionError: only silence detected, no useful audio data
    • job 101758 AssertionError: too short audio, expected 10s, got 9.36446712018140...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_223_audio_play_hvm (1/2 times with errors)
    • job 101109 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
    TC_20_AudioVM_Pulse_whonix-workstation-17/test_252_audio_playback_audiovm_switch_hvm (1/2 times with errors)
    • job 101109 AssertionError: Command 'timeout 20s paplay --format=float32le --ra...
  • system_tests_suspend

    suspend/ (2/4 times with errors)
    suspend/Failed (2/4 times with errors)
    • job 102431 # Test died: no candidate needle with tag(s) 'xscreensaver-prompt' ...
    • job 102443 # Test died: no candidate needle with tag(s) 'xscreensaver-prompt' ...
    suspend/wait_serial (2/4 times with errors)
    • job 102431 # wait_serial expected: qr/2E8vz-\d+-/...
    • job 102443 # wait_serial expected: qr/2E8vz-\d+-/...
  • system_tests_suspend@hw1

    suspend/ (2/4 times with errors)
    suspend/Failed (2/4 times with errors)
    • job 102431 # Test died: no candidate needle with tag(s) 'xscreensaver-prompt' ...
    • job 102443 # Test died: no candidate needle with tag(s) 'xscreensaver-prompt' ...
    suspend/wait_serial (2/4 times with errors)
    • job 102431 # wait_serial expected: qr/2E8vz-\d+-/...
    • job 102443 # wait_serial expected: qr/2E8vz-\d+-/...

untrusted_device_desc = untrusted_device_desc.decode(
'unicode_escape', errors='ignore')
return ''.join(
c if c in set(safe_chars) else '_' for c in untrusted_device_desc
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move set out of the loop.

Comment on lines 225 to 280
untrusted_device_desc = untrusted_device_desc.decode(
'unicode_escape', errors='ignore')
Copy link
Contributor

Choose a reason for hiding this comment

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

I looked at the underlying C code, and it does not give me confidence. It’s probably correct, but I would not trust it to be safe with malicious input. For instance, it supports \N{NAME} escapes, where NAME is the name of a Unicode character.

I recommend one of the following, in order of preference:

  1. Switch to a different codec, such as base64.
  2. Reimplement the functionality that is actually needed in pure Python.

@marmarek
Copy link
Member

Integration tests need an update (see a long list of failures in the updated bot comment above).

@marmarek
Copy link
Member

test_010_assign still fails, this is what I got from logs:

ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-114666' coro=<USBDeviceExtension.attach_and_notify() done, defined at /usr/lib/python3.11/site-packages/qubesusbproxy/core3ext.py:432> exception=QubesUSBException('Device attach failed: 2024-05-16 09:58:43.067 qrexec-client[124341]: process_io.c:236:qrexec_process_io: vchan connection closed early (fds: 1 -1 -1, status: -1 -1)')>
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/qubesusbproxy/core3ext.py", line 561, in on_device_attach_usb
    await vm.run_service_for_stdio('qubes.USBAttach',
  File "/usr/lib/python3.11/site-packages/qubes/vm/qubesvm.py", line 1585, in run_service_for_stdio
    raise subprocess.CalledProcessError(p.returncode,
subprocess.CalledProcessError: Command 'qubes.USBAttach' returned non-zero exit status 255.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/qubesusbproxy/core3ext.py", line 435, in attach_and_notify
    await self.on_device_attach_usb(
  File "/usr/lib/python3.11/site-packages/qubesusbproxy/core3ext.py", line 573, in on_device_attach_usb
    raise QubesUSBException(
qubesusbproxy.core3ext.QubesUSBException: Device attach failed: 2024-05-16 09:58:43.067 qrexec-client[124341]: process_io.c:236:qrexec_process_io: vchan connection closed early (fds: 1 -1 -1, status: -1 -1)

But I'm not sure what is wrong, I do see qubes.USB call being made:

May 16 09:13:10 dom0 qrexec-policy-daemon[1390]: qrexec: qubes.USB+1-1: test-inst-frontend -> test-inst-backend: allowed to test-inst-backend

device = assignment.device
await self.on_device_attach_usb(vm, '', device, options={})
for assignment in vm.devices['usb'].get_assigned_devices():
asyncio.ensure_future(self.attach_and_notify(
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be await instead of asyncio.ensure_future and that's what the test detected (see the "Task exception was never retrieved" part). And the actual attach probably failed because test already started cleaning up (but that's just my guess)...

Copy link
Member Author

Choose a reason for hiding this comment

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

youre right

@marmarek
Copy link
Member

@piotrbartman there is an issue changing core3ext.py... Currently this repo is using the same branch for all qubes releases (R4.1, R4.2, R4.3, ...), so merging this change into main will break R4.2. Do you see some way to make it compatible with R4.2 (some if, condition on importing device_protocol or something) and be not too ugly? Or maybe the endpoint for device plugins needs to be renamed when changing the API (see setup.py)?
If it would be too problematic, I can also move R4.1/R4.2 into separate branch, but if not too problematic, I'd like to avoid it.

Comment on lines 225 to 280
untrusted_device_desc = untrusted_device_desc.decode(
'unicode_escape', errors='ignore')
Copy link
Contributor

Choose a reason for hiding this comment

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

The concern is that malicious input might be able to attack the C implementation of unicode_escape before the character set filtering happens. Character set filtering will not protect against memory corruption that happens earlier.

Do you want me to provide a simple pure-Python reimplementation?

if i >= len(untrusted_device_desc):
break
hex_code = untrusted_device_desc[i - 1: i + 1]
c = chr(int(hex_code, base=16))
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a check that these are actually hex digits?

Comment on lines +302 to +303
hex_value = int(hex_code, 16)
c = chr(hex_value)
Copy link
Contributor

Choose a reason for hiding this comment

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

I’d do an explicit check for both characters being hex digits. int() is rather loose.


result = ""
i = 0
while i < len(untrusted_device_desc):
Copy link
Member

Choose a reason for hiding this comment

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

This loop never ends on "Test\x20device"

break
hex_code = untrusted_device_desc[i - 1: i + 1]
try:
for i in range(2):
Copy link
Member

Choose a reason for hiding this comment

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

Here you reset i...

@marmarek marmarek merged commit f86dbf6 into QubesOS:main Jun 21, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants