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

Whitespace in policy file name (Policy Editor) #8795

Closed
johnnyboy-3 opened this issue Dec 27, 2023 · 4 comments · Fixed by QubesOS/qubes-desktop-linux-manager#220
Closed
Assignees
Labels
affects-4.2 This issue affects Qubes OS 4.2. C: core C: manager/widget diagnosed Technical diagnosis has been performed (see issue comments). P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. pr submitted A pull request has been submitted for this issue. T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists.

Comments

@johnnyboy-3
Copy link

Qubes OS release

R4.2

Brief summary

When using whitespaces in the policy editor as new policy file name, the Policy Editor won't save and prints an error message.

Steps to reproduce

  1. Open Qubes Policy Editor
  2. File -> New -> "test file" (without ")
  3. qubes.Filecopy * work @dispvm allow
  4. Save Changes

Expected behavior

Policy file saved to disk.

Actual behavior

An error occured while trying to save the policy file: Internal error. See /var/log/qubes/policy-admin.log in dom0 for details.

2023-12-27 15:22:44,628 policy.Replace+test file (dom0): exception
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/qrexec/tools/qubes_policy_admin.py", line 53, in main
    response = admin.handle_request(service_name, argument, payload)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/qrexec/policy/admin.py", line 90, in handle_request
    assert all(char in RPCNAME_ALLOWED_CHARSET for char in arg)
AssertionError

Suggested Solution

Don't allow whitespaces when at step #2.
Not tested: And don't allow other characters as well that could potentially break (injection wise ; + ( ) ' " { } * # $() `` ... )

@johnnyboy-3 johnnyboy-3 added P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists. labels Dec 27, 2023
@andrewdavidwong andrewdavidwong added C: core needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. affects-4.2 This issue affects Qubes OS 4.2. C: manager/widget labels Dec 27, 2023
@alimirjamali
Copy link

alimirjamali commented Sep 23, 2024

Don't allow whitespaces when at step #2. Not tested: And don't allow other characters as well that could potentially break (injection wise ; + ( ) ' " { } * # $() `` ... )

By design it only allows letters, numbers, plus sign, minus sign, dot and underline. I personally preferred if it forced letters and numbers for the 1st character (but that is another issue).

Don't allow whitespaces when at step #2

Having said that, you are right about the above point. It is relatively easy to fix. I will work on it.

@alimirjamali
Copy link

I personally preferred this to happen at the time of entering the filename (rather at saving time). But let's keep this simple and patch only one repository. User can copy/paste their draft policy.

policy

@alimirjamali
Copy link

alimirjamali commented Sep 23, 2024

It is more complex. It appears that we have two non-conforming logic to validate policy file names:

  1. One in qubes-core-qrexec. Here and here.
  2. One in qubes-desktop-linux-manager here.

@marmarek any suggestion?

p.s. Regex for the 2nd case should be r'^[\w-]+$'. But the discrepancy remains.

@andrewdavidwong andrewdavidwong added the S: question Status: question. In order to determine the status of this issue, an open question must be answered. label Sep 23, 2024
@andrewdavidwong andrewdavidwong added the pr submitted A pull request has been submitted for this issue. label Sep 23, 2024
@ben-grande
Copy link

p.s. Regex for the 2nd case should be r'^[\w-]+$'. But the discrepancy remains.

I'm not marmarek but I suggest to use the same method on both files to avoid having such discrepancies.

The correct method I commented on your PR:

QubesOS/qubes-core-qrexec#176 (comment)

alimirjamali added a commit to alimirjamali/qubes-core-qrexec that referenced this issue Sep 24, 2024
@andrewdavidwong andrewdavidwong added pr submitted A pull request has been submitted for this issue. diagnosed Technical diagnosis has been performed (see issue comments). and removed pr submitted A pull request has been submitted for this issue. S: question Status: question. In order to determine the status of this issue, an open question must be answered. needs diagnosis Requires technical diagnosis from developer. Replace with "diagnosed" or remove if otherwise closed. labels Sep 24, 2024
alimirjamali added a commit to alimirjamali/qubes-core-qrexec that referenced this issue Sep 25, 2024
alimirjamali added a commit to alimirjamali/qubes-core-qrexec that referenced this issue Sep 25, 2024
alimirjamali added a commit to alimirjamali/qubes-core-qrexec that referenced this issue Sep 25, 2024
alimirjamali added a commit to alimirjamali/qubes-core-qrexec that referenced this issue Sep 25, 2024
alimirjamali added a commit to alimirjamali/qubes-core-qrexec that referenced this issue Sep 25, 2024
alimirjamali added a commit to alimirjamali/qubes-core-qrexec that referenced this issue Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.2 This issue affects Qubes OS 4.2. C: core C: manager/widget diagnosed Technical diagnosis has been performed (see issue comments). P: default Priority: default. Default priority for new issues, to be replaced given sufficient information. pr submitted A pull request has been submitted for this issue. T: bug Type: bug report. A problem or defect resulting in unintended behavior in something that exists.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants