mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-18 23:51:40 +00:00
fix(security): validate realpath result before LOG_DIR deletion in e2e.sh (#3225)
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:
parent
ad9da53210
commit
05fbb2ebdc
1 changed files with 5 additions and 1 deletions
|
|
@ -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}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue