Skip to content
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

add-mask is leaking a secret in master if debug or ::echo::on is set #158

Merged
merged 4 commits into from
Nov 4, 2019

Conversation

thboop
Copy link
Collaborator

@thboop thboop commented Oct 30, 2019

If debug variable is set or echo::on is used, add-mask will echo before the secret is registered and it will leak the secret. This bug did not ship and was caught in the release branch

Resolves #159, #157

@thboop thboop changed the title Output after processing command to avoid leaking mask Avoid Echoing add-mask command Oct 30, 2019
}

context.Error($"Unable to process command '{input}' successfully.");
var commandInformation = extension.OmitEcho ? extension.Command : input;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the omit echo command crashes or otherwise fails, we should only log the command name not the entire command

@@ -404,6 +405,7 @@ private static class RemoveMatcherCommandProperties
public sealed class DebugCommandExtension : RunnerService, IActionCommandExtension
{
public string Command => "debug";
public bool OmitEcho => false;
Copy link
Collaborator Author

@thboop thboop Oct 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug, Error, and Warning could be a candidate for ignoring echos (as they did previously), but they are commands and I feel like they should have both their command echo and their outputs appear in the logs.

The ADR specified all commands would work the same way, but we are breaking that for add-mask at the moment due to the security concerns.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bryanmacfarlane to weigh in

We should skip echo for debug, otherwise every debug statement gets written twice. It hinders debugging because the log is noisy and harder to read.

I would follow the same pattern for warning/error. Otherwise the message is written to the log twice. Looks silly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Eric

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@juliobbv we will need to amend the ADR for consistency sake, we can link this discussion

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericsciple , this has been updated, can you take a look?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thboop I'll amend the ADR to reflect the add-mask, issue-command, and debug command logging behavior changes.

@bryanmacfarlane bryanmacfarlane changed the title Avoid Echoing add-mask command add-mask is leaking a secret in master if debug or ::echo::on is set Nov 4, 2019
@thboop thboop changed the base branch from master to releases/m160 November 4, 2019 14:34
@thboop thboop force-pushed the users/thboop/OutputAfterProcessingCommand branch from 8b920aa to 28ea219 Compare November 4, 2019 14:35
@bryanmacfarlane
Copy link
Member

Let's make sure this goes to master as well

@thboop thboop merged commit 3ba55f8 into releases/m160 Nov 4, 2019
@thboop thboop deleted the users/thboop/OutputAfterProcessingCommand branch November 4, 2019 19:31
thboop added a commit that referenced this pull request Nov 11, 2019
…158)

* Output after processing command to avoid leaking mask

* Remove extra noise output from echo changes

* Omit Echoing of add-mask command

* avoid echoing on debug/warning/error
AdamOlech pushed a commit to antmicro/runner that referenced this pull request Jan 28, 2021
…ctions#158)

* Output after processing command to avoid leaking mask

* Remove extra noise output from echo changes

* Omit Echoing of add-mask command

* avoid echoing on debug/warning/error
@lurbanski-equinix
Copy link

lurbanski-equinix commented Nov 25, 2022

The bug is live in situation when the ::add-mask:: is the first command in a step, then the command is showed. If the command is in second and so on lines, then it is correctly not shown.
And command with secret is shown when command from step are expanded.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants