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

Fix verify_password gatherer for scenarios where there is not hash #305

Merged
merged 3 commits into from
Dec 12, 2023

Conversation

arbulu89
Copy link
Contributor

https://bugzilla.suse.com/show_bug.cgi?id=1217543

>  panic: runtime error: index out of range [2] with length 1
> 
> goroutine 264 [running]:
>  github.com/trento-project/agent/internal/factsengine/gatherers.(VerifyPasswordGatherer).getSalt(0xc000484030, {0xc0005ab5a0, 0x9})
>  github.com/trento-project/agent/internal/factsengine/gatherers/verifypassword.go:111 +0x21c
>  github.com/trento-project/agent/internal/factsengine/gatherers.(VerifyPasswordGatherer).Gather(0xc000484030?, {0xc00030f100, 0x1, 0x1?})
>  github.com/trento-project/agent/internal/factsengine/gatherers/verifypassword.go:68 +0x1e5
>  github.com/trento-project/agent/internal/factsengine.gatherFacts.func1()
>  github.com/trento-project/agent/internal/factsengine/gathering.go:44 +0xb9
>  golang.org/x/sync/errgroup.(Group).Go.func1()
>  golang.org/x/[[email protected]](mailto:[email protected])/errgroup/errgroup.go:75 +0x64
>  created by golang.org/x/sync/errgroup.(Group).Go
>  golang.org/x/[[email protected]](mailto:[email protected])/errgroup/errgroup.go:72 +0xa5

@arbulu89 arbulu89 added the bug Something isn't working label Nov 29, 2023
func (suite *PasswordTestSuite) TestPasswordGatherCryptError() {
shadow := []byte("hacluster:$aaaa$aaaa")
func (suite *PasswordTestSuite) TestPasswordGatherNotEncrypted() {
shadow := []byte("hacluster:!:19029::::::")
Copy link
Contributor

Choose a reason for hiding this comment

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

Hey @arbulu89, just wondering about this: why is the test name "...NotEncrypted"? seems to me it's more simply about the case where no password is set (rather than not encrypted).

Also, about the exclamation mark, I think an exclamation mark at the start of the field means simply "account disabled" while an exclamation mark in the content of the hash is an invalid hash (as it is an invalid character in this context)

Copy link
Contributor Author

@arbulu89 arbulu89 Nov 29, 2023

Choose a reason for hiding this comment

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

Yes, we could improve the naming of the test.
About what the ! means, based on this:
https://linuxize.com/post/etc-shadow-file/

If the password field contains an asterisk (*) or exclamation point (!), the user will not be able to login to the system using password authentication. Other login methods like key-based authentication or switching to the user are still allowed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I understand my doubts now, there is a "common practice" (even documented in man 5 shadow) that says that if you add a ! as the first character of a password it means "password disabled" but in reality, adding it anywhere will block the password anyways. So effectively, a password containing just ! or * means: "no password, and also no login allowed".

@CDimonaco CDimonaco marked this pull request as ready for review December 12, 2023 10:55
@CDimonaco CDimonaco self-assigned this Dec 12, 2023
Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

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

Sounds good 👍

@dottorblaster dottorblaster merged commit 97d2045 into main Dec 12, 2023
10 checks passed
@dottorblaster dottorblaster deleted the fix-verify-password-gatherer-no-pass branch December 12, 2023 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

4 participants