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 (update) #21510

Merged
merged 1 commit into from
Jul 3, 2024
Merged

Conversation

kkzo
Copy link
Contributor

@kkzo kkzo commented Jul 3, 2024

Updated checkServiceExistsOnRemoteServer to ensure there are services returned from the specified node before proceeding with the service matcher.

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

Fixes #21339

Testing & Reproduction steps

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

Links

#21339

PR Checklist

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

Updated `checkServiceExistsOnRemoteServer` to ensure there are services
returned from the specified node before proceeding with the service
matcher.
Copy link

hashicorp-cla-app bot commented Jul 3, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

CLA assistant check

Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement

Learn more about why HashiCorp requires a CLA and what the CLA includes

Have you signed the CLA already but the status is still pending? Recheck it.

@kkzo kkzo mentioned this pull request Jul 3, 2024
4 tasks
@dduzgun-security dduzgun-security added pr/no-changelog PR does not need a corresponding .changelog entry backport/all Apply backports for all active releases per .release/versions.hcl labels Jul 3, 2024
@dduzgun-security
Copy link
Collaborator

@kkzo thanks a lot for your contribution to fix this panic call. Once the Contribution License Agreement is signed and the tests are 🟢, we should be good to merge.

@dduzgun-security dduzgun-security merged commit 88bade6 into hashicorp:main Jul 3, 2024
95 of 98 checks passed
@hc-github-team-consul-core hc-github-team-consul-core added backport/1.19 This release series is longer active on CE, use backport/ent/1.19 backport/ent/1.17 This release series is longer active on CE or Ent backport/ent/1.15 Changes are backported to 1.15 ent backport/ent/1.18 Changes are backported to 1.18 ent labels Jul 3, 2024
jmurret pushed a commit that referenced this pull request Jul 8, 2024
Updated `checkServiceExistsOnRemoteServer` to ensure there are services
returned from the specified node before proceeding with the service
matcher.
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 This release series is longer active on CE or Ent backport/ent/1.18 Changes are backported to 1.18 ent backport/1.19 This release series is longer active on CE, use backport/ent/1.19 pr/no-changelog PR does not need a corresponding .changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants