-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
feat(api): redact secrets in logs. Fixes #8685 #9859
feat(api): redact secrets in logs. Fixes #8685 #9859
Conversation
Signed-off-by: Anil Kumar <[email protected]>
Signed-off-by: Anil Kumar <[email protected]>
dfbc009
to
dc5e925
Compare
Signed-off-by: Anil Kumar <[email protected]>
Signed-off-by: Anil Kumar <[email protected]>
@alexec @terrytangyuan Can one of you review the changes? |
Signed-off-by: Anil Kumar <[email protected]>
Signed-off-by: Anil Kumar <[email protected]>
Signed-off-by: Anil Kumar <[email protected]>
This is cool. I wonder if it can be even smarter? E.g. auto-detect secrets using a regex? |
@alexec while the idea to auto-detect the secrets is nice, secrets are something user configurable and they can be literally anything. I believe it would be difficult to have a regex to identify all possible secrets. Do you have any references in mind? Please share your thoughts. |
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.
I tested how Github Action hides the secret
from the result, I think this is exaclty how it's done.
string replace rather than any regex.
(e.g. if I echo "text same as secret", it will hide it, if I remove 1 char from it, it will show)
Signed-off-by: Anil Kumar <[email protected]>
Signed-off-by: Anil Kumar <[email protected]>
docs/environment-variables.md
Outdated
@@ -22,6 +22,7 @@ most users. Environment variables may be removed at any time. | |||
| `ARGO_AGENT_PATCH_RATE` | `time.Duration` | `DEFAULT_REQUEUE_TIME` | Rate that the Argo Agent will patch the workflow task-set. | | |||
| `ARGO_AGENT_CPU_LIMIT` | `resource.Quantity` | `100m` | CPU resource limit for the agent. | | |||
| `ARGO_AGENT_MEMORY_LIMIT` | `resource.Quantity` | `256m` | Memory resource limit for the agent. | | |||
| `ARGO_REDACT_POD_LOGS` | `bool` | `false` | Whether to redact pod logs to hide/mask secrets. | |
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.
I think this should be turned on by default.
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.
Although I am not sure if we should turn on new features by default. WDYT? @sarabala1979 @alexec
// get env variable for pod logs redaction | ||
enablePodLogRedaction := os.Getenv("ARGO_REDACT_POD_LOGS") | ||
// get secrets for redaction | ||
secrets, err := kubeClient.CoreV1().Secrets(req.GetNamespace()).List(ctx, metav1.ListOptions{}) |
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.
I don't think we want to list all the secrets. See #8534
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.
@terrytangyuan I can see the GetSecret method is available but it requires the service account name and we can only fetch the secrets associated with a service account using this method.
One approach is using Service account Lister to get all the service accounts and fetch the secrets of each SA using above mentioned GetSecret method. Although we might not have all the secrets with this approach.
Can you suggest any other alternate approaches?
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.
@terrytangyuan @anilkumar-pcs
I'd like to resolve #8685 but I don't have any better idea then
- list secrets and keep then in cache or queue
- when command like "echo" or "export", check command if they include one of those secrets
- hide secrets
but I think those feature make large burden on argo-workflows....
any suggestion on this??
Signed-off-by: Anil Kumar <[email protected]>
Signed-off-by: Anil Kumar <[email protected]>
Signed-off-by: Anil Kumar <[email protected]>
Signed-off-by: Anil Kumar <[email protected]>
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.
I don't think this is the right approach. It moves responsibly for secret redaction from the user to the operator, yet it is the user's fault secrets are being logged.
I'd be amenable to a redaction that was zero-configuration. Github Actions automatically redacts secrets for example.
Signed-off-by: Anil Kumar <[email protected]>
@alexec made changes to remove the env configuration and masking secrets by default. |
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.
Server should/does not have list secrets
permission. So this should/will not work. Instead, I think some research into "how to mask secrets" in logs is needed.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a mentoring request, please provide an update here. Thank you for your contributions. |
This issue has been closed due to inactivity. Feel free to re-open if you still encounter this issue. |
where @anilkumar-pcs |
Per above, this approach has security ramifications. This approach also only affects the logs API. |
Fixes #8685
FIlter and mask secrets in workflow logs.
Logs when running
examples/secrets.yaml
workflow with no redactionLogs when running
examples/secrets.yaml
workflow with redaction enabledPlease do not open a pull request until you have checked ALL of these:
make pre-commit -B
to fix codegen and lint problems.If changes were requested, and you've made them, dismiss the review to get it reviewed again.