2023-04-10 15:36:59 +00:00
|
|
|
# Copyright (c) HashiCorp, Inc.
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2022-02-02 20:03:18 +00:00
|
|
|
rules:
|
2023-02-27 18:17:47 +00:00
|
|
|
# Check potentially unauthenticated RPC endpoints. Technically more
|
|
|
|
# authorization (authz) oriented than authn, but before Nomad 1.4/1.5 that
|
|
|
|
# distinction wasn't as important.
|
2022-02-02 20:03:18 +00:00
|
|
|
- id: "rpc-potentially-unauthenticated"
|
|
|
|
patterns:
|
|
|
|
- pattern: |
|
|
|
|
if done, err := $A.$B.forward($METHOD, ...); done {
|
|
|
|
return err
|
|
|
|
}
|
2023-01-27 13:29:53 +00:00
|
|
|
# Pattern used by typical endpoints that take an auth token or workload
|
|
|
|
# identity. Some of these endpoints have no context for Authenticate
|
2022-02-02 20:03:18 +00:00
|
|
|
- pattern-not-inside: |
|
2023-01-27 13:29:53 +00:00
|
|
|
authErr := $A.$B.Authenticate(...)
|
|
|
|
...
|
2022-02-02 20:03:18 +00:00
|
|
|
if done, err := $A.$B.forward($METHOD, ...); done {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
...
|
2023-01-27 13:29:53 +00:00
|
|
|
... := $A.$B.ResolveACL(...)
|
2022-02-02 20:03:18 +00:00
|
|
|
...
|
2023-01-27 13:29:53 +00:00
|
|
|
# Pattern used by endpoints that are used by both ACLs and Clients.
|
|
|
|
# These endpoints will always have a ctx passed to Authenticate
|
2022-02-02 20:03:18 +00:00
|
|
|
- pattern-not-inside: |
|
2023-01-27 13:29:53 +00:00
|
|
|
authErr := $A.$B.Authenticate($A.ctx, args)
|
|
|
|
...
|
2022-02-02 20:03:18 +00:00
|
|
|
if done, err := $A.$B.forward($METHOD, ...); done {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
...
|
2023-01-27 13:29:53 +00:00
|
|
|
... := $A.$B.ResolveClientOrACL(...)
|
2022-02-02 20:03:18 +00:00
|
|
|
...
|
2023-01-27 13:29:53 +00:00
|
|
|
# Pattern used by ACL endpoints that need to interact with the token directly
|
2022-02-02 20:03:18 +00:00
|
|
|
- pattern-not-inside: |
|
2023-01-27 13:29:53 +00:00
|
|
|
authErr := $A.$B.Authenticate($A.ctx, args)
|
|
|
|
...
|
2022-02-02 20:03:18 +00:00
|
|
|
if done, err := $A.$B.forward($METHOD, ...); done {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
...
|
2023-01-27 13:29:53 +00:00
|
|
|
... := args.GetIdentity().GetACLToken()
|
2022-02-02 20:03:18 +00:00
|
|
|
...
|
|
|
|
# Pattern used by endpoints called exclusively between agents
|
|
|
|
# (server -> server or client -> server)
|
|
|
|
- pattern-not-inside: |
|
2023-01-27 13:29:53 +00:00
|
|
|
authErr := $A.$B.Authenticate($A.ctx, args)
|
2022-03-25 16:00:48 +00:00
|
|
|
...
|
2022-02-05 01:35:20 +00:00
|
|
|
... := validateTLSCertificateLevel(...)
|
2022-02-02 20:03:18 +00:00
|
|
|
...
|
|
|
|
if done, err := $A.$B.forward($METHOD, ...); done {
|
|
|
|
return err
|
|
|
|
}
|
2023-01-27 13:29:53 +00:00
|
|
|
# Pattern used by endpoints that support both normal ACLs and workload
|
|
|
|
# identity but break authentication and authorization up
|
|
|
|
# TODO: currently this is just for Variables and should be removed once
|
|
|
|
# https://github.com/hashicorp/nomad/issues/15875 is complete.
|
2022-06-10 13:41:54 +00:00
|
|
|
- pattern-not-inside: |
|
2023-01-27 13:29:53 +00:00
|
|
|
authErr := $A.$B.Authenticate($A.ctx, args)
|
|
|
|
...
|
2022-06-10 13:41:54 +00:00
|
|
|
if done, err := $A.$B.forward($METHOD, ...); done {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
...
|
|
|
|
... := $T.handleMixedAuthEndpoint(...)
|
|
|
|
...
|
2023-01-27 13:29:53 +00:00
|
|
|
# Second pattern used by endpoints that support both normal ACLs and
|
2022-10-18 20:43:59 +00:00
|
|
|
# workload identity but break authentication and authorization up
|
2023-01-27 13:29:53 +00:00
|
|
|
# TODO: currently this is just for Variables and should be removed once
|
|
|
|
# https://github.com/hashicorp/nomad/issues/15875 is complete.
|
2022-10-18 20:43:59 +00:00
|
|
|
- pattern-not-inside: |
|
2023-01-27 13:29:53 +00:00
|
|
|
authErr := $A.$B.Authenticate($A.ctx, args)
|
|
|
|
...
|
2022-10-18 20:43:59 +00:00
|
|
|
if done, err := $A.$B.forward($METHOD, ...); done {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
...
|
2023-01-27 13:29:53 +00:00
|
|
|
... := svePreApply($A, args, args.Var)
|
2022-10-18 20:43:59 +00:00
|
|
|
...
|
2022-02-02 20:03:18 +00:00
|
|
|
# Pattern used by some Node endpoints.
|
|
|
|
- pattern-not-inside: |
|
2023-01-27 13:29:53 +00:00
|
|
|
authErr := $A.$B.Authenticate($A.ctx, args)
|
|
|
|
...
|
2022-02-02 20:03:18 +00:00
|
|
|
if done, err := $A.$B.forward($METHOD, ...); done {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
...
|
|
|
|
return $A.deregister(...)
|
|
|
|
...
|
|
|
|
- metavariable-pattern:
|
|
|
|
metavariable: $METHOD
|
|
|
|
patterns:
|
|
|
|
# Endpoints that are expected not to have authentication.
|
|
|
|
- pattern-not: '"ACL.Bootstrap"'
|
2023-02-27 18:17:47 +00:00
|
|
|
- pattern-not: '"ACL.GetClaimPolicies"'
|
2022-02-02 20:03:18 +00:00
|
|
|
- pattern-not: '"ACL.ResolveToken"'
|
|
|
|
- pattern-not: '"ACL.UpsertOneTimeToken"'
|
|
|
|
- pattern-not: '"ACL.ExchangeOneTimeToken"'
|
2023-01-27 13:29:53 +00:00
|
|
|
- pattern-not: '"ACL.WhoAmI"'
|
2023-01-18 10:18:35 +00:00
|
|
|
- pattern-not: 'structs.ACLListAuthMethodsRPCMethod'
|
|
|
|
- pattern-not: 'structs.ACLOIDCAuthURLRPCMethod'
|
|
|
|
- pattern-not: 'structs.ACLOIDCCompleteAuthRPCMethod'
|
2023-03-16 13:50:20 +00:00
|
|
|
- pattern-not: 'structs.ACLLoginRPCMethod'
|
2022-02-02 20:03:18 +00:00
|
|
|
- pattern-not: '"CSIPlugin.Get"'
|
|
|
|
- pattern-not: '"CSIPlugin.List"'
|
|
|
|
- pattern-not: '"Status.Leader"'
|
|
|
|
- pattern-not: '"Status.Peers"'
|
|
|
|
- pattern-not: '"Status.Version"'
|
|
|
|
message: "RPC method $METHOD appears to be unauthenticated"
|
|
|
|
languages:
|
|
|
|
- "go"
|
|
|
|
severity: "WARNING"
|
|
|
|
paths:
|
|
|
|
include:
|
2023-01-27 13:29:53 +00:00
|
|
|
- "nomad/*_endpoint.go"
|