-
-
Notifications
You must be signed in to change notification settings - Fork 0
Use PHP Matrix v1; Switch to composite action #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
working-directory: ${{ github.action_path }} | ||
|
||
- name: Add the binary into PATH | ||
run: echo "${ACTION_PATH}/bin" >> "$GITHUB_PATH" |
Check warning
Code scanning / CodeQL
PATH environment variable built from user-controlled sources
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 6 days ago
To mitigate the risk, ensure the path added to $GITHUB_PATH
cannot be manipulated by external or untrusted actors. The best method is to sanitize or validate ${ACTION_PATH}
before use. Since ${{ github.action_path }}
points to the location of the action's code (which may come from attacker-controlled repositories in some contexts), hardcoding trusted paths is preferred. However, if the binary must reside in the action path, validate that ${ACTION_PATH}
matches an expected trusted base path before appending it to $GITHUB_PATH
. At minimum, ensure the path does not contain dangerous characters (such as newlines, spaces, shell metacharacters), and that it is an absolute path under a safe parent directory.
Since only the snippet from action.yml is shown and shell commands are used, the most robust approach within the limitation of bash is to check the path prior to echoing. Insert a check ensuring ${ACTION_PATH}
is absolute and does not contain suspicious characters. If validation fails, abort the workflow safely.
Specifically, replace the run line at line 99 with a script that:
- Verifies
${ACTION_PATH}
:- Is an absolute path (
[[ $ACTION_PATH = /* ]]
) - Does not contain dangerous characters using a regex (e.g., no whitespace, no semicolon, no newline).
- Is an absolute path (
- Optionally, restrict it to a specific safe base directory if known.
If it passes, echo${ACTION_PATH}/bin
into$GITHUB_PATH
; else, error and abort.
No additional imports/dependencies are required for bash.
-
Copy modified lines R99-R106
@@ -96,7 +96,14 @@ | ||
working-directory: ${{ github.action_path }} | ||
|
||
- name: Add the binary into PATH | ||
run: echo "${ACTION_PATH}/bin" >> "$GITHUB_PATH" | ||
run: | | ||
if [[ ! "$ACTION_PATH" =~ ^/ ]]; then | ||
echo "::error::ACTION_PATH is not an absolute path"; exit 1 | ||
fi | ||
if [[ "$ACTION_PATH" =~ [[:space:];`$"\\\]] ]]; then | ||
echo "::error::ACTION_PATH contains invalid characters"; exit 1 | ||
fi | ||
echo "${ACTION_PATH}/bin" >> "$GITHUB_PATH" | ||
shell: bash | ||
env: | ||
ACTION_PATH: ${{ github.action_path }} |
c2def56
to
ca2f22a
Compare
ca2f22a
to
1c500ef
Compare
1c500ef
to
97a2d27
Compare
No description provided.