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

feat: Implement pluggable password generator #2659

Merged
merged 1 commit into from
Sep 24, 2020
Merged

feat: Implement pluggable password generator #2659

merged 1 commit into from
Sep 24, 2020

Conversation

bnevis-i
Copy link
Collaborator

Remove dependency on GoKey for password generator;
if not specified, the built-in password generator
does the equivalent of "openssl rand -base64 33"
which generates a base64 encoded random string
of 264 random bits.

Otherwise, the code looks for a PasswordProvider
in configuration that points to an executable,
and PasswordProviderArgs that specify the
arguments to that executable. The code then
launches that exectuable, trims the trailing
newline, and uses the result as a password.

Signed-off-by: Bryon Nevis bryon.nevis@intel.com

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit subject follows the Conventional Commits spec
  • The commit message follows the EdgeX Contributor Guide
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • make test has completed successfully

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Current functionality uses Vault root token and database name to feed into GoKey password generator. The GoKey password generator was never fully vetted for this purpose before being introduced. Community would like a pluggable password generator rather than forcing use of Gokey

Issue Number:

Fixes #1946

What is the new behavior?

Remove dependency on GoKey for password generator;
if not specified, the built-in password generator
does the equivalent of "openssl rand -base64 33"
which generates a base64 encoded random string
of 264 random bits.

Otherwise, the code looks for a PasswordProvider
in configuration that points to an executable,
and PasswordProviderArgs that specify the
arguments to that executable. The code then
launches that exectuable, trims the trailing
newline, and uses the result as a password.

Does this PR introduce a breaking change?

  • Yes
  • No

Are there any new imports or modules? If so, what are they used for and why?

Are there any specific instructions or things that should be known prior to reviewing?

Other information

While doing research, although openssl is a commonly installed dependency (though by no means guaranteed to there in a minimal container), the apg (automatic password generator) tool is only installed (in Ubuntu) by the Gnome packages. It is reasonable to assume that in a gui-less installation, that apg tool will not be available. Thus, no default external password generator is configured by default. Instead, the code simulates the output of openssl rand -base64 33

@bnevis-i bnevis-i added this to the Hanoi milestone Aug 10, 2020
internal/security/secretstore/execrunner.go Show resolved Hide resolved
internal/security/secretstore/execrunner_test.go Outdated Show resolved Hide resolved
internal/security/secretstore/password.go Show resolved Hide resolved
internal/security/secretstore/password_linux_test.go Outdated Show resolved Hide resolved
internal/security/secretstore/password_linux_test.go Outdated Show resolved Hide resolved
internal/security/secretstore/password_test.go Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Aug 11, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

lenny-goodell
lenny-goodell previously approved these changes Aug 11, 2020
Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@tonyespy tonyespy left a comment

Choose a reason for hiding this comment

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

Overall, looks pretty good to me, but a few comments inline.

Also what happened to PasswordGeneratorContextOption from the issue? Why did this get dropped?

You also get a prize from dropping a dependency of edgex-go. Bravo!

cmd/security-secretstore-setup/res/configuration.toml Outdated Show resolved Hide resolved
internal/security/secretstore/execrunner.go Outdated Show resolved Hide resolved
internal/security/secretstore/execrunner.go Outdated Show resolved Hide resolved
internal/security/secretstore/execrunner.go Outdated Show resolved Hide resolved
func (p *PasswordProvider) SetConfiguration(passwordProvider string, passwordProviderArgs []string) error {
var err error
p.passwordProvider = passwordProvider
p.passwordProviderArgs = passwordProviderArgs
Copy link
Member

Choose a reason for hiding this comment

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

Should there be any validation of these strings (i.e. max length)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

PasswordProvider is validated by LookPath. ProviderArgs there is no obvious validation criteria. Also, since this is the password generation function, the input is implicitly trusted. (If the input can be forged, it can run pretty much anything.)

Copy link
Member

@tonyespy tonyespy Sep 24, 2020

Choose a reason for hiding this comment

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

OK, if you're OK with it, then I'll trust your judgement on this. The only reason I brought this up is because of the recent GRub2 BootHole vulnerability which involved buffer overruns involving the Grub2 config file...

Copy link
Member

@tonyespy tonyespy left a comment

Choose a reason for hiding this comment

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

Changing status so this doesn't get merged accidentally as there are still a few minor open issues.

@tonyespy
Copy link
Member

@mkbhanda we should try to avoid using github's merge from master, and leave this to the PR submitter to handle with 'git pull -r' (which uses rebase to pop-off the pending commits, rebases to latest HEAD, and re-applies the commits). Otherwise we end up with lots of identical "merge from master" commits in our git log.

Remove dependency on GoKey for password generator;
if not specified, the built-in password generator
does the equivalent of "openssl rand -base64 33"
which generates a base64 encoded random string
of 264 random bits.

Otherwise, the code looks for a PasswordProvider
in configuration that points to an executable,
and PasswordProviderArgs that specify the
arguments to that executable.  The code then
launches that exectuable, trims the trailing
newline, and uses the result as a password.

Signed-off-by: Bryon Nevis <bryon.nevis@intel.com>
@sonarcloud
Copy link

sonarcloud bot commented Sep 24, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@bnevis-i
Copy link
Collaborator Author

Rebased and squashed fixup commits. Can @tonyespy please re-review?

Copy link
Member

@tonyespy tonyespy left a comment

Choose a reason for hiding this comment

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

Thanks for the changes, LGTM now.

@bnevis-i bnevis-i merged commit ff532ad into edgexfoundry:master Sep 24, 2020
@bnevis-i bnevis-i deleted the issue-1946 branch September 24, 2020 18:50
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.

Pluggable random database password generation
3 participants