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

security: fix AliasCheck panic #21339

Merged
merged 2 commits into from
Jun 14, 2024
Merged

Conversation

dduzgun-security
Copy link
Contributor

Description

Resolves the following

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x10370a28c]

goroutine 344 [running]:
[github.com/hashicorp/consul/agent/checks.(*CheckAlias).checkServiceExistsOnRemoteServer(0x140009f37c0](http://github.com/hashicorp/consul/agent/checks.(*CheckAlias).checkServiceExistsOnRemoteServer(0x140009f37c0), 0x140009f37d0)
        [github.com/hashicorp/consul/agent/checks/alias.go:164](http://github.com/hashicorp/consul/agent/checks/alias.go:164) +0x18c
[github.com/hashicorp/consul/agent/checks.(*CheckAlias).runQuery.func1(0x1](http://github.com/hashicorp/consul/agent/checks.(*CheckAlias).runQuery.func1(0x1)?)
        [github.com/hashicorp/consul/agent/checks/alias.go:237](http://github.com/hashicorp/consul/agent/checks/alias.go:237) +0x28
[github.com/hashicorp/consul/agent/checks.(*CheckAlias).processChecks(0x140009f37c0](http://github.com/hashicorp/consul/agent/checks.(*CheckAlias).processChecks(0x140009f37c0), {0x0, 0x0, 0x1057baa22?}, 0x140010dff48)
        [github.com/hashicorp/consul/agent/checks/alias.go:284](http://github.com/hashicorp/consul/agent/checks/alias.go:284) +0x36c
[github.com/hashicorp/consul/agent/checks.(*CheckAlias).runQuery(0x140009f37c0](http://github.com/hashicorp/consul/agent/checks.(*CheckAlias).runQuery(0x140009f37c0), 0x0?)
        [github.com/hashicorp/consul/agent/checks/alias.go:236](http://github.com/hashicorp/consul/agent/checks/alias.go:236) +0x29c
[github.com/hashicorp/consul/agent/checks.(*CheckAlias).run(0x0](http://github.com/hashicorp/consul/agent/checks.(*CheckAlias).run(0x0)?, 0x0?)
        [github.com/hashicorp/consul/agent/checks/alias.go:89](http://github.com/hashicorp/consul/agent/checks/alias.go:89) +0x58
created by [github.com/hashicorp/consul/agent/checks.(*CheckAlias).Start](http://github.com/hashicorp/consul/agent/checks.(*CheckAlias).Start) in goroutine 342
        [github.com/hashicorp/consul/agent/checks/alias.go:64](http://github.com/hashicorp/consul/agent/checks/alias.go:64) +0x15c
</excerpt>

Testing & Reproduction steps

curl --request PUT --data '{"name": "a", "check": {"AliasNode": "doesnotexist"}}' http://127.0.0.1:8500/v1/agent/service/register

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

@dduzgun-security dduzgun-security added backport/all Apply backports for all active releases per .release/versions.hcl theme/security labels Jun 14, 2024
Copy link
Member

@sarahalsmiller sarahalsmiller 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 grabbing this

@dduzgun-security dduzgun-security merged commit 7a19d2e into main Jun 14, 2024
99 of 100 checks passed
@dduzgun-security dduzgun-security deleted the security/fix-checkalias-panic branch June 14, 2024 15:03
@hc-github-team-consul-core hc-github-team-consul-core added backport/1.19 Changes are backported to 1.19 backport/ent/1.17 Changes are backported to 1.17 ent backport/ent/1.15 Changes are backported to 1.15 ent backport/ent/1.18 Changes are backported to 1.18 ent labels Jun 14, 2024
@kkzo
Copy link
Contributor

kkzo commented Jul 3, 2024

Thanks for the quick fix @dduzgun-security

@kkzo
Copy link
Contributor

kkzo commented Jul 3, 2024

Unfortunately the fix did not help. I created #21510 for review which does avoid the panic by checking for returned services from the target node before proceeding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/all Apply backports for all active releases per .release/versions.hcl backport/ent/1.15 Changes are backported to 1.15 ent backport/ent/1.17 Changes are backported to 1.17 ent backport/ent/1.18 Changes are backported to 1.18 ent backport/1.19 Changes are backported to 1.19 theme/security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants