fix: enforce 0600 permissions on .netrc credentials file

The previous use of `touch` before `netrc set` allowed the file to inherit the umask and be world-readable, exposing stored git credentials to local users. The set and unset paths now explicitly chmod 0600 and chown to the dokku user, and the plugin install hook repairs permissions on already-affected installations.
This commit is contained in:
Jose Diaz-Gonzalez
2026-05-09 12:22:17 -04:00
parent 2974830e8f
commit 6eb8b8632c
3 changed files with 96 additions and 2 deletions

View File

@@ -14,6 +14,17 @@ trigger-git-install() {
fn-plugin-property-setup "git"
migrate_git_vars_0_12_0 "$@"
migrate_netrc_permissions "$@"
}
migrate_netrc_permissions() {
declare desc="enforces 0600 permissions on a pre-existing .netrc from older dokku versions"
local netrc_file="${DOKKU_ROOT}/.netrc"
[[ ! -f "$netrc_file" ]] && return 0
chmod 600 "$netrc_file"
chown "${DOKKU_SYSTEM_USER}:${DOKKU_SYSTEM_GROUP}" "$netrc_file"
}
migrate_git_vars_0_12_0() {