fix(security): validate realpath result before LOG_DIR deletion in e2e.sh (#3225)
Some checks are pending
CLI Release / Build and release CLI (push) Waiting to run
Lint / ShellCheck (push) Waiting to run
Lint / Biome Lint (push) Waiting to run
Lint / macOS Compatibility (push) Waiting to run

Fixes #3222

Agent: security-auditor

Co-authored-by: B <6723574+louisgv@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
A 2026-04-07 17:43:34 -07:00 committed by GitHub
parent ad9da53210
commit 05fbb2ebdc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -702,7 +702,11 @@ final_cleanup() {
SAFE_TMP_ROOT="${SAFE_TMP_ROOT%/}"
# Resolve symlinks to prevent symlink-following attacks (#3194)
local resolved_log_dir
resolved_log_dir=$(realpath "${LOG_DIR}" 2>/dev/null || printf '%s' "${LOG_DIR}")
resolved_log_dir=$(realpath "${LOG_DIR}" 2>/dev/null)
if [ -z "${resolved_log_dir}" ]; then
log_warn "Failed to resolve LOG_DIR path, skipping cleanup"
return
fi
# Verify ownership before deletion
if [ ! -O "${resolved_log_dir}" ]; then
log_warn "LOG_DIR not owned by current user, refusing deletion: ${resolved_log_dir}"