From 3bde48a9fbb331f9cc92123234a970fa1e747313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Thu, 31 Aug 2023 16:35:08 +0200 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=94=92=EF=B8=8F=20Use=20sandboxed=20j?= =?UTF-8?q?inja=20env=20for=20gcode=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this patch, an attacker with admin rights could configure a specially crafted GCODE Script to allow for code execution during rendering of that script. An attacker might use this to extract data managed by OctoPrint, or manipulate data managed by OctoPrint, as well as execute arbitrary commands with the rights of the OctoPrint process on the server system. Fixes a reported security issue, CVE pending. --- src/octoprint/settings/__init__.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/octoprint/settings/__init__.py b/src/octoprint/settings/__init__.py index 4ca274dda..0a0d5eb93 100644 --- a/src/octoprint/settings/__init__.py +++ b/src/octoprint/settings/__init__.py @@ -593,9 +593,10 @@ class Settings: return folder def _init_script_templating(self): - from jinja2 import BaseLoader, ChoiceLoader, Environment, TemplateNotFound + from jinja2 import BaseLoader, ChoiceLoader, TemplateNotFound from jinja2.ext import Extension from jinja2.nodes import Include + from jinja2.sandbox import SandboxedEnvironment from octoprint.util.jinja import FilteredFileSystemLoader @@ -664,9 +665,9 @@ class Settings: def list_templates(self): return self._default.list_templates() - class RelEnvironment(Environment): + class RelEnvironment(SandboxedEnvironment): def __init__(self, prefix_sep=":", *args, **kwargs): - Environment.__init__(self, *args, **kwargs) + super().__init__(*args, **kwargs) self._prefix_sep = prefix_sep def join_path(self, template, parent): From 5ca7f07cb7f094fb031072a291be8c44c33a438b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 9 Oct 2023 10:13:40 +0200 Subject: [PATCH 2/5] =?UTF-8?q?=F0=9F=91=B7=20Include=20server=20run=20in?= =?UTF-8?q?=20test=20install=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test_install.yml | 81 ++++++++++++++++-------------- 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index a908de3c6..8cb72a8e0 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -15,21 +15,63 @@ jobs: matrix: os: ["ubuntu-latest"] python: ["3.7", "3.8", "3.9", "3.10", "3.11"] - branch: ["master"] + branch: ["master", "release"] runs-on: ${{ matrix.os }} steps: + - name: ⬇ Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + path: src + - name: 🐍 Set up Python ${{ matrix.python }} uses: actions/setup-python@v4 with: python-version: ${{ matrix.python }} - - name: ⬇ Checkout code + + # Checkout code and install + - name: ⬇ Checkout code to test + if: ${{ matrix.branch != 'release' }} uses: actions/checkout@v4 with: ref: ${{ matrix.branch }} fetch-depth: 0 + path: checkout - name: πŸ‘· Build and install checkout + if: ${{ matrix.branch != 'release' }} + working-directory: checkout run: | pip install . + + # Install latest release + - name: πŸ‘€ Determine latest release + if: ${{ matrix.branch == 'release' }} + run: | + OCTOPRINT_VERSION=$(curl -i https://github.com/OctoPrint/OctoPrint/releases/latest | grep -i location: | head -n1 | awk -F/ '{print $NF}' | tr -d '\r') + echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV + - name: πŸ‘· Build and install latest release + if: ${{ matrix.branch == 'release' }} + run: | + pip install https://github.com/OctoPrint/OctoPrint/archive/${{ env.OCTOPRINT_VERSION }}.zip + + # Test if server starts without error + - name: πŸ— Create base config for test server + run: | + mkdir e2econfig + cp -r src/.github/fixtures/with_acl/* e2econfig + - name: πŸ§ͺ Start OctoPrint server + run: | + timeout -k 10s 30s octoprint serve --basedir e2econfig & + wait + - name: πŸ”Ž Check octoprint.log for errors + run: | + log=${{ github.workspace }}/e2econfig/logs/octoprint.log + if grep "\- ERROR \-" $log; then + echo "::error::Errors were logged to octoprint.log" + grep -Pazo '(?m)^\N+\- ERROR \-\N*\n(^\N*?\n)*?(?=\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} \- )' $log + exit 1 + fi + - name: πŸ“§ Discord success notification continue-on-error: true env: @@ -45,38 +87,3 @@ jobs: uses: Ilshidur/action-discord@master with: args: "🚫 Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ matrix.branch }}` failed" - - install-latest: - name: Install latest release - strategy: - matrix: - os: ["ubuntu-latest"] - python: ["3.7", "3.8", "3.9", "3.10", "3.11"] - runs-on: ${{ matrix.os }} - steps: - - name: πŸ‘€ Determine latest release - run: | - OCTOPRINT_VERSION=$(curl -i https://github.com/OctoPrint/OctoPrint/releases/latest | grep -i location: | head -n1 | awk -F/ '{print $NF}' | tr -d '\r') - echo "OCTOPRINT_VERSION=$OCTOPRINT_VERSION" >> $GITHUB_ENV - - name: 🐍 Set up Python ${{ matrix.python }} - uses: actions/setup-python@v4 - with: - python-version: ${{ matrix.python }} - - name: πŸ‘· Build and install latest release - run: | - pip install https://github.com/OctoPrint/OctoPrint/archive/${{ env.OCTOPRINT_VERSION }}.zip - - name: πŸ“§ Discord success notification - continue-on-error: true - env: - DISCORD_WEBHOOK: ${{ secrets.discord_webhook }} - uses: Ilshidur/action-discord@master - with: - args: "β˜‘οΈ Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ env.OCTOPRINT_VERSION }}` was successful" - - name: πŸ“§ Discord failure notification - continue-on-error: true - if: failure() - env: - DISCORD_WEBHOOK: ${{ secrets.discord_webhook }} - uses: Ilshidur/action-discord@master - with: - args: "🚫 Test install on Python ${{ matrix.python }} under `${{ matrix.os }}` for `OctoPrint/OctoPrint:${{ env.OCTOPRINT_VERSION }}` failed" From 2b7c01563f080089ffdc1404a290b9f4f689cdb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 9 Oct 2023 10:49:37 +0200 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=93=8C=20Pin=20pydantic=20to=201.10.1?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Solves #4893 by working around pydantic/pydantic#7689 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 015458422..dcc0d11b3 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,7 @@ core_deps = [ "pathvalidate>=2.5.2,<3", "pkginfo>=1.9.6,<2", "psutil>=5.9.4,<6", - "pydantic>=1.10.7,<2", + "pydantic==1.10.12", # to be kept pinned until https://github.com/pydantic/pydantic/issues/7689 is resolved "pylru>=1.2.1,<2", "pyserial>=3.5,<4", "PyYAML>=6.0.1,<7", # changelog at https://github.com/yaml/pyyaml/blob/master/CHANGES From 506648c152681bf4b1416cf2b5aaf97d526ee752 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 9 Oct 2023 14:32:34 +0200 Subject: [PATCH 4/5] =?UTF-8?q?=F0=9F=94=96=20Preparing=20release=20of=201?= =?UTF-8?q?.9.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SUPPORTERS.md | 10 ++++------ src/octoprint/plugins/errortracking/__init__.py | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/SUPPORTERS.md b/SUPPORTERS.md index 6820f28cd..85403f9bd 100644 --- a/SUPPORTERS.md +++ b/SUPPORTERS.md @@ -10,7 +10,6 @@ thanks to everyone who contributed! * 3DPrinterOS * Al Mucci * Ash King - * Ben Fritsch * BigTreeTech * Boris Hussein * Brad Jackson @@ -18,13 +17,12 @@ thanks to everyone who contributed! * Christian Wolf * Christian WΓΌrthner * Christoph Sigrist - * Creality3D * DeltaMaker 3D Printers * Dennis Breining * Dima Gorbenko - * Douglas Floyd * Ed Crump * Ernesto Martinez + * Fiberpunk * Franziska Kunsmann * Hog Duske * Jacob Renstrom @@ -41,10 +39,10 @@ thanks to everyone who contributed! * Lachlan Bell * Lefteris Lertas * LulzBot - * Makerbase * Makespace Madrid * Mark Greenwald * Mark Walker + * Martin Majewski * Michael Aumock * Michael Badagliacco * Mike Labanov @@ -52,7 +50,6 @@ thanks to everyone who contributed! * Norman Jaffe * Obico * Ory Weaver - * Peopoly * Pete Barnwell * Raise3D * Randy C. Will @@ -64,6 +61,7 @@ thanks to everyone who contributed! * Stefan Krister * Steve Dougherty * Steve Thompson + * Tideline 3D * Ulrich Kempken -and 1970 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)! +and 1918 more wonderful people pledging on the [Patreon campaign](https://patreon.com/foosel) or via [GitHub Sponsors](https://github.com/users/foosel/sponsorship)! diff --git a/src/octoprint/plugins/errortracking/__init__.py b/src/octoprint/plugins/errortracking/__init__.py index a6225ceac..1797bb68f 100644 --- a/src/octoprint/plugins/errortracking/__init__.py +++ b/src/octoprint/plugins/errortracking/__init__.py @@ -18,10 +18,10 @@ from octoprint.util.version import ( ) SENTRY_URL_SERVER = ( - "https://ba4e3d61c37a4d219e1cd81bdc1417a7@o118517.ingest.sentry.io/1373987" + "https://f723fd2a91da40dbae1148193ea49001@o118517.ingest.sentry.io/1373987" ) SENTRY_URL_COREUI = ( - "https://2382252761de4d318e5f83be0816efaa@o118517.ingest.sentry.io/1374096" + "https://a115318be6faed605c6bfde4e183b7a0@o118517.ingest.sentry.io/1374096" ) SETTINGS_DEFAULTS = { From 8365b47bd58d71c90854ff4f5ffed3f96fba85ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 9 Oct 2023 17:19:40 +0200 Subject: [PATCH 5/5] =?UTF-8?q?=F0=9F=94=96=20staging/bugfix=20is=20now=20?= =?UTF-8?q?1.9.4.dev?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .versioneer-lookup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.versioneer-lookup b/.versioneer-lookup index 7657e4e87..5869b0961 100644 --- a/.versioneer-lookup +++ b/.versioneer-lookup @@ -26,8 +26,8 @@ improve/.* 1.9.0 fa2c4680cca0d1d6b46e6c1ed68ceea4d9b79afb pep440-dev # staging/bugfix is the branch for preparation of the 1.9.x bugfix releases # so are any bug/... branches -staging/bugfix 1.9.3 f027aaa7300f70b046525a49245b33c43dd198c1 pep440-dev -bug/.* 1.9.3 f027aaa7300f70b046525a49245b33c43dd198c1 pep440-dev +staging/bugfix 1.9.4 506648c152681bf4b1416cf2b5aaf97d526ee752 pep440-dev +bug/.* 1.9.4 506648c152681bf4b1416cf2b5aaf97d526ee752 pep440-dev # staging/maintenance is currently the branch for preparation of 1.9.0rc6 # so is regressionfix/...