Skip to Content
Cloud

Secure OpenStack with cnspec

Scan OpenStack projects against security and compliance best practices with cnspec.

Scan your OpenStack project to find security risks before they become incidents. cnspec evaluates Keystone identity, Nova compute, Placement resource providers, Glance images, Neutron networking and VPNaaS, Cinder block storage, Swift object storage, Barbican key management, Octavia load balancers, Designate DNS, Manila shared file systems, Magnum container clusters, Trove databases, Ironic bare metal nodes, and Heat stacks, all without installing agents on your infrastructure.

New to cnspec? Read the Quickstart to install cnspec and run your first scan. To scan other platforms, see the cloud scanning overview.

Prerequisites

To scan OpenStack with cnspec, you must have:

Authenticate

cnspec resolves OpenStack credentials in this priority order:

  1. CLI flags (--auth-url, --username, --password, --project-name, ...)
  2. --cloud <name> to select an entry from clouds.yaml
  3. OS_* environment variables

Use a clouds.yaml entry

If you already manage OpenStack credentials with a clouds.yaml file, reference the entry by name:

cnspec scan openstack --cloud my-cloud

Use environment variables

Export the standard OS_* variables once and reuse them across commands:

export OS_AUTH_URL=https://keystone.example.com/v3
export OS_USERNAME=admin
export OS_PASSWORD=secret
export OS_PROJECT_NAME=demo
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default

Pass flags explicitly

cnspec scan openstack \
  --auth-url https://keystone.example.com/v3 \
  --username admin --password secret \
  --project-name demo \
  --user-domain-name Default --project-domain-name Default \
  --region RegionOne

Use a Keystone application credential

Application credentials avoid embedding a user's password in scan configuration:

cnspec scan openstack \
  --auth-url https://keystone.example.com/v3 \
  --application-credential-id <id> \
  --application-credential-secret <secret>

If your Keystone endpoint uses a certificate cnspec cannot validate, add --insecure to skip TLS verification. Use this only in trusted environments.

Connection options

The openstack provider accepts these connection options. Each is also settable through the noted environment variable:

OptionDescription
--auth-urlKeystone auth URL (env: OS_AUTH_URL)
--usernameUsername (env: OS_USERNAME)
--passwordPassword (env: OS_PASSWORD)
--project-nameProject name (env: OS_PROJECT_NAME)
--project-idProject ID (env: OS_PROJECT_ID)
--project-domain-nameProject domain name (env: OS_PROJECT_DOMAIN_NAME)
--project-domain-idProject domain ID (env: OS_PROJECT_DOMAIN_ID)
--user-domain-nameUser domain name (env: OS_USER_DOMAIN_NAME)
--user-domain-idUser domain ID (env: OS_USER_DOMAIN_ID)
--regionRegion (env: OS_REGION_NAME)
--cloudclouds.yaml entry to use
--application-credential-idApplication credential ID (env: OS_APPLICATION_CREDENTIAL_ID)
--application-credential-nameApplication credential name (env: OS_APPLICATION_CREDENTIAL_NAME)
--application-credential-secretApplication credential secret (env: OS_APPLICATION_CREDENTIAL_SECRET)
--insecureSkip TLS certificate verification
--discoverChild asset types to discover (see below)

Verify with a quick OpenStack check

Confirm that cnspec can reach your OpenStack project:

cnspec run openstack -c 'openstack.projectId != empty'

If cnspec connects to Keystone, it prints the scoped project ID and confirms the check passed.

Scan OpenStack

Scan your OpenStack project:

cnspec scan openstack

When the scan completes, cnspec prints each check with a pass or fail result and an overall risk score from 0 (no risk) to 100 (highest risk). To learn how to read a report in depth, see Understand Scan Results.

Discover security groups

By default, cnspec scans the connected project as a single asset. To also scan each Neutron security group as its own asset, use the --discover flag:

ValueDiscovers
autoOnly the connected project (the default)
allEvery supported child asset type
security-groupsOne asset per security group in the connected scope
cnspec scan openstack --cloud my-cloud --discover security-groups

Scan with the Mondoo OpenStack Security policy

Mondoo maintains an out-of-the-box Mondoo OpenStack Security policy that checks Keystone identity, Nova compute, Neutron networking and VPNaaS, Cinder block storage, Glance images, Swift object storage, Octavia load balancers, Manila shared file systems, Magnum container clusters, and Trove databases against security best practices. Most of its checks also evaluate OpenStack resources in Terraform HCL, plan, and state files. To learn more, read Secure Terraform Code with cnspec.

Mondoo Platform users: Enable the policy in your space. In the Mondoo App, go to Findings > Policies, search for "OpenStack", and add the policy. All future scans of your OpenStack projects automatically evaluate against it. To learn more, read Manage policies in Mondoo Platform.

Open source users: Pass the policy bundle URL directly to cnspec:

cnspec scan openstack \
  --policy-bundle https://raw.githubusercontent.com/mondoohq/cnspec/refs/heads/main/content/mondoo-openstack-security.mql.yaml

You can also create your own policies to meet your specific requirements.

Asset model

Each connection produces one root asset for the Keystone scope. A project-scoped connection reports the openstack-project platform; domain-scoped and system-scoped connections report openstack-domain and openstack-system. Security groups discovered with --discover security-groups report openstack-security-group. Every OpenStack platform belongs to the openstack family. Project assets are placed under:

technology=openstack/project=<project-uuid>

Calls to services that aren't deployed (for example, Octavia or Barbican on smaller clouds) return empty rather than failing the scan, so policies stay portable across clouds with different service catalogs.

Required permissions

  • Project-scoped tokens see their own project's data across all services.
  • Listing Keystone users, roles, domains, groups, credentials, trusts, service catalog services and endpoints, role assignments, and role inference rules typically requires admin scope.
  • Nova hypervisors, compute services, and host aggregates, and Cinder QoS specs, require admin scope.
  • When the token isn't allowed to list a collection, cnspec returns an empty list for it and logs a warning instead of failing the scan.

Explore and test checks interactively

Open a cnspec shell to discover resources and try out checks:

cnspec shell openstack

Identify the scoped project

cnspec> openstack { projectId region authUrl }

List Nova servers

cnspec> openstack.servers { name status availabilityZone flavor.name image.name }

Find servers without an SSH key configured

cnspec> openstack.servers.where(keyName == "") { name status }

List Glance images and their visibility

cnspec> openstack.images { name status visibility diskFormat sizeBytes }

Find public images you may not have intended to share

cnspec> openstack.images.where(visibility == "public") { name owner createdAt }

List Neutron networks

cnspec> openstack.networks { name status external shared subnets.length }

Inspect security groups and their rules

cnspec> openstack.securityGroups { name description rules { direction protocol portRangeMin portRangeMax remoteIpPrefix } }

Find security group rules that expose any port to the internet

cnspec> openstack.securityGroups.all(
    rules.none(direction == "ingress" && remoteIpPrefix == "0.0.0.0/0")
  )

List FWaaS v2 firewall groups, policies, and rules

cnspec> openstack.firewallGroups { name adminStateUp ingressPolicy.name egressPolicy.name }
cnspec> openstack.firewallPolicies { name shared audited }
cnspec> openstack.firewallRules { name action protocol enabled }

List Cinder volumes and check encryption

cnspec> openstack.volumes { name size status encrypted bootable availabilityZone }
cnspec> openstack.volumes.all(encrypted == true)

List Octavia load balancers and listeners

cnspec> openstack.loadBalancers { name provisioningStatus operatingStatus vipAddress listeners.length }
cnspec> openstack.listeners { name protocol protocolPort defaultPool.name }

List Barbican secrets

cnspec> openstack.secrets { name secretType algorithm bitLength status expiresAt }

Find Swift containers that anyone can read

cnspec> openstack.objectStorageContainers.where(public) { name objectCount readACL }

Find Nova keypairs and their fingerprints

cnspec> openstack.keypairs { name fingerprint type user.name }

List Keystone users, roles, and domains (admin scope required)

cnspec> openstack.users { name enabled domain.name }
cnspec> openstack.roles { name description }
cnspec> openstack.domains { name enabled description }

Coverage

cnspec queries the following OpenStack services through the project's Keystone service catalog:

ServiceResources
Identity (Keystone v3)projects, users, roles, domains, groups, credentials (such as EC2 access keys), trusts, service catalog services and endpoints, regions, role assignments, role inference rules, federation (identity providers, protocols, mappings, service providers)
Compute (Nova v2)servers (with server actions), flavors, keypairs, server groups, hypervisors, compute services, host aggregates, limits, quotas
Placementresource providers
Image (Glance v2)images
Networking (Neutron v2)networks, subnets, subnet pools, address scopes, address groups, routers, ports, floating IPs, security groups (with rules), QoS policies, RBAC policies, agents, tap mirrors, trunks, quotas, FWaaS v2 (groups/policies/rules), VPNaaS v2 (VPN services, IKE policies, IPsec policies, endpoint groups, site connections)
Block Storage (Cinder v3)volumes, snapshots, backups, volume types, QoS specs, volume transfers, quotas
Object Storage (Swift)account, containers, objects
Key Manager (Barbican v1)secrets, containers, orders
Load Balancer (Octavia v2)load balancers, listeners, pools, members, health monitors, L7 policies, L7 rules, amphorae
DNS (Designate)zones, record sets, zone transfer requests and accepts, TSIG keys
Shared File Systems (Manila)shares (with access rules), security services, share networks, share transfers
Container Infrastructure (Magnum)clusters (with node groups), cluster templates
Database (Trove)database instances, configuration groups
Bare Metal (Ironic)nodes, ports
Orchestration (Heat)stacks (with stack resources)

Learn more

Last updated on

On this page