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

Sanitize sandbox output #491

Merged
merged 9 commits into from
Aug 1, 2023
Merged

Sanitize sandbox output #491

merged 9 commits into from
Aug 1, 2023

Conversation

apyrgio
Copy link
Contributor

@apyrgio apyrgio commented Jul 31, 2023

Sanitize the output that the container/disposable VM sends back to the user, before displaying it on screen/terminal. Also tackle some issues that are closely related to the sanitization logic, and add some tests.

@apyrgio apyrgio force-pushed the 2023-07-sanitize-progress-update branch from 3e5e280 to 2d3457d Compare July 31, 2023 11:08
Copy link
Contributor

@deeplow deeplow left a comment

Choose a reason for hiding this comment

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

One tiny comment, but otherwise a quite a good hardening. And thanks for catching also the GUI plaintext part.

apyrgio and others added 9 commits August 1, 2023 14:38
The isort tool is not compatible with Black by default. This leads to a
tug of war between these tools, when we run `make lint-apply` -> `make
lint`. Fix this by forcing isort to be compatible with Black.
Do not forget to reset the red text once we print an error string to the
terminal
Run our GUI tests on separate processes, because the combination of
Ubuntu Focal, Qt5, PySide6, and pytest-qt somehow leads to segfaults,
probably due to stale global state.

Closes #493
Make the `error_label` widget always render messages as plain text,
instead of auto discovering if the text is rich. We need this because
the error message may contain input from the sandbox, which we consider
untrusted.
Add `replace_control_chars()` function in `util.py`, which can be used
to sanitize strings from ANSI escape sequences or weird Unicode symbols.
Sanitize filenames in various places in the code, before we write them
to the user's terminal. Filenames, especially in Linux, can contain
virtually any character except for '\0' and '/', so it's important to
sanitize them.
Update the common `print_progress()` method in the base
`IsolationProvider` class, with two extra features:

1. Always sanitize the provided text argument.
2. Mark the sanitized text argument as untrusted.

This is default behavior from now on, since this function is commonly
used to parse progress reports from the conversion sandbox.
Improve the `parse_progress()` method of the container isolation
provider in the following ways:

1. Make sure that the fields of the progress report have the expected
   type.
2. In case of a JSON parsing error, sanitize the invalid string so that
   it doesn't contain escape sequences, or the user considers it as
   trusted.
Mark the messages that Dangerzone creates once a conversion step
finishes as trusted, since they do not contain any string not controlled
by us.
@apyrgio apyrgio force-pushed the 2023-07-sanitize-progress-update branch from 09f866f to 6c374d8 Compare August 1, 2023 11:44
@apyrgio apyrgio merged commit 6c374d8 into main Aug 1, 2023
@deeplow deeplow deleted the 2023-07-sanitize-progress-update branch August 9, 2023 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants