mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-05-17 18:51:50 +02:00
Compare commits
12 commits
b67cb9bb60
...
48ad749965
Author | SHA1 | Date | |
---|---|---|---|
![]() |
48ad749965 | ||
![]() |
a7e39a04ad | ||
![]() |
abc72ffe0e | ||
![]() |
02602b072a | ||
![]() |
acf20ef700 | ||
![]() |
3499010d8e | ||
![]() |
2423fc18c5 | ||
![]() |
1298e9c398 | ||
![]() |
00e58a8707 | ||
![]() |
77975a8e50 | ||
![]() |
5b9e9c82fc | ||
![]() |
f4fa1f87eb |
18 changed files with 146 additions and 42 deletions
7
.github/workflows/check_repos.yml
vendored
7
.github/workflows/check_repos.yml
vendored
|
@ -53,8 +53,13 @@ jobs:
|
|||
gpg --keyserver hkps://keys.openpgp.org \
|
||||
--no-default-keyring --keyring ./fpf-apt-tools-archive-keyring.gpg \
|
||||
--recv-keys "DE28 AB24 1FA4 8260 FAC9 B8BA A7C9 B385 2260 4281"
|
||||
|
||||
# Export the GPG key in armor mode because sequoia needs it this way
|
||||
# (sqv is used on debian trixie by default to check the keys)
|
||||
mkdir -p /etc/apt/keyrings/
|
||||
mv fpf-apt-tools-archive-keyring.gpg /etc/apt/keyrings
|
||||
gpg --no-default-keyring --keyring ./fpf-apt-tools-archive-keyring.gpg \
|
||||
--armor --export "DE28 AB24 1FA4 8260 FAC9 B8BA A7C9 B385 2260 4281" \
|
||||
> /etc/apt/keyrings/fpf-apt-tools-archive-keyring.gpg
|
||||
|
||||
- name: Add packages.freedom.press to our APT sources
|
||||
run: |
|
||||
|
|
5
.github/workflows/scan.yml
vendored
5
.github/workflows/scan.yml
vendored
|
@ -17,7 +17,10 @@ jobs:
|
|||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install container build dependencies
|
||||
run: sudo apt install pipx && pipx install poetry
|
||||
run: |
|
||||
sudo apt install pipx
|
||||
pipx install poetry
|
||||
pipx inject poetry poetry-plugin-export
|
||||
- name: Build container image
|
||||
run: python3 ./install/common/build-image.py --runtime docker --no-save
|
||||
- name: Get image tag
|
||||
|
|
6
BUILD.md
6
BUILD.md
|
@ -70,6 +70,7 @@ methods](https://python-poetry.org/docs/#installation))_
|
|||
```sh
|
||||
pipx ensurepath
|
||||
pipx install poetry
|
||||
pipx inject poetry poetry-plugin-export
|
||||
```
|
||||
|
||||
After this, restart the terminal window, for the `poetry` command to be in your
|
||||
|
@ -157,6 +158,7 @@ Install Poetry using `pipx`:
|
|||
|
||||
```sh
|
||||
pipx install poetry
|
||||
pipx inject poetry poetry-plugin-export
|
||||
```
|
||||
|
||||
Clone this repository:
|
||||
|
@ -369,7 +371,7 @@ cd dangerzone
|
|||
Install Python dependencies:
|
||||
|
||||
```sh
|
||||
python3 -m pip install poetry
|
||||
python3 -m pip install poetry poetry-plugin-export
|
||||
poetry install
|
||||
```
|
||||
|
||||
|
@ -430,7 +432,7 @@ Install Microsoft Visual C++ 14.0 or greater. Get it with ["Microsoft C++ Build
|
|||
Install [poetry](https://python-poetry.org/). Open PowerShell, and run:
|
||||
|
||||
```
|
||||
python -m pip install poetry
|
||||
python -m pip install poetry poetry-plugin-export
|
||||
```
|
||||
|
||||
Install git from [here](https://git-scm.com/download/win), open a Windows terminal (`cmd.exe`) and clone this repository:
|
||||
|
|
|
@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
since 0.4.1, and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased](https://github.com/freedomofpress/dangerzone/compare/v0.8.0...HEAD)
|
||||
## [Unreleased](https://github.com/freedomofpress/dangerzone/compare/v0.8.1...HEAD)
|
||||
|
||||
-
|
||||
|
||||
## [0.8.1](https://github.com/freedomofpress/dangerzone/compare/v0.8.1...0.8.0)
|
||||
|
||||
- Update the container image
|
||||
|
||||
### Added
|
||||
|
||||
|
|
10
INSTALL.md
10
INSTALL.md
|
@ -1,7 +1,7 @@
|
|||
## MacOS
|
||||
|
||||
- Download [Dangerzone 0.8.0 for Mac (Apple Silicon CPU)](https://github.com/freedomofpress/dangerzone/releases/download/v0.8.0/Dangerzone-0.8.0-arm64.dmg)
|
||||
- Download [Dangerzone 0.8.0 for Mac (Intel CPU)](https://github.com/freedomofpress/dangerzone/releases/download/v0.8.0/Dangerzone-0.8.0-i686.dmg)
|
||||
- Download [Dangerzone 0.8.1 for Mac (Apple Silicon CPU)](https://github.com/freedomofpress/dangerzone/releases/download/v0.8.1/Dangerzone-0.8.1-arm64.dmg)
|
||||
- Download [Dangerzone 0.8.1 for Mac (Intel CPU)](https://github.com/freedomofpress/dangerzone/releases/download/v0.8.1/Dangerzone-0.8.1-i686.dmg)
|
||||
|
||||
You can also install Dangerzone for Mac using [Homebrew](https://brew.sh/): `brew install --cask dangerzone`
|
||||
|
||||
|
@ -11,7 +11,7 @@ You can also install Dangerzone for Mac using [Homebrew](https://brew.sh/): `bre
|
|||
|
||||
## Windows
|
||||
|
||||
- Download [Dangerzone 0.8.0 for Windows](https://github.com/freedomofpress/dangerzone/releases/download/v0.8.0/Dangerzone-0.8.0.msi)
|
||||
- Download [Dangerzone 0.8.1 for Windows](https://github.com/freedomofpress/dangerzone/releases/download/v0.8.1/Dangerzone-0.8.1.msi)
|
||||
|
||||
> **Note**: you will also need to install [Docker Desktop](https://www.docker.com/products/docker-desktop/).
|
||||
> This program needs to run alongside Dangerzone at all times, since it is what allows Dangerzone to
|
||||
|
@ -94,7 +94,9 @@ gpg --keyserver hkps://keys.openpgp.org \
|
|||
--no-default-keyring --keyring ./fpf-apt-tools-archive-keyring.gpg \
|
||||
--recv-keys "DE28 AB24 1FA4 8260 FAC9 B8BA A7C9 B385 2260 4281"
|
||||
sudo mkdir -p /etc/apt/keyrings/
|
||||
sudo mv fpf-apt-tools-archive-keyring.gpg /etc/apt/keyrings
|
||||
sudo gpg --no-default-keyring --keyring ./fpf-apt-tools-archive-keyring.gpg \
|
||||
--armor --export "DE28 AB24 1FA4 8260 FAC9 B8BA A7C9 B385 2260 4281" \
|
||||
> /etc/apt/keyrings/fpf-apt-tools-archive-keyring.gpg
|
||||
```
|
||||
|
||||
Add the URL of the repo in your APT sources:
|
||||
|
|
12
README.md
12
README.md
|
@ -14,13 +14,13 @@ _Read more about Dangerzone in the [official site](https://dangerzone.rocks/abou
|
|||
|
||||
Follow the instructions for each platform:
|
||||
|
||||
* [macOS](https://github.com/freedomofpress/dangerzone/blob/v0.8.0//INSTALL.md#macos)
|
||||
* [Windows](https://github.com/freedomofpress/dangerzone/blob/v0.8.0//INSTALL.md#windows)
|
||||
* [Ubuntu Linux](https://github.com/freedomofpress/dangerzone/blob/v0.8.0/INSTALL.md#ubuntu-debian)
|
||||
* [Debian Linux](https://github.com/freedomofpress/dangerzone/blob/v0.8.0/INSTALL.md#ubuntu-debian)
|
||||
* [Fedora Linux](https://github.com/freedomofpress/dangerzone/blob/v0.8.0/INSTALL.md#fedora)
|
||||
* [macOS](https://github.com/freedomofpress/dangerzone/blob/v0.8.1/INSTALL.md#macos)
|
||||
* [Windows](https://github.com/freedomofpress/dangerzone/blob/v0.8.1//INSTALL.md#windows)
|
||||
* [Ubuntu Linux](https://github.com/freedomofpress/dangerzone/blob/v0.8.1/INSTALL.md#ubuntu-debian)
|
||||
* [Debian Linux](https://github.com/freedomofpress/dangerzone/blob/v0.8.1/INSTALL.md#ubuntu-debian)
|
||||
* [Fedora Linux](https://github.com/freedomofpress/dangerzone/blob/v0.8.1/INSTALL.md#fedora)
|
||||
* [Qubes OS (beta)](https://github.com/freedomofpress/dangerzone/blob/v0.8.0/INSTALL.md#qubes-os)
|
||||
* [Tails](https://github.com/freedomofpress/dangerzone/blob/v0.8.0/INSTALL.md#tails)
|
||||
* [Tails](https://github.com/freedomofpress/dangerzone/blob/v0.8.1/INSTALL.md#tails)
|
||||
|
||||
## Some features
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ Here is what you need to do:
|
|||
|
||||
# In case of a new Python installation or minor version upgrade, e.g., from
|
||||
# 3.11 to 3.12, reinstall Poetry
|
||||
python3 -m pip install poetry
|
||||
python3 -m pip install poetry poetry-plugin-export
|
||||
|
||||
# You can verify the correct Python version is used
|
||||
poetry debug info
|
||||
|
@ -202,7 +202,7 @@ The Windows release is performed in a Windows 11 virtual machine (as opposed to
|
|||
```bash
|
||||
# In case of a new Python installation or minor version upgrade, e.g., from
|
||||
# 3.11 to 3.12, reinstall Poetry
|
||||
python3 -m pip install poetry
|
||||
python3 -m pip install poetry poetry-plugin-export
|
||||
|
||||
# You can verify the correct Python version is used
|
||||
poetry debug info
|
||||
|
|
|
@ -42,6 +42,12 @@ def print_header(s: str) -> None:
|
|||
type=click.UNPROCESSED,
|
||||
callback=args.validate_input_filenames,
|
||||
)
|
||||
@click.option(
|
||||
"--debug",
|
||||
"debug",
|
||||
flag_value=True,
|
||||
help="Run Dangerzone in debug mode, to get logs from gVisor.",
|
||||
)
|
||||
@click.version_option(version=get_version(), message="%(version)s")
|
||||
@errors.handle_document_errors
|
||||
def cli_main(
|
||||
|
@ -50,6 +56,7 @@ def cli_main(
|
|||
filenames: List[str],
|
||||
archive: bool,
|
||||
dummy_conversion: bool,
|
||||
debug: bool,
|
||||
) -> None:
|
||||
setup_logging()
|
||||
|
||||
|
@ -58,7 +65,7 @@ def cli_main(
|
|||
elif is_qubes_native_conversion():
|
||||
dangerzone = DangerzoneCore(Qubes())
|
||||
else:
|
||||
dangerzone = DangerzoneCore(Container())
|
||||
dangerzone = DangerzoneCore(Container(debug=debug))
|
||||
|
||||
display_banner()
|
||||
if len(filenames) == 1 and output_filename:
|
||||
|
|
|
@ -5,7 +5,9 @@ import platform
|
|||
import signal
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
from abc import ABC, abstractmethod
|
||||
from io import BytesIO
|
||||
from typing import IO, Callable, Iterator, Optional
|
||||
|
||||
import fitz
|
||||
|
@ -18,10 +20,6 @@ from ..util import get_tessdata_dir, replace_control_chars
|
|||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
MAX_CONVERSION_LOG_CHARS = 150 * 50 # up to ~150 lines of 50 characters
|
||||
DOC_TO_PIXELS_LOG_START = "----- DOC TO PIXELS LOG START -----"
|
||||
DOC_TO_PIXELS_LOG_END = "----- DOC TO PIXELS LOG END -----"
|
||||
|
||||
TIMEOUT_EXCEPTION = 15
|
||||
TIMEOUT_GRACE = 15
|
||||
TIMEOUT_FORCE = 5
|
||||
|
@ -75,9 +73,9 @@ def read_int(f: IO[bytes]) -> int:
|
|||
return int.from_bytes(untrusted_int, "big", signed=False)
|
||||
|
||||
|
||||
def read_debug_text(f: IO[bytes], size: int) -> str:
|
||||
"""Read arbitrarily long text (for debug purposes), and sanitize it."""
|
||||
untrusted_text = f.read(size).decode("ascii", errors="replace")
|
||||
def sanitize_debug_text(text: bytes) -> str:
|
||||
"""Read all the buffer and return a sanitized version"""
|
||||
untrusted_text = text.decode("ascii", errors="replace")
|
||||
return replace_control_chars(untrusted_text, keep_newlines=True)
|
||||
|
||||
|
||||
|
@ -86,12 +84,16 @@ class IsolationProvider(ABC):
|
|||
Abstracts an isolation provider
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
if getattr(sys, "dangerzone_dev", False) is True:
|
||||
def __init__(self, debug: bool = False) -> None:
|
||||
self.debug = debug
|
||||
if self.should_capture_stderr():
|
||||
self.proc_stderr = subprocess.PIPE
|
||||
else:
|
||||
self.proc_stderr = subprocess.DEVNULL
|
||||
|
||||
def should_capture_stderr(self) -> bool:
|
||||
return self.debug or getattr(sys, "dangerzone_dev", False)
|
||||
|
||||
@abstractmethod
|
||||
def install(self) -> bool:
|
||||
pass
|
||||
|
@ -327,7 +329,11 @@ class IsolationProvider(ABC):
|
|||
timeout_force: int = TIMEOUT_FORCE,
|
||||
) -> Iterator[subprocess.Popen]:
|
||||
"""Start a conversion process, pass it to the caller, and then clean it up."""
|
||||
# Store the proc stderr in memory
|
||||
stderr = BytesIO()
|
||||
p = self.start_doc_to_pixels_proc(document)
|
||||
stderr_thread = self.start_stderr_thread(p, stderr)
|
||||
|
||||
if platform.system() != "Windows":
|
||||
assert os.getpgid(p.pid) != os.getpgid(
|
||||
os.getpid()
|
||||
|
@ -343,15 +349,40 @@ class IsolationProvider(ABC):
|
|||
document, p, timeout_grace=timeout_grace, timeout_force=timeout_force
|
||||
)
|
||||
|
||||
# Read the stderr of the process only if:
|
||||
# * Dev mode is enabled.
|
||||
# * The process has exited (else we risk hanging).
|
||||
if getattr(sys, "dangerzone_dev", False) and p.poll() is not None:
|
||||
assert p.stderr
|
||||
debug_log = read_debug_text(p.stderr, MAX_CONVERSION_LOG_CHARS)
|
||||
if stderr_thread:
|
||||
# Wait for the thread to complete. If it's still alive, mention it in the debug log.
|
||||
stderr_thread.join(timeout=1)
|
||||
|
||||
debug_bytes = stderr.getvalue()
|
||||
debug_log = sanitize_debug_text(debug_bytes)
|
||||
|
||||
incomplete = "(incomplete) " if stderr_thread.is_alive() else ""
|
||||
|
||||
log.info(
|
||||
"Conversion output (doc to pixels)\n"
|
||||
f"{DOC_TO_PIXELS_LOG_START}\n"
|
||||
f"----- DOC TO PIXELS LOG START {incomplete}-----\n"
|
||||
f"{debug_log}" # no need for an extra newline here
|
||||
f"{DOC_TO_PIXELS_LOG_END}"
|
||||
"----- DOC TO PIXELS LOG END -----"
|
||||
)
|
||||
|
||||
def start_stderr_thread(
|
||||
self, process: subprocess.Popen, stderr: IO[bytes]
|
||||
) -> Optional[threading.Thread]:
|
||||
"""Start a thread to read stderr from the process"""
|
||||
|
||||
def _stream_stderr(process_stderr: IO[bytes]) -> None:
|
||||
try:
|
||||
for line in process_stderr:
|
||||
stderr.write(line)
|
||||
except (ValueError, IOError) as e:
|
||||
log.debug(f"Stderr stream closed: {e}")
|
||||
|
||||
if process.stderr:
|
||||
stderr_thread = threading.Thread(
|
||||
target=_stream_stderr,
|
||||
args=(process.stderr,),
|
||||
daemon=True,
|
||||
)
|
||||
stderr_thread.start()
|
||||
return stderr_thread
|
||||
return None
|
||||
|
|
|
@ -194,6 +194,10 @@ class Container(IsolationProvider):
|
|||
) -> subprocess.Popen:
|
||||
container_runtime = container_utils.get_runtime()
|
||||
security_args = self.get_runtime_security_args()
|
||||
debug_args = []
|
||||
if self.debug:
|
||||
debug_args += ["-e", "RUNSC_DEBUG=1"]
|
||||
|
||||
enable_stdin = ["-i"]
|
||||
set_name = ["--name", name]
|
||||
prevent_leakage_args = ["--rm"]
|
||||
|
@ -203,14 +207,14 @@ class Container(IsolationProvider):
|
|||
args = (
|
||||
["run"]
|
||||
+ security_args
|
||||
+ debug_args
|
||||
+ prevent_leakage_args
|
||||
+ enable_stdin
|
||||
+ set_name
|
||||
+ image_name
|
||||
+ command
|
||||
)
|
||||
args = [container_runtime] + args
|
||||
return self.exec(args)
|
||||
return self.exec([container_runtime] + args)
|
||||
|
||||
def kill_container(self, name: str) -> None:
|
||||
"""Terminate a spawned container.
|
||||
|
|
|
@ -71,6 +71,7 @@ class DangerzoneCore(object):
|
|||
ocr_lang,
|
||||
stdout_callback,
|
||||
)
|
||||
|
||||
except Exception:
|
||||
log.exception(
|
||||
f"Unexpected error occurred while converting '{document}'"
|
||||
|
|
6
debian/changelog
vendored
6
debian/changelog
vendored
|
@ -1,3 +1,9 @@
|
|||
dangerzone (0.8.1) unstable; urgency=low
|
||||
|
||||
* Released Dangerzone 0.8.1
|
||||
|
||||
-- Freedom of the Press Foundation <info@freedom.press> Tue, 22 December 2024 22:03:28 +0300
|
||||
|
||||
dangerzone (0.8.0) unstable; urgency=low
|
||||
|
||||
* Released Dangerzone 0.8.0
|
||||
|
|
|
@ -183,6 +183,7 @@ COPY storage.conf /home/user/.config/containers
|
|||
# FIXME: pipx install poetry does not work for Ubuntu Focal.
|
||||
ENV PATH="$PATH:/home/user/.local/bin"
|
||||
RUN pipx install poetry
|
||||
RUN pipx inject poetry poetry-plugin-export
|
||||
|
||||
COPY pyproject.toml poetry.lock /home/user/dangerzone/
|
||||
RUN cd /home/user/dangerzone && poetry --no-ansi install
|
||||
|
@ -291,6 +292,7 @@ def get_build_dir_sources(distro, version):
|
|||
sources = [
|
||||
git_root() / "pyproject.toml",
|
||||
git_root() / "poetry.lock",
|
||||
git_root() / "dev_scripts" / "env.py",
|
||||
git_root() / "dev_scripts" / "storage.conf",
|
||||
git_root() / "dev_scripts" / "containers.conf",
|
||||
]
|
||||
|
|
|
@ -287,6 +287,7 @@ methods](https://python-poetry.org/docs/#installation))_
|
|||
```sh
|
||||
pipx ensurepath
|
||||
pipx install poetry
|
||||
pipx inject poetry poetry-plugin-export
|
||||
```
|
||||
|
||||
After this, restart the terminal window, for the `poetry` command to be in your
|
||||
|
@ -375,6 +376,7 @@ Install Poetry using `pipx`:
|
|||
|
||||
```sh
|
||||
pipx install poetry
|
||||
pipx inject poetry poetry-plugin-export
|
||||
```
|
||||
|
||||
Clone this repository:
|
||||
|
@ -440,7 +442,7 @@ Install Microsoft Visual C++ 14.0 or greater. Get it with ["Microsoft C++ Build
|
|||
Install [poetry](https://python-poetry.org/). Open PowerShell, and run:
|
||||
|
||||
```
|
||||
python -m pip install poetry
|
||||
python -m pip install poetry poetry-plugin-export
|
||||
```
|
||||
|
||||
Install git from [here](https://git-scm.com/download/win), open a Windows terminal (`cmd.exe`) and clone this repository:
|
||||
|
@ -878,7 +880,7 @@ class QAWindows(QABase):
|
|||
"Install Poetry and the project's dependencies", ref=REF_BUILD, auto=True
|
||||
)
|
||||
def install_poetry(self):
|
||||
self.run("python", "-m", "pip", "install", "poetry")
|
||||
self.run("python", "-m", "pip", "install", "poetry", "poetry-plugin-export")
|
||||
self.run("poetry", "install", "--sync")
|
||||
|
||||
@QABase.task("Build Dangerzone container image", ref=REF_BUILD, auto=True)
|
||||
|
|
33
docs/advisories/2024-12-24.md
Normal file
33
docs/advisories/2024-12-24.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
Security Advisory 2024-12-24
|
||||
|
||||
In Dangerzone, a security vulnerability was detected in the quarantined
|
||||
environment where documents are opened. Vulnerabilities like this are expected
|
||||
and do not compromise the security of Dangerzone. However, in combination with
|
||||
another more serious vulnerability (also called container escape), a malicious
|
||||
document may be able to breach the security of Dangerzone. We are not aware of
|
||||
any container escapes that affect Dangerzone. **To reduce that risk, you are
|
||||
strongly advised to update Dangerzone to the latest version**.
|
||||
|
||||
# Summary
|
||||
|
||||
A series of vulnerabilities in gst-plugins-base (CVE-2024-47538, CVE-2024-47607
|
||||
and CVE-2024-47615) affects the **contained** environment where the document
|
||||
rendering takes place.
|
||||
|
||||
If one attempts to convert a malicious file with an embedded Vorbis or Opus
|
||||
media elements, arbitrary code may run within that environment. Such files
|
||||
look like regular Office documents, which means that you cannot avoid a specific
|
||||
extension. Other programs that open Office documents, such as LibreOffice, are
|
||||
also affected, unless the system has been upgraded in the meantime.
|
||||
|
||||
# How does this impact me?
|
||||
|
||||
The expectation is that malicious code will run in a container without Internet
|
||||
access, meaning that it won't be able to infect the rest of the system.
|
||||
|
||||
If you are running Dangerzone via the Qubes OS, you are not impacted.
|
||||
|
||||
# What do I need to do?
|
||||
|
||||
You are **strongly** advised to update your Dangerzone installation to 0.8.1 as
|
||||
soon as possible.
|
|
@ -32,7 +32,7 @@ Name: dangerzone-qubes
|
|||
Name: dangerzone
|
||||
%endif
|
||||
|
||||
Version: 0.8.0
|
||||
Version: 0.8.1
|
||||
Release: 1%{?dist}
|
||||
Summary: Take potentially dangerous PDFs, office documents, or images and convert them to safe PDFs
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "dangerzone"
|
||||
version = "0.8.0"
|
||||
version = "0.8.1"
|
||||
description = "Take potentially dangerous PDFs, office documents, or images and convert them to safe PDFs"
|
||||
authors = ["Freedom of the Press Foundation <info@freedom.press>", "Micah Lee <micah.lee@theintercept.com>"]
|
||||
license = "AGPL-3.0"
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.8.0
|
||||
0.8.1
|
||||
|
|
Loading…
Reference in a new issue