Skip to main content

Internal (INSECURE!) Dangerzone document to pixels conversion.

Project description

Dangerzone-image

This repository contains the dangerzone container image that is used to perform "document to pixels" conversions. This container is used by dangerzone to securely convert its documents.

Using the container image

The image is published on a monthly basis on the container registry, alongside their Cosign signatures. Additionally, nightly and development branches are published under the dangerzone-testing namespace.

Channel Location Signed? Use it for
Stable ghcr.io/freedomofpress/dangerzone/v1 ✅ (prod keys) Production
Nightly ghcr.io/freedomofpress/dangerzone-testing/main/v1 ✅ (testing keys) Development
Branch ghcr.io/freedomofpress/dangerzone-testing/<branch-name>/v1 ✅ (testing keys) Development

What this container provides

This container provides a way to convert documents to pixel buffers, using a secure sandbox.

The security of the sandbox is provided by different layers:

  • The container uses gVisor, an application Kernel that provides a strong layer of isolation between running applications and the host operating system. It is written in a memory-safe language (Go) and runs in userspace.
  • Additionally, it is expected that this container is run with specific flags and a specific seccomp policy, to unsure that users are not mapped in the container, that no network is available in the container, etc. See the "how to use" section.

We also provide the following guarantees, related to the distribution of the image:

  • The container is signed in an auditable way, using Cosign
  • Ultimately, the container is reproducible, and so one can verify that it can be rebuilt, resulting to the same digests.

How to use this container?

The recommended way to use this container is via these flags. They require to defined a specific seccomp policy. Seccomp policies is a way to define which system calls are authorized inside the container.

Here is a podman command with the proper flags, and the gvisor seccomp policy.

podman run \
    --log-driver none \
    --security-opt no-new-privileges \
    --userns nomap \
    --security-opt seccomp=tests/share/seccomp.gvisor.json \
    --cap-drop all \
    --cap-add SYS_CHROOT \
    --security-opt label=type:container_engine_t \
    --network=none \
    -u dangerzone \
    --rm -i ghcr.io/freedomofpress/dangerzone/v1 \
    /usr/bin/python3 -m dangerzone.conversion.doc_to_pixels

Output Format

The output of the container is streamed to stdout in a custom binary format:

  1. Total Pages: A 4-byte unsigned integer representing the total number of pages in the converted document.
  2. For each page: a. Page Width: A 4-byte unsigned integer representing the width of the page in pixels. b. Page Height: A 4-byte unsigned integer representing the height of the page in pixels. c. Pixel Data: bytes of raw RGB pixel data - Length is width x height x 3 color channels

dangerzone-insecure-conversion python package

[!WARNING] Do not use this unless you are certain about what you are doing. Do not use this to convert documents that should be processed safely!

The python code that runs inside the container is packaged under the name "dangerzone-insecure-conversion". It's considered insecure because the intended way to run dangerzone is by using a hardened sandbox, which is provided by dangerzone.

With that being said, there are situations where it's useful to run this code on its own, for instance when adding new file formats.

Running the tests

uv pip install -e .
uv run pytest

# Or, if you prefer to run the tests outside the sandbox:
uv run pytest --local

# It's also possible to run tests in parallel if you have multiple cores:
uv run --with pytest-xdist pytest -n 6

Building and Reproducing the Image

To build the Dangerzone container image, use the build-image.py script:

python3 build-image.py [OPTIONS]

Common Options:

  • --platform <PLATFORM>: Specify the build platform (e.g., linux/amd64, linux/arm64). Defaults to the current platform.
  • --runtime <RUNTIME>: Specify the container runtime (docker or podman). Defaults to podman.
  • --debian-archive-date <YYYYMMDD>: Use a specific Debian snapshot archive date for reproducibility.

Example:

python3 build-image.py --platform linux/amd64 --debian-archive-date 20231026

To verify the reproducibility of a Dangerzone container image, follow these instructions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dangerzone_insecure_conversion-1.0.0.tar.gz (12.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dangerzone_insecure_conversion-1.0.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

Details for the file dangerzone_insecure_conversion-1.0.0.tar.gz.

File metadata

  • Download URL: dangerzone_insecure_conversion-1.0.0.tar.gz
  • Upload date:
  • Size: 12.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dangerzone_insecure_conversion-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6fc0df75f5ad4a832641153931c0d188beb0505545cd8b733b0eddc79b24161f
MD5 9257d8d0b9d641733c83fa5889126ed4
BLAKE2b-256 135fcde7db05060808df9c3409377d053c43caff67e28064e57507e6b7be9ead

See more details on using hashes here.

File details

Details for the file dangerzone_insecure_conversion-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: dangerzone_insecure_conversion-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dangerzone_insecure_conversion-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 984f77e4159aa0835519b2b56d4d09df55164d071fa06967a965e3f0316534c9
MD5 8d4f6dbae1404e0fc7851f9557552ff9
BLAKE2b-256 9b1e6c025f89c46c348ce1fe2506b290b67f61f996db00caaee1dc537c3f0204

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page