fix: Split SSH gateway key into separate host and user keys#351
fix: Split SSH gateway key into separate host and user keys#351minhtule wants to merge 4 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #351 +/- ##
==========================================
- Coverage 86.07% 85.94% -0.14%
==========================================
Files 40 40
Lines 2830 2832 +2
==========================================
- Hits 2436 2434 -2
- Misses 269 272 +3
- Partials 125 126 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR addresses Issue #350 by reducing key-compromise blast radius in the SSH gateway: it replaces the single shared gateway keypair with two distinct keypairs—one for host certificates (downstream) and one for user certificates (upstream).
Changes:
- Split the gateway keypair into separate host and user signers/public keys in
Config. - Generate independent host/user keypairs during config initialization.
- Extend
NewConfigunit test coverage to assert the two keys are distinct.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/sshhandler/config.go | Replaces shared gateway key material with separate host/user keys and wires them into downstream/upstream certificate flows. |
| internal/sshhandler/config_test.go | Adds assertions ensuring host and user keys are both generated and distinct. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| gatewaySigner, gatewayPublicKey, err := keyConfig{ | ||
| typ: keyType, | ||
| bits: sshCfg.Gateway.Key.Bits, | ||
| }.Generate(rand.Reader) |
There was a problem hiding this comment.
There is an existing bug that is also fixed with this change: the old code constructs keyConfig instance directly instead of using the constructor newKeyConfig. As such, key type in SSH format like ssh-ed25519 is treated as error.
| // Apply defaults for Gateway's key config | ||
| keyType := keyType(sshCfg.Gateway.Key.Type) | ||
| if keyType == "" { | ||
| keyType = defaultKeyType |
There was a problem hiding this comment.
Move this default to newKeyConfig constructor because it's more appropriate and also testable.
Related Tickets & Documents
Changes