fix(settings): confine Traefik file read/write to the Traefik config directory - #5070
Open
bunlongheng wants to merge 1 commit into
Open
fix(settings): confine Traefik file read/write to the Traefik config directory#5070bunlongheng wants to merge 1 commit into
bunlongheng wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
settings.readTraefikFileandsettings.updateTraefikFiletRPC procedures pass a caller-supplied path straight to the filesystem helpers without confining it to the Traefik configuration directory. A user holding thetraefikFilespermission can therefore read or overwrite arbitrary files on the Dokploy host.traefikFiles(read/write) is a free-tier, member-grantable resource inaccess-control.ts, so this is not limited to owners/admins - a scoped member intended only to edit Traefik dynamic config files can escalate to full host file access.Vulnerable path
apps/dokploy/server/api/routers/settings.tsreadConfigInPath/writeTraefikConfigInPathonly callpath.join(pathFile), which does not restrict the location:The companion
readDirectoriesendpoint only ever lists files underMAIN_TRAEFIK_PATH(/etc/dokploy/traefik), so the read/write endpoints are meant to operate on that directory alone.Impact
A permitted user can supply an absolute path or
../traversal inpathto:/etc/dokploy/.env(database credentials, auth secret), SSH private keys, or any host file readable by the process.~/.ssh/authorized_keysor a cron/systemd unit), which can lead to further compromise.Fix
Resolve the requested path against
MAIN_TRAEFIK_PATHand reject anything that escapes that directory, in both the read and write procedures. Legitimate usage is unaffected because every path the UI can produce comes fromreadDirectories, which is already rooted atMAIN_TRAEFIK_PATH.Notes
serverId(remote) branch is validated with the same directory base used to render the file tree, so remote editing of legitimate Traefik files continues to work.Greptile Summary
The PR confines caller-supplied Traefik read and write paths to the appropriate local or remote Traefik configuration directory.
Confidence Score: 5/5
The PR appears safe to merge, with no concrete changed-code-triggered failures identified.
The new resolver uses the same server-aware Traefik base as directory listing, accepts the absolute in-tree paths produced by existing callers, rejects traversal and external absolute paths, and passes shell-quoted paths to the existing remote helpers.
Reviews (1): Last reviewed commit: "fix(settings): confine Traefik file read..." | Re-trigger Greptile
Context used: