awsaccess

package
v0.172.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package awsaccess asks AWS which identity the credentials in the environment are, and which actions that identity's policies allow.

The first question is asked by two callers: `draugr doctor`, to say whether a declared account is the one the credentials reach, and the prowler scanner, before Prowler runs. Prowler's output names the account it read and not the identity that read it, and credentials for another account produce a complete, plausible report about the wrong account. The second is the scanner's, to learn before the scan which services' reads will be denied.

The credentials are the ones Prowler and every AWS SDK read: the AWS_* environment variables, AWS_PROFILE and the shared config and credentials files, an SSO session, or the role of the machine the scan runs on. Asking with the same chain is what makes the answer about the scan rather than about this process.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCredentials = errors.New("no AWS credentials found: set AWS_PROFILE, sign in with " +
	"`aws sso login`, or run where an instance or task role is attached")

ErrNoCredentials is a machine with no AWS credentials to ask with.

View Source
var ErrNotSimulated = errors.New("the policy simulator answers for IAM users and roles only")

ErrNotSimulated is a caller IAM's policy simulator cannot be asked about: the account's root, or a federated user, whose permissions no IAM principal holds.

Functions

func Denied

func Denied(ctx context.Context, sim Simulator, caller Caller, actions []string) ([]string, error)

Denied asks the simulator which of actions caller's policies do not allow, in the order given. An error is a question IAM did not answer, most often because the caller may not ask it.

func Principal

func Principal(ctx context.Context, sim Simulator, caller Caller) (string, error)

Principal is the IAM principal whose policies decide what caller may do: the user itself, or for a role session the role it assumed. A session's ARN names the role without its path, and the simulator needs the path, which only iam:GetRole returns.

Types

type Caller

type Caller struct {
	// Account is the 12-digit ID of the account the identity belongs to.
	Account string
	// ARN names the identity: a user, a role session or the account's root.
	ARN string
}

Caller is the identity the credentials resolve to.

func Confirm

func Confirm(ctx context.Context, id Identifier, account string) (Caller, error)

Confirm asks who the credentials are and refuses an identity outside account.

STS answers for any valid credentials, so an error here is credentials that do not work at all, and an identity in another account is credentials that work and would scan the wrong account.

type IAM

type IAM struct {
	// contains filtered or unexported fields
}

IAM asks AWS Identity and Access Management what the credentials' policies allow. Both of its calls need a permission of their own, iam:GetRole and iam:SimulatePrincipalPolicy, which a read-only role commonly lacks.

func NewIAM

func NewIAM(ctx context.Context) (*IAM, error)

NewIAM loads the default credential chain and returns a Simulator that asks with it.

func (*IAM) Allowed

func (c *IAM) Allowed(ctx context.Context, principal string, actions []string) ([]string, error)

Allowed asks iam:SimulatePrincipalPolicy whether principal's policies allow each action on any resource. The simulation weighs the principal's identity policies, its permissions boundary and the organization's service control policies; a resource's own policy and a session policy are outside it.

func (*IAM) RoleARN

func (c *IAM) RoleARN(ctx context.Context, name string) (string, error)

RoleARN asks iam:GetRole for the role's ARN, which carries its path.

type Identifier

type Identifier interface {
	CallerIdentity(ctx context.Context) (Caller, error)
}

Identifier asks AWS who the credentials are.

type STS

type STS struct {
	// contains filtered or unexported fields
}

STS asks AWS Security Token Service who the credentials are.

func New

func New(ctx context.Context) (*STS, error)

New loads the default credential chain and returns an Identifier that asks with it.

func (*STS) CallerIdentity

func (s *STS) CallerIdentity(ctx context.Context) (Caller, error)

CallerIdentity asks STS GetCallerIdentity, which needs no permission: any valid credentials may ask who they are.

type Simulator

type Simulator interface {
	// RoleARN is the ARN of the role named name, with its path, as iam:GetRole returns it.
	RoleARN(ctx context.Context, name string) (string, error)
	// Allowed simulates the policies of principal, a user's or a role's ARN, for each action, with
	// iam:SimulatePrincipalPolicy, and returns the actions they allow.
	Allowed(ctx context.Context, principal string, actions []string) ([]string, error)
}

Simulator asks IAM what an identity's policies allow.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL