Commit Graph
11 Commits
Author SHA1 Message Date
Maxim Shulga c15763d9f8 Stop server-provided values from reaching a shell or escaping /dsc/seafile
Commands were joined into a string and passed to "su -c", so a login shell
parsed every interpolated value. A library name is chosen on the server, and
"sync -d /dsc/seafile/<name>" put it straight into that string: a library
named 'Docs; touch /tmp/pwned; #' ran as an arbitrary command. Confirmed
against the built image before and after this change.

Every command is now an argument list executed by "runuser --", which execs
directly with no shell. runuser -u sets the same HOME and a PATH that still
finds the seaf-cli wrapper, so the daemon environment is unchanged.

The password no longer needs its surrounding quotes, which also fixes
passwords containing quotes, dollar signs, and backticks.

Library names are untrusted, so dsc/paths.py reduces each one to a single
path component and proves the result stays under the libraries directory
with symlinks resolved. Empty, ".", "..", and names containing a separator
are skipped with a warning; names that would collide are suffixed with their
library ID rather than sharing a directory.

Tests cover quotes, command substitutions, separators, newlines, absolute
paths, parent traversal, Unicode, and colliding names. They run in a separate
CI job so application failures stay distinguishable from packaging failures.
2026-08-02 16:53:19 -07:00
Maxim ShulgaandClaude Opus 5 2126808cee Trim the build context and drop unused imports
Add a .dockerignore that whitelists only requirements.txt, start.py and
dsc/. The build context previously included .git, .idea, __pycache__ and
any local .env, which slowed builds and put a secrets file within reach
of any future COPY of the whole tree.

Remove the unused urlparse import from dsc/client.py and the redundant
import os.path from start.py; importing os already binds os.path.

Record both in IMPROVEMENTS.md, including the part still outstanding:
binutils and squashfs-tools remain in the runtime image because the
AppImage is unpacked in the same stage.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-02 16:23:04 -07:00
snegov 452c29ac95 Add DELETE_CONFIRM_THRESHOLD option 2023-10-20 17:32:34 -07:00
snegov 7f39e0f271 Initialize seafile client during container start 2023-09-16 01:27:46 -07:00
snegov 724166b4a4 Support library names in configuration 2022-01-30 18:27:37 +03:00
snegov 4dcac70520 Removed DATA_DIR environment variable 2021-02-28 23:26:04 +03:00
snegov e35cf0efa5 Fix incorrect schema issue 2020-08-25 21:17:34 +03:00
snegov c72727b9a0 Fix circular dependencies 2019-12-05 15:58:11 +03:00
snegov 107bb55082 Move SeafileClient out of main file 2019-09-06 21:41:52 +03:00
snegov 0e4583d3af Add current sync info to log 2019-08-13 22:38:00 +03:00
snegov 40827f413f rewrite start script in python 2019-04-14 12:34:20 +03:00