Skip to content

Commit b04bda5

Browse files
committed
add path traversal guard
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent fdfa978 commit b04bda5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

action.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,15 @@ runs:
172172
run: |
173173
SOURCE_PATH="$INPUT_INPUTS_PATH"
174174
[[ "$SOURCE_PATH" != /* ]] && SOURCE_PATH="${WORKSPACE}/$SOURCE_PATH"
175+
176+
# Prevent path traversal outside the workspace
177+
REAL_SOURCE=$(realpath -m "$SOURCE_PATH")
178+
REAL_WORKSPACE=$(realpath "$WORKSPACE")
179+
if [[ "$REAL_SOURCE" != "$REAL_WORKSPACE"* ]]; then
180+
echo "::error::inputs-path resolves outside the workspace. Aborting."
181+
exit 1
182+
fi
183+
175184
DESTINATION_PATH="${PROJECT_WORK_DIRECTORY}/input/"
176185
mkdir -p "$DESTINATION_PATH"
177186

0 commit comments

Comments
 (0)