Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions core/capabilities/confidentialrelay/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,14 @@ type Handler struct {
// validateAttestation validates TEE attestation documents.
// Defaults to the Nitro validator; overridden in tests.
validateAttestation attestationValidatorFunc
limitsFactory limits.Factory
// trustEnclaves relaxes attestation validation for fake (non-Nitro)
// enclaves. INSECURE; test-only. When set, the custom-CA-roots validation
// path is skipped in favour of validateAttestation (the accept-all func).
trustEnclaves bool
limitsFactory limits.Factory
}

func NewHandler(capRegistry core.CapabilitiesRegistry, conn core.GatewayConnector, responseSigner relayResponseSigner, lggr logger.Logger, lf limits.Factory) (*Handler, error) {
func NewHandler(capRegistry core.CapabilitiesRegistry, conn core.GatewayConnector, responseSigner relayResponseSigner, lggr logger.Logger, lf limits.Factory, trustEnclaves bool) (*Handler, error) {
if responseSigner == nil {
return nil, errors.New("response signer is required")
}
Expand All @@ -124,13 +128,20 @@ func NewHandler(capRegistry core.CapabilitiesRegistry, conn core.GatewayConnecto
return nil, fmt.Errorf("failed to create metrics: %w", err)
}

named := logger.Named(lggr, HandlerName)
validate := nitro.ValidateAttestation
if trustEnclaves {
validate = func(_, _, _ []byte) error { return nil }
}

h := &Handler{
capRegistry: capRegistry,
gatewayConnector: conn,
responseSigner: responseSigner,
lggr: logger.Named(lggr, HandlerName),
lggr: named,
metrics: m,
validateAttestation: nitro.ValidateAttestation,
validateAttestation: validate,
trustEnclaves: trustEnclaves,
limitsFactory: lf,
}
h.Service, h.eng = services.Config{
Expand Down Expand Up @@ -622,7 +633,7 @@ func (h *Handler) verifyAttestationHash(ctx context.Context, attestationB64 stri
var validationErr error
for _, m := range measurements {
var err error
if caRootsPEM != "" {
if caRootsPEM != "" && !h.trustEnclaves {
err = nitro.ValidateAttestationWithRoots(attestationBytes, hash, m, caRootsPEM)
} else {
err = h.validateAttestation(attestationBytes, hash, m)
Expand Down
2 changes: 1 addition & 1 deletion core/capabilities/confidentialrelay/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func newTestHandler(t *testing.T, registry core.CapabilitiesRegistry, gwConn cor
require.NoError(t, err)
key, err := p2pkey.NewV2()
require.NoError(t, err)
h, err := NewHandler(registry, gwConn, newRelayResponseSigner(key), lggr, limits.Factory{Logger: lggr})
h, err := NewHandler(registry, gwConn, newRelayResponseSigner(key), lggr, limits.Factory{Logger: lggr}, false)
require.NoError(t, err)
h.validateAttestation = noopValidator
return h
Expand Down
5 changes: 4 additions & 1 deletion core/capabilities/confidentialrelay/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Service struct {
peerID p2pkey.PeerID
lggr logger.Logger
limitsFactory limits.Factory
trustEnclaves bool

handler *Handler
}
Expand All @@ -42,6 +43,7 @@ func NewService(
peerID p2pkey.PeerID,
lggr logger.Logger,
limitsFactory limits.Factory,
trustEnclaves bool,
) *Service {
s := &Service{
wrapper: wrapper,
Expand All @@ -50,6 +52,7 @@ func NewService(
peerID: peerID,
lggr: lggr,
limitsFactory: limitsFactory,
trustEnclaves: trustEnclaves,
}
s.Service, s.eng = services.Config{
Name: "ConfidentialRelayService",
Expand All @@ -68,7 +71,7 @@ func (s *Service) start(ctx context.Context) error {
if err != nil {
return fmt.Errorf("failed to get p2p key for confidential relay signing: %w", err)
}
h, err := NewHandler(s.capRegistry, conn, newRelayResponseSigner(key), s.lggr, s.limitsFactory)
h, err := NewHandler(s.capRegistry, conn, newRelayResponseSigner(key), s.lggr, s.limitsFactory, s.trustEnclaves)
if err != nil {
return err
}
Expand Down
3 changes: 3 additions & 0 deletions core/config/cre_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ type WorkflowFetcher interface {
// CREConfidentialRelay defines configuration for the confidential relay handler.
type CREConfidentialRelay interface {
Enabled() bool
// TrustEnclaves reports whether the relay should trust fake (non-Nitro)
// enclaves by relaxing TEE attestation validation. INSECURE; test-only.
TrustEnclaves() bool
}

// CRELinking defines configuration for connecting to the CRE linking service
Expand Down
2 changes: 2 additions & 0 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,8 @@ DebugMode = false # Default
[CRE.ConfidentialRelay]
# Enabled controls whether the confidential relay gateway handler should be configured.
Enabled = false # Default
# TrustEnclaves relaxes TEE attestation validation so the relay trusts fake (non-Nitro) enclaves. intended only for tests.
TrustEnclaves = false # Default

# Sharding holds settings for node sharding configuration.
[Sharding]
Expand Down
7 changes: 7 additions & 0 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1957,6 +1957,10 @@ type WorkflowFetcherConfig struct {
// validating enclave attestations and proxying capability requests.
type ConfidentialRelayConfig struct {
Enabled *bool `toml:",omitempty"`
// TrustEnclaves relaxes TEE attestation validation so the relay trusts
// fake (non-Nitro) enclaves. INSECURE; intended only for tests/E2E that run
// against the fake enclave environment.
TrustEnclaves *bool `toml:",omitempty"`
}

// LinkingConfig holds the configuration for connecting to the CRE linking service
Expand Down Expand Up @@ -2020,6 +2024,9 @@ func (c *CreConfig) setFrom(f *CreConfig) {
if v := f.ConfidentialRelay.Enabled; v != nil {
c.ConfidentialRelay.Enabled = v
}
if v := f.ConfidentialRelay.TrustEnclaves; v != nil {
c.ConfidentialRelay.TrustEnclaves = v
}
}
}

Expand Down
12 changes: 9 additions & 3 deletions core/services/chainlink/config_cre.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ func (c *creConfig) Linking() config.CRELinking {
}

type confidentialRelayConfig struct {
enabled bool
enabled bool
trustEnclaves bool
}

func (cr *confidentialRelayConfig) Enabled() bool { return cr.enabled }
func (cr *confidentialRelayConfig) Enabled() bool { return cr.enabled }
func (cr *confidentialRelayConfig) TrustEnclaves() bool { return cr.trustEnclaves }

func (c *creConfig) ConfidentialRelay() config.CREConfidentialRelay {
if c.c.ConfidentialRelay == nil {
Expand All @@ -119,7 +121,11 @@ func (c *creConfig) ConfidentialRelay() config.CREConfidentialRelay {
if c.c.ConfidentialRelay.Enabled != nil {
enabled = *c.c.ConfidentialRelay.Enabled
}
return &confidentialRelayConfig{enabled: enabled}
trustEnclaves := false
if c.c.ConfidentialRelay.TrustEnclaves != nil {
trustEnclaves = *c.c.ConfidentialRelay.TrustEnclaves
}
return &confidentialRelayConfig{enabled: enabled, trustEnclaves: trustEnclaves}
}

func (c *creConfig) LocalSecretOverrides() map[string]map[string]string {
Expand Down
3 changes: 2 additions & 1 deletion core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,8 @@ func TestConfig_Marshal(t *testing.T) {
TLSEnabled: ptr(true),
},
ConfidentialRelay: &toml.ConfidentialRelayConfig{
Enabled: ptr(false),
Enabled: new(bool),
TrustEnclaves: new(bool),
},
}
full.Billing = toml.Billing{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
1 change: 1 addition & 0 deletions core/services/chainlink/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
1 change: 1 addition & 0 deletions core/services/cre/cre.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ func (s *Services) newSubservices(
confidentialRelayPeerID(cfg, capCfg),
lggr,
opts.LimitsFactory,
cfg.CRE().ConfidentialRelay().TrustEnclaves(),
)
srvs = append(srvs, relayService)
}
Expand Down
1 change: 1 addition & 0 deletions core/web/resolver/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
1 change: 1 addition & 0 deletions core/web/resolver/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
7 changes: 7 additions & 0 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2724,6 +2724,7 @@ DebugMode enables additional tracing and logging for workflow engines.
```toml
[CRE.ConfidentialRelay]
Enabled = false # Default
TrustEnclaves = false # Default
```


Expand All @@ -2733,6 +2734,12 @@ Enabled = false # Default
```
Enabled controls whether the confidential relay gateway handler should be configured.

### TrustEnclaves
```toml
TrustEnclaves = false # Default
```
TrustEnclaves relaxes TEE attestation validation so the relay trusts fake (non-Nitro) enclaves. intended only for tests.

## Sharding
```toml
[Sharding]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import (

const flag = cre.ConfidentialRelayCapability

type ConfidentialRelay struct{}
type ConfidentialRelay struct {
// TrustEnclaves makes the relay trust fake (non-Nitro) enclaves by
// relaxing TEE attestation validation. INSECURE; test/E2E use only.
TrustEnclaves bool
}

func (o *ConfidentialRelay) Flag() cre.CapabilityFlag {
return flag
Expand Down Expand Up @@ -59,7 +63,11 @@ func (o *ConfidentialRelay) PreEnvStartup(
}

enabled := true
typedConfig.CRE.ConfidentialRelay = &coretoml.ConfidentialRelayConfig{Enabled: &enabled}
trustEnclaves := o.TrustEnclaves
typedConfig.CRE.ConfidentialRelay = &coretoml.ConfidentialRelayConfig{
Enabled: &enabled,
TrustEnclaves: &trustEnclaves,
}

out, err := tomlser.Marshal(typedConfig)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/config/merge_raw_configs.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/default.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/defaults-override.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/disk-based-logging.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/fallback-override.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/invalid-ocr-p2p.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/invalid.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = ''
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/valid.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
1 change: 1 addition & 0 deletions testdata/scripts/node/validate/warnings.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ TLSEnabled = true

[CRE.ConfidentialRelay]
Enabled = false
TrustEnclaves = false

[Billing]
URL = 'localhost:4319'
Expand Down
Loading