Skip to content

fix(security): harden command injection, path traversal & auth surfaces - #3018

Open
7feilee wants to merge 2 commits into
whyour:developfrom
7feilee:security/harden-injection-traversal-auth
Open

fix(security): harden command injection, path traversal & auth surfaces#3018
7feilee wants to merge 2 commits into
whyour:developfrom
7feilee:security/harden-injection-traversal-auth

Conversation

@7feilee

@7feilee 7feilee commented Jun 22, 2026

Copy link
Copy Markdown

What

Hardens the backend against the web-reachable injection / traversal / auth issues found in a defensive attack-surface audit. Adds back/shared/security.ts with centralized helpers (shellEscape, assertSafeDependenceName, SUBSCRIPTION_PATTERNS, safeCompare, isSafeSshConfigValue).

Fixes

Severity Issue Fix
CRITICAL OS command injection via subscription url/branch/whitelist/blacklist/extensions/proxy reaching spawn(...,{shell}) shell-escape every value + strict Joi patterns at the API
CRITICAL Command injection via dependency name (pnpm/pip/apk/apt + embedded Python) validate name before interpolation
HIGH SSH ProxyCommand/host injection (services/sshKey.ts) reject newline/metachars; proxy must be host:port
HIGH Path traversal read — data/scripts/../db/database.sqlite leaked the SQLite DB resolve real path, then enforce containment
HIGH Arbitrary file write/RCE via multer originalname (overwrite crontab.list/env.sh) path.basename, reject ./..
MEDIUM /configs/save sibling-dir write bypass path.sep containment check
CRITICAL (config) Default JWT secret whyour-secret → forgeable admin tokens generate + persist per-install secret; refuse default in production
HIGH Non-constant-time token comparison safeCompare (hash + timingSafeEqual)

The API-boundary validation also neutralizes the web-reachable shell eval/git-arg-injection paths downstream.

Notes

  • Behavior-preserving for legitimate inputs (escaping is transparent; patterns allow normal git URLs, branches, package names, host:port proxies). Security logic verified with standalone runtime tests.
  • Deferred hardening (plaintext passwords, open-API system scope, SSRF in notify, error-message leakage, rate-limit, self-update integrity) tracked in Security hardening follow-ups (deferred from injection/traversal/auth audit) #3017.

whyour and others added 2 commits June 21, 2026 23:53
Audit of the backend attack surface and fixes for the web-reachable
CRITICAL/HIGH issues. Adds back/shared/security.ts with centralized
hardening helpers (shellEscape, assertSafeDependenceName,
SUBSCRIPTION_PATTERNS, safeCompare, isSafeSshConfigValue).

- Subscription fields (url/branch/whitelist/blacklist/extensions/proxy)
  are now shell-escaped before reaching spawn() and validated with strict
  Joi patterns at the API, closing OS command injection and the
  downstream shell eval/git-arg-injection paths.
- Dependency names are validated before interpolation into
  pnpm/pip/apk/apt commands (incl. the embedded Python source).
- SSH config generation rejects newline/metachar injection in host/proxy
  (prevents injected ProxyCommand execution).
- ConfigService.getFile resolves the real path before containment check,
  fixing data/scripts/../db traversal that leaked the SQLite DB.
- /configs/save containment check fixed (sibling-dir write bypass).
- Script/env uploads use path.basename, preventing arbitrary file write
  (crontab.list/env.sh overwrite -> RCE) via multer originalname.
- JWT secret is generated and persisted per-install instead of the public
  default 'whyour-secret'; production refuses to boot without one.
- Token comparison is now constant-time (safeCompare).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

@7feilee is attempting to deploy a commit to the hunter wang's projects Team on Vercel.

A member of the Team first needs to authorize it.

@whyour
whyour force-pushed the develop branch 6 times, most recently from 953b68f to f09ef37 Compare July 1, 2026 16:10
@whyour
whyour force-pushed the develop branch 5 times, most recently from 509b0d0 to da6dac8 Compare July 9, 2026 17:43
@whyour
whyour force-pushed the develop branch 8 times, most recently from 152a9aa to 92e4f26 Compare July 24, 2026 14:34
@whyour
whyour force-pushed the develop branch 3 times, most recently from 9b37f06 to 0bb41eb Compare July 25, 2026 05:29
@whyour
whyour force-pushed the develop branch 2 times, most recently from de65d7f to 5f6049d Compare August 29, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants