[GH-ISSUE #3810] [Issue]: Unix launchers execute .env with Bash semantics #2056

Closed
opened 2026-10-21 05:44:58 +07:00 by bsakaguchi · 5 comments
Owner

Originally created by @Xelvanis on GitHub (Jul 19, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3810

Originally assigned to: @SpicyMarinara on GitHub.

Summary

start.sh and start-termux.sh source the project .env as Bash code. The server and documentation treat the same file as inert dotenv KEY=value data, so valid dotenv values can abort startup, expand unexpectedly, or execute shell substitutions.

Expected behavior

Unix launchers should read only the settings they need using non-evaluating parsing compatible with the server's dotenv semantics. Values in .env should never be executed as shell code.

Actual behavior

Both Unix launchers run set -a; . ./.env; set +a. Bash therefore interprets spaces, substitutions, expansions, redirections, and other shell syntax. Because the launchers use set -e, a shell-incompatible but valid dotenv value can terminate startup.

The server independently reads the file with dotenv.config() in packages/server/src/config/runtime-config.ts, while docs/CONFIGURATION.md describes .env as plain KEY=value text. The Windows launcher uses a non-evaluating line parser instead.

Steps to reproduce

  1. On a source installation using a Bash launcher, add this valid dotenv value to .env:
    BASIC_AUTH_REALM=My Private Server
    
  2. Run ./start.sh --skip-update or ./start-termux.sh --skip-update.
  3. Observe Bash treating part of the value as a command and the launcher exiting with command not found.

A controlled parser comparison also confirmed that EXPANDED=$(printf shell-evaluated) executes the substitution when sourced by Bash, while dotenv.parse() preserves it literally.

Environment

  • Marinara Engine version: 2.3.3 / current source checkout
  • Install type: source / termux
  • OS + version: Affects Bash launchers on macOS, Linux, and Termux; reproduced with GNU Bash 5.2.26 under Git Bash
  • Browser or app shell: Not applicable; failure happens before server startup

Logs, screenshots, or video

Controlled reproduction output:

shell substitution value: shell-evaluated
/dev/fd/63: line 1: world: command not found
unquoted-space source status: 127

For the same input, dotenv returned literal values:

{ EXPANDED: '$(printf shell-evaluated)', PLAIN: 'hello world' }

Additional context

The sourcing was introduced in commit a1b7d8320 to make AUTO_UPDATE_ENABLED available before the update decision and reuse server settings later in the launcher. This appears to be an unintended consequence of that intentional behavior.

Smallest fix direction: after Node 24 is available, extract only launcher-owned settings (AUTO_UPDATE_ENABLED, PORT, HOST, SSL_CERT, SSL_KEY, and AUTO_OPEN_BROWSER) through a non-evaluating env-file parser. Do not use source or eval. Preserve ambient-environment precedence and test spaces, quotes, comments, $, command-substitution text, and Termux's pre-install startup order.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (Jul 19, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3810 Originally assigned to: @SpicyMarinara on GitHub. ## Summary `start.sh` and `start-termux.sh` source the project `.env` as Bash code. The server and documentation treat the same file as inert dotenv `KEY=value` data, so valid dotenv values can abort startup, expand unexpectedly, or execute shell substitutions. ## Expected behavior Unix launchers should read only the settings they need using non-evaluating parsing compatible with the server's dotenv semantics. Values in `.env` should never be executed as shell code. ## Actual behavior Both Unix launchers run `set -a; . ./.env; set +a`. Bash therefore interprets spaces, substitutions, expansions, redirections, and other shell syntax. Because the launchers use `set -e`, a shell-incompatible but valid dotenv value can terminate startup. The server independently reads the file with `dotenv.config()` in `packages/server/src/config/runtime-config.ts`, while `docs/CONFIGURATION.md` describes `.env` as plain `KEY=value` text. The Windows launcher uses a non-evaluating line parser instead. ## Steps to reproduce 1. On a source installation using a Bash launcher, add this valid dotenv value to `.env`: ```dotenv BASIC_AUTH_REALM=My Private Server ``` 2. Run `./start.sh --skip-update` or `./start-termux.sh --skip-update`. 3. Observe Bash treating part of the value as a command and the launcher exiting with `command not found`. A controlled parser comparison also confirmed that `EXPANDED=$(printf shell-evaluated)` executes the substitution when sourced by Bash, while `dotenv.parse()` preserves it literally. ## Environment - Marinara Engine version: 2.3.3 / current source checkout - Install type: source / termux - OS + version: Affects Bash launchers on macOS, Linux, and Termux; reproduced with GNU Bash 5.2.26 under Git Bash - Browser or app shell: Not applicable; failure happens before server startup ## Logs, screenshots, or video Controlled reproduction output: ```text shell substitution value: shell-evaluated /dev/fd/63: line 1: world: command not found unquoted-space source status: 127 ``` For the same input, dotenv returned literal values: ```text { EXPANDED: '$(printf shell-evaluated)', PLAIN: 'hello world' } ``` ## Additional context The sourcing was introduced in commit `a1b7d8320` to make `AUTO_UPDATE_ENABLED` available before the update decision and reuse server settings later in the launcher. This appears to be an unintended consequence of that intentional behavior. Smallest fix direction: after Node 24 is available, extract only launcher-owned settings (`AUTO_UPDATE_ENABLED`, `PORT`, `HOST`, `SSL_CERT`, `SSL_KEY`, and `AUTO_OPEN_BROWSER`) through a non-evaluating env-file parser. Do not use `source` or `eval`. Preserve ambient-environment precedence and test spaces, quotes, comments, `$`, command-substitution text, and Termux's pre-install startup order. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:44:58 +07:00
  • closed this issue
  • added the
    in-pr
    label
Author
Owner

@SpicyMarinara commented on GitHub (Jul 19, 2026):

Claimed by @SpicyMarinara for the assigned issue sweep on agent/assigned-issue-sweep. I will keep the fix scoped to this issue and link the draft PR once the first proof-backed patch is pushed.

<!-- gh-comment-id:5015840456 --> @SpicyMarinara commented on GitHub (Jul 19, 2026): Claimed by @SpicyMarinara for the assigned issue sweep on `agent/assigned-issue-sweep`. I will keep the fix scoped to this issue and link the draft PR once the first proof-backed patch is pushed.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 19, 2026):

Implementation will continue in draft PR #3814; the launcher fix is the next sweep slice.

<!-- gh-comment-id:5015880092 --> @SpicyMarinara commented on GitHub (Jul 19, 2026): Implementation will continue in draft PR #3814; the launcher fix is the next sweep slice.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 19, 2026):

Fixed in draft PR #3814. Both Unix launchers now wait for Node 24, extract only their allowlisted settings through Node dotenv parsing, and assign values without source or eval. Ambient values (including empty values) win. pnpm regression:issues passes with spaces, quotes, comments, literal $, literal command-substitution text, allowlisting, both launcher orderings, and Bash syntax covered.

<!-- gh-comment-id:5015895820 --> @SpicyMarinara commented on GitHub (Jul 19, 2026): Fixed in draft PR #3814. Both Unix launchers now wait for Node 24, extract only their allowlisted settings through Node dotenv parsing, and assign values without `source` or `eval`. Ambient values (including empty values) win. `pnpm regression:issues` passes with spaces, quotes, comments, literal `$`, literal command-substitution text, allowlisting, both launcher orderings, and Bash syntax covered.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 19, 2026):

Addressed in ready-for-review PR #3814. Unix launchers now parse only their allowlisted dotenv settings as inert data, preserve ambient-variable precedence, and never source or evaluate . Focused launcher regressions and the full local validation gate pass.

<!-- gh-comment-id:5015944936 --> @SpicyMarinara commented on GitHub (Jul 19, 2026): Addressed in ready-for-review PR #3814. Unix launchers now parse only their allowlisted dotenv settings as inert data, preserve ambient-variable precedence, and never source or evaluate . Focused launcher regressions and the full local validation gate pass.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 19, 2026):

Correction for the close note: Unix launchers now parse only their allowlisted dotenv settings as inert data, preserve ambient-variable precedence, and never source or evaluate .env. Focused launcher regressions and the full local validation gate pass.

<!-- gh-comment-id:5015946247 --> @SpicyMarinara commented on GitHub (Jul 19, 2026): Correction for the close note: Unix launchers now parse only their allowlisted dotenv settings as inert data, preserve ambient-variable precedence, and never source or evaluate `.env`. Focused launcher regressions and the full local validation gate pass.
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#2056
No description provided.