-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
exec.exec leaks action input parameters to subprocess #309
Comments
Toolkit exec for subprocesses has an optional arg to specify what the env dictionary looks like. https://github.com/actions/toolkit/blob/master/packages/exec/src/interfaces.ts#L10 However, it is an interesting question whether we should strip INPUT_ vars. Right now, it would have to be a blanket INPUT_ strip unless we loaded up the action yml |
I've used the Stripping all An alternative would be for @actions/core to remove the variables from |
I think it is a common case to use input for passing sensitive values like GitHub token. When using actions/exec for those actions, the sensitive values will be leaked to subprocesses. If subprocess really requires some // Assume some_command requires INPUT_FOO. Even in the case, the `env` value can set `INPUT_FOO` value.
await exec.exec('some_command', ['args'], {
env: {
INPUT_FOO: '...'
}
}); |
Closing since this issue is stale (limited initial activity, and none for a over a year). The current solution is to use If we do this change, we need to major version the toolkit since this would be a breaking change. Some folks likely rely on this behavior today - i.e. their logic is written in a different scripting language or even compiled binary (have seen this in the past). Note, inheriting the env dictionary is also the default of Node.js and common scripting languages (bash, sh, ps, cmd). OS default too |
Might be good to consider for the next major version |
Chatted w/ @luketomlinson and @thboop offline. Let's track for next major version. Reopening for now, feel free to close again after this is tracked for next version (or leave open depending on however you decide to track) |
Maybe add a boolean flag to |
@jhenstridge I think for the time being passing in an explicit |
I still feel changing the default behavior is safer since I cannot come up with the case where a subprocess utilizes In addition to changing the default behavior, I wander it might be nice to add an option to disable filtering out the variables from env object for some possible edge cases (meant filtering out can be opt-out). |
Describe the bug
As input parameters are passed to the action as environment variables, and exec() reuses the action's environment by default, this means the input parameters will probably be visible to the subprocess. If any secrets are being passed via parameters, they will be visible too.
To Reproduce
Steps to reproduce the behavior:
foo
await exec.exec('sh', ['-c', 'echo foo==$INPUT_FOO'])
Expected behavior
I would expect exec.exec() to strip input parameters from the environment used to run the subprocess by default. If there are cases where it is desirable to pass input parameters to the subprocess, this feels like it should be opt-in.
Add any other context about the problem here.
Additional context
While writing an action that took a login token for an online service as an input parameter, I was trying to be careful not to leak the secret: some commands I need to run have the secret passed via command line, and others don't need it. In retrospect it seems obvious that the secrets would be visible to all subprocesses through the environment variables, but it wasn't obvious from the toolkit documentation.
The text was updated successfully, but these errors were encountered: