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

daemon: error out when using drkey endpoints without configured drkey #4453

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

rohrerj
Copy link
Contributor

@rohrerj rohrerj commented Dec 6, 2023

I found a bug in the SCION daemon. If you create a SCION daemon connection and call one of the drkey endpoints without first setting the configuration value "drkey_level2_db.Connection" to something meaningful, the SCION daemon will encounter an error like that and crash:

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

This bug can easily be reproduced by running a code snippet like this for a SCION daemon that has no drkey configured:

sd, _ := daemon.NewService(daemonAddr).Connect(ctx)
sd.DRKeyGetASHostKey(ctx, drkey.ASHostMeta{})

The problem is that in the file "daemon/internal/servers/grpc.go", when the drkey endpoints are called, DaemonServer.DRKeyClient is nil if it is not configured as described above.


This change is Reviewable

Copy link
Contributor

@matzf matzf left a comment

Choose a reason for hiding this comment

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

Thanks! :lgtm:

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @rohrerj)

@matzf matzf changed the title scion-daemon: crash when using drkey endpoints without configured drkey daemon: error out when using drkey endpoints without configured drkey Dec 7, 2023
@matzf matzf merged commit 85b8a13 into scionproto:master Dec 7, 2023
4 checks passed
juagargi pushed a commit to netsec-ethz/scion that referenced this pull request Mar 8, 2024
…scionproto#4453)

I found a bug in the SCION daemon. If you create a SCION daemon connection and call one of the drkey endpoints without first setting the configuration value "drkey_level2_db.Connection" to something meaningful, the SCION daemon will encounter an error like that and crash:
```
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xb82d33]
```
This bug can easily be reproduced by running a code snippet like this for a SCION daemon that has no drkey configured:
```
sd, _ := daemon.NewService(daemonAddr).Connect(ctx)
sd.DRKeyGetASHostKey(ctx, drkey.ASHostMeta{})
```
The problem is that in the file "daemon/internal/servers/grpc.go", when the drkey endpoints are called, DaemonServer.DRKeyClient is nil if it is not configured as described above.

Fixed by explicitly checking whether DRKey is available and erroring out if it is not.
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.

2 participants