-
Notifications
You must be signed in to change notification settings - Fork 60
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
[Bug fix] Prevent exposing API key secret in stdout logging #270
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one. Should do what it says on the tin.
I'd like to have a discussion around the pull request template before we merge that in.
Also, I'd like to see us fix up the issues around the "not catching all the permutations" that we spotted on the way.
.github/pull_request_template.md
Outdated
@@ -0,0 +1,41 @@ | |||
# Background |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be done as a separate PR... I think there's discussion we want to have around it first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, we can leave that to another PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah woops - just a heads up on this - I intended to provide a barebones template. Its updated now to that, but I will strip this out into a separate PR momentarily. 👍
fec5730
to
76cb9d1
Compare
29a1ec8
to
50e2c8c
Compare
@@ -1278,6 +1278,5 @@ function Register-Tentacle { | |||
$registerArguments += @("--tenanted-deployment-participation", $TenantedDeploymentParticipation) | |||
} | |||
|
|||
Write-Verbose "Registering with arguments: $registerArguments" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the main fix - this line is redundant and doesn't pass the arguments through the scrubber.
@@ -158,41 +158,45 @@ Function Get-MaskedOutput | |||
[CmdletBinding()] | |||
param($arguments) | |||
|
|||
$reg = [System.Text.RegularExpressions.RegEx]::new("--masterkey|--password|--license", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We felt it was prudent to improve the logic around the masking function. Note the edge case clause (the else block).
} | ||
|
||
function Invoke-OctopusServerCommand ($cmdArgs) { | ||
# todo: fix this up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rewriting the function masker helped make it clear that much of this code was redundant, so it has been removed. Args provided to a call to Write-Verbose (or other logging) should always be passed through the masking function.
README.md
Outdated
@@ -24,7 +24,7 @@ Version 3.0 of OctopusDSC supports Octopus Deploy 4.x and above with backwards c | |||
## Installation | |||
|
|||
### [PowerShellGet](https://technet.microsoft.com/en-us/library/dn807169.aspx) / PowerShell 5 (recommended) | |||
1. Install PowerShellGet from [PowerShell Gallery](https://www.powershellgallery.com/GettingStarted) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the guide, I noticed some of these links no longer work. (the vagrant.io tried to open from within the github domain).
We could consider a little more detail concerning TeamCity env variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Nice one - great to see some TODO
comments disappear.
Is there any way to detect if we've been affected by this bug? ...or is it simpler to just change the API key? |
You'd have to use the audit log to review changes made via that api key. |
@paulegradie Sorry for the late question, but what are the default permissions for where this was logged? Is this a proactive "just in case" fix and the file was e.g. 600 or equiv, or was the file world-readable? Thanks! |
Background
A customer revealed to us that we are exposing an api key secret during a call to
Write-Verbose
in one of our configuration scripts forcTentancleAgent
. This was due to a redundant bit of logging that was not passed through our secret scrubber functionGet-MaskedOutput
. Removing the logging line resolves this problem while leaving the masked logging in tact.Results
Duplicate logging no longer occurs.
How to review this PR
We current provide test coverage on the methods used to mask outputs, however we do not text stdout via assent.
This issue has been reported to the School Security for their ongoing secrets related investigations.