[PR #4966] [MERGED] security: harden local execution and package trust #6559

Closed
opened 2026-10-23 04:11:35 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4966
Author: @SpicyMarinara
Created: 8/13/2026
Status: ✅ Merged
Merged: 8/13/2026
Merged by: @SpicyMarinara

Base: staging ← Head: agent/security-hardening-2026-08


📝 Commits (8)

  • 3d8a8b0 security: harden local execution and package trust
  • 62c4f8a security: address CodeQL gate findings
  • 3a79142 security: preserve CSS token boundaries
  • 802b789 security: apply review hardening
  • 57590dd security: finish automated review fixes
  • 8267e45 security: close final review edge cases
  • 704bba0 security: normalize final import edge cases
  • 0b2080d ci: use canonical pnpm integrity pin

📊 Changes

80 files changed (+6601 additions, -1616 deletions)

View changed files

📝 .env.example (+32 -24)
➕ .github/dependabot.yml (+23 -0)
📝 .github/workflows/bunny-review.yml (+6 -2)
➕ .github/workflows/codeql.yml (+46 -0)
📝 .github/workflows/prealpha-platform-builds.yml (+59 -29)
📝 .github/workflows/pull-request-checks.yml (+7 -0)
➕ .github/workflows/security-audit.yml (+33 -0)
📝 CHANGELOG.md (+3 -0)
📝 CONTRIBUTING.md (+1 -0)
📝 Dockerfile (+2 -2)
📝 Dockerfile.lite (+3 -3)
📝 README.md (+1 -1)
📝 android/README.md (+18 -5)
📝 android/app/build.gradle (+37 -3)
📝 android/app/src/main/java/com/marinara/engine/MainActivity.java (+492 -42)
📝 android/gradle/wrapper/gradle-wrapper.properties (+1 -0)
📝 docs/CONFIGURATION.md (+4 -2)
📝 docs/FAQ.md (+3 -1)
📝 docs/REMOTE_ACCESS.md (+7 -7)
📝 docs/TROUBLESHOOTING.md (+10 -0)

...and 60 more files

📄 Description

Why

A broad security review found several trust-boundary gaps in local executable features, Android localhost integration, downloadable packages, network auto-trust, local secret storage, and build supply chains. This patch closes those gaps while preserving user-installed extensions, scripts, webhooks, agents, remote media, manual Termux installs, and remote-access workflows.

No linked issue was opened, per maintainer request; this security hardening was prepared directly.

What changed

  • Replace Professor Mari JavaScript --where evaluation with a small data-only expression parser, and run transform scripts in a separate OS sandbox with an explicit reviewed-script compatibility fallback where no supported sandbox exists.
  • Run custom Script tools in an isolated QuickJS worker; quarantine imported executable tools until local review; encrypt webhook credentials at storage boundaries and warn before credential-bearing exports.
  • Authenticate APK-managed Android localhost sessions, verify Termux downloads and installed signers, bind the native bridge to each trusted top-frame navigation, preserve manual Termux through explicit consent, and require real release signing.
  • Bind Agent installs to the reviewed version and SHA-256, verify installed package files before execution/serving, bound ZIP parsing, and contain shared-message HTML/CSS without disabling HTTPS or data-image styling.
  • Make automatic Tailscale and Docker trust request-local and runtime-specific while retaining explicit compatibility overrides; fail closed on invalid allowlists and require ADMIN_SECRET for non-loopback Professor Mari access.
  • Harden local file and backup permissions, fail Windows release installs on moved tag commits, pin Actions, Docker bases, and Gradle downloads, patch audited dependencies, and restore Dependabot, audit, and CodeQL coverage.

Automated validation

  • pnpm check
  • Focused security regressions for Mari DB execution, custom Script isolation/import, ZIP parsing, shared-message CSS, Android local auth, request trust, package lifecycle, storage shutdown, and backups
  • MARINARA_LOW_MEMORY_BUILD=1 pnpm --filter @marinara-engine/server build
  • pnpm audit --audit-level low
  • node scripts/check-windows-installer-layout.mjs
  • Android debug Java compilation; unsigned release artifact build correctly failed closed
  • pnpm install --frozen-lockfile
  • git diff --check

Manual verification requested

  • Manually complete an APK-managed Android install with an official Termux signer.
  • Manually verify the explicit unverified-server consent path for an existing manual Termux setup.
  • Manually import, review, enable, execute, and export a Script and webhook Function.
  • Manually install/update an Agent from both the official catalog and an explicitly trusted custom catalog.
  • Manually verify direct Tailscale and Docker access plus authenticated forwarded-proxy access.

Compatibility notes

Dangerous implicit trust is removed, but capabilities are retained. Operators can still explicitly enable broad Docker/Tailscale compatibility. mari db transform remains automatic on supported macOS/Linux sandboxes and has an explicit MARI_DB_ALLOW_UNSAFE_TRANSFORMS=true route for personally reviewed scripts on unsupported systems. Custom Script tools retain their existing opt-in and API.

Summary by CodeRabbit

  • Security
    • Strengthened Android authentication, APK verification, release integrity checks, and local file protection.
    • Improved protection for custom-tool credentials, imported scripts, chat CSS, ZIP files, and database operations.
  • New Features
    • Added verified capability-package installations with version and checksum validation.
    • Custom scripts and data transforms now run in isolated, resource-limited environments.
  • Bug Fixes
    • Invalid network allowlists now fail closed, and release installations stop on commit mismatches.
  • Documentation
    • Expanded Android setup, security settings, custom-tool, and release-signing guidance.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/4966 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/13/2026 **Status:** ✅ Merged **Merged:** 8/13/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `agent/security-hardening-2026-08` --- ### 📝 Commits (8) - [`3d8a8b0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3d8a8b0c0a81ccb146b393c06da756c0a7ca0ab6) security: harden local execution and package trust - [`62c4f8a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/62c4f8a8442e26c57e3fc353f84aa32ca2bd3077) security: address CodeQL gate findings - [`3a79142`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3a7914208065c67cdc71340d0bbcf1c5a8e55ec1) security: preserve CSS token boundaries - [`802b789`](https://github.com/Pasta-Devs/Marinara-Engine/commit/802b78996cfed49c7fc1dc12640a628158d37b97) security: apply review hardening - [`57590dd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/57590dd4ecd27b7d0bf2eb305d8bc6aa72d4a0ad) security: finish automated review fixes - [`8267e45`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8267e456b5095ffbb6cbc60e3a15caa78b0540c9) security: close final review edge cases - [`704bba0`](https://github.com/Pasta-Devs/Marinara-Engine/commit/704bba07503830be32871c3a333e6adf11a0cfd0) security: normalize final import edge cases - [`0b2080d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0b2080d65cd5896e69b0aa329f6d2d9b1c50d696) ci: use canonical pnpm integrity pin ### 📊 Changes **80 files changed** (+6601 additions, -1616 deletions) <details> <summary>View changed files</summary> 📝 `.env.example` (+32 -24) ➕ `.github/dependabot.yml` (+23 -0) 📝 `.github/workflows/bunny-review.yml` (+6 -2) ➕ `.github/workflows/codeql.yml` (+46 -0) 📝 `.github/workflows/prealpha-platform-builds.yml` (+59 -29) 📝 `.github/workflows/pull-request-checks.yml` (+7 -0) ➕ `.github/workflows/security-audit.yml` (+33 -0) 📝 `CHANGELOG.md` (+3 -0) 📝 `CONTRIBUTING.md` (+1 -0) 📝 `Dockerfile` (+2 -2) 📝 `Dockerfile.lite` (+3 -3) 📝 `README.md` (+1 -1) 📝 `android/README.md` (+18 -5) 📝 `android/app/build.gradle` (+37 -3) 📝 `android/app/src/main/java/com/marinara/engine/MainActivity.java` (+492 -42) 📝 `android/gradle/wrapper/gradle-wrapper.properties` (+1 -0) 📝 `docs/CONFIGURATION.md` (+4 -2) 📝 `docs/FAQ.md` (+3 -1) 📝 `docs/REMOTE_ACCESS.md` (+7 -7) 📝 `docs/TROUBLESHOOTING.md` (+10 -0) _...and 60 more files_ </details> ### 📄 Description ## Why A broad security review found several trust-boundary gaps in local executable features, Android localhost integration, downloadable packages, network auto-trust, local secret storage, and build supply chains. This patch closes those gaps while preserving user-installed extensions, scripts, webhooks, agents, remote media, manual Termux installs, and remote-access workflows. No linked issue was opened, per maintainer request; this security hardening was prepared directly. ## What changed - Replace Professor Mari JavaScript `--where` evaluation with a small data-only expression parser, and run transform scripts in a separate OS sandbox with an explicit reviewed-script compatibility fallback where no supported sandbox exists. - Run custom Script tools in an isolated QuickJS worker; quarantine imported executable tools until local review; encrypt webhook credentials at storage boundaries and warn before credential-bearing exports. - Authenticate APK-managed Android localhost sessions, verify Termux downloads and installed signers, bind the native bridge to each trusted top-frame navigation, preserve manual Termux through explicit consent, and require real release signing. - Bind Agent installs to the reviewed version and SHA-256, verify installed package files before execution/serving, bound ZIP parsing, and contain shared-message HTML/CSS without disabling HTTPS or data-image styling. - Make automatic Tailscale and Docker trust request-local and runtime-specific while retaining explicit compatibility overrides; fail closed on invalid allowlists and require `ADMIN_SECRET` for non-loopback Professor Mari access. - Harden local file and backup permissions, fail Windows release installs on moved tag commits, pin Actions, Docker bases, and Gradle downloads, patch audited dependencies, and restore Dependabot, audit, and CodeQL coverage. ## Automated validation - `pnpm check` - Focused security regressions for Mari DB execution, custom Script isolation/import, ZIP parsing, shared-message CSS, Android local auth, request trust, package lifecycle, storage shutdown, and backups - `MARINARA_LOW_MEMORY_BUILD=1 pnpm --filter @marinara-engine/server build` - `pnpm audit --audit-level low` - `node scripts/check-windows-installer-layout.mjs` - Android debug Java compilation; unsigned release artifact build correctly failed closed - `pnpm install --frozen-lockfile` - `git diff --check` ## Manual verification requested - [ ] Manually complete an APK-managed Android install with an official Termux signer. - [ ] Manually verify the explicit unverified-server consent path for an existing manual Termux setup. - [ ] Manually import, review, enable, execute, and export a Script and webhook Function. - [ ] Manually install/update an Agent from both the official catalog and an explicitly trusted custom catalog. - [ ] Manually verify direct Tailscale and Docker access plus authenticated forwarded-proxy access. ## Compatibility notes Dangerous implicit trust is removed, but capabilities are retained. Operators can still explicitly enable broad Docker/Tailscale compatibility. `mari db transform` remains automatic on supported macOS/Linux sandboxes and has an explicit `MARI_DB_ALLOW_UNSAFE_TRANSFORMS=true` route for personally reviewed scripts on unsupported systems. Custom Script tools retain their existing opt-in and API. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Security** * Strengthened Android authentication, APK verification, release integrity checks, and local file protection. * Improved protection for custom-tool credentials, imported scripts, chat CSS, ZIP files, and database operations. * **New Features** * Added verified capability-package installations with version and checksum validation. * Custom scripts and data transforms now run in isolated, resource-limited environments. * **Bug Fixes** * Invalid network allowlists now fail closed, and release installations stop on commit mismatches. * **Documentation** * Expanded Android setup, security settings, custom-tool, and release-signing guidance. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:11:35 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#6559
No description provided.