Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion docker/runner-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,31 @@ run_runner_bash() {
env RUNNER_EXECUTION_MODE="${runner_exec_mode}" "$@" gosu runner bash -lc "${command}"
}

run_runner_job_bash() {
local command="$1"
shift || true

if [[ "${runner_exec_mode}" == "root" ]]; then
env \
-u GITHUB_PAT \
-u GITHUB_APP_ID \
-u GITHUB_APP_INSTALLATION_ID \
-u GITHUB_APP_PRIVATE_KEY \
Comment on lines +31 to +35

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep root-mode runner secrets out of parent processes

In root execution mode, this only removes the GitHub auth variables from the child ./run.sh environment; the entrypoint shell that started the pipeline still keeps its original environment while the runner is active. For supported root-mode runners such as RUNNER_EXEC_MODE_OVERRIDE=root on the Linux Docker plane or Synology root fallback, workflow processes also run as root and can read another root process's /proc/<pid>/environ, so they can still recover GITHUB_PAT or the App credentials despite this sanitization.

Useful? React with 👍 / 👎.

RUNNER_ALLOW_RUNASROOT=1 \
RUNNER_EXECUTION_MODE="${runner_exec_mode}" \
"$@" bash -lc "${command}"
return
fi

env \
-u GITHUB_PAT \
-u GITHUB_APP_ID \
-u GITHUB_APP_INSTALLATION_ID \
-u GITHUB_APP_PRIVATE_KEY \
RUNNER_EXECUTION_MODE="${runner_exec_mode}" \
"$@" gosu runner bash -lc "${command}"
}

cleanup_local_state() {
rm -f \
"${RUNNER_HOME}/.runner" \
Expand Down Expand Up @@ -254,5 +279,5 @@ runner_configured="true"
audit_event runner_registered

log "starting runner ${RUNNER_NAME}"
run_runner_bash "cd '${RUNNER_HOME}' && exec ./run.sh" \
run_runner_job_bash "cd '${RUNNER_HOME}' && exec ./run.sh" \
2>&1 | tee -a "${RUNNER_LOG_DIR}/runner.log"
1 change: 1 addition & 0 deletions scripts/smoke-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ run_smoke_case() {
grep -q -- "--runnergroup synology-private --ephemeral --disableupdate" "${state_dir}/config-invocations.log"
grep -q "config path: /tmp/runner-state/runner-home" "${state_dir}/config-context.log"
grep -q "run path: /tmp/runner-state/runner-home" "${state_dir}/run-context.log"
grep -q "github auth: unset" "${state_dir}/run-context.log"
grep -q "runner writable home: /tmp/runner-state/runner-home" "${runner_stdout}"
grep -q "^job output$" "${state_dir}/logs/runner.log"
grep -q "run.sh stub executed" "${state_dir}/run.log"
Expand Down
8 changes: 8 additions & 0 deletions scripts/smoke/actions-runner/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ set -euo pipefail
printf '%s run.sh stub executed\n' "$(date -Iseconds)" >> "${RUNNER_STATE_DIR}/run.log"
printf 'run path: %s\n' "$(pwd)" >> "${RUNNER_STATE_DIR}/run-context.log"
printf 'run mode: %s\n' "${RUNNER_EXECUTION_MODE:-unknown}" >> "${RUNNER_STATE_DIR}/run-context.log"
if [[ -n "${GITHUB_PAT:-}" \
|| -n "${GITHUB_APP_ID:-}" \
|| -n "${GITHUB_APP_INSTALLATION_ID:-}" \
|| -n "${GITHUB_APP_PRIVATE_KEY:-}" ]]; then
printf 'github auth leaked to run.sh\n' >> "${RUNNER_STATE_DIR}/run-context.log"
exit 1
fi
printf 'github auth: unset\n' >> "${RUNNER_STATE_DIR}/run-context.log"
mkdir -p "${RUNNER_WORK_DIR}/workspace"
touch "${RUNNER_WORK_DIR}/workspace/job.txt"
echo "job output"
Loading