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

Redact secrets in logArgv #511

Merged
merged 3 commits into from
Dec 12, 2024
Merged

Redact secrets in logArgv #511

merged 3 commits into from
Dec 12, 2024

Conversation

ecooper
Copy link
Contributor

@ecooper ecooper commented Dec 12, 2024

Problem

When we log argv via verbosity, we log secrets. This is probably fine, but we also want to avoid people accidentally posting secrets to github issues where they use verbosity to debug.

Solution

Add a custom stringify function that redacts the value of any key with secret or accountKey in it.

I think this is the only place we output secrets or keys.

Result

Screenshot 2024-12-11 at 4 40 21 PM

Testing

Added unit tests for redact and redactedStringify

@ecooper ecooper requested a review from a team as a code owner December 12, 2024 00:44
Comment on lines +11 to +13
if (text.length < 12) {
return "*".repeat(text.length);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

what is twelve based on? Is there some sort of algorithmic guarantee that 8 couldn't be brute force guessed?

I'd imagine there's some entropy number for that you could find on OWASP

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect. What i was looking for.

Comment on lines 15 to 17
const lastFour = text.slice(-4);
const redactedLength = text.length - 4;
return "*".repeat(redactedLength) + lastFour;
Copy link
Contributor

Choose a reason for hiding this comment

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

might be good to put some of the prefix in too as they can hint to us what type of key it is.

See: https://github.com/fauna/backup-restore-frontdoor/blob/main/src/auth/constants.ts

For some examples

Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly, i'd rather just do the prefix and redact all the rest. that way none of the random data is displayed. its just the envelope flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That won't help a user figure out what secret was used if it's not something they expect (such as an expected profile or env passing secret). How about for strings larger than 16, we keep the first and last 4 and redact the middle?

@echo-bravo-yahoo echo-bravo-yahoo merged commit 2071e2e into v3 Dec 12, 2024
4 checks passed
@echo-bravo-yahoo echo-bravo-yahoo deleted the v3-redact branch December 12, 2024 17:50
@cleve-fauna cleve-fauna mentioned this pull request Dec 13, 2024
@mwilde345 mwilde345 mentioned this pull request Dec 18, 2024
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.

4 participants