The cnspec Configuration File
Reference for mondoo.yml, the cnspec configuration file, including where cnspec looks for it and every setting it accepts.
cnspec stores its settings in a YAML file named mondoo.yml. Registering cnspec creates the file and writes the credentials that connect the host to your Mondoo Platform space. You can then add settings of your own to control logging, proxies, asset metadata, provider updates, and how often the service scans.
Everything in this file is optional except the registration credentials. An unregistered cnspec runs happily without a configuration file, scanning against Mondoo's free, open source policies.
Where cnspec looks for the file
cnspec checks the current user's configuration first, then the system-wide configuration. It uses the first file it finds:
| Operating system | Scope | Path |
|---|---|---|
| Linux | Current user | ~/.config/mondoo/mondoo.yml |
| Linux | All users | /etc/opt/mondoo/mondoo.yml |
| macOS | Current user | ~/.config/mondoo/mondoo.yml |
| macOS | All users | /Library/Mondoo/etc/mondoo.yml |
| Windows | Current user | C:\Users\{username}\.config\mondoo\mondoo.yml |
| Windows | All users | C:\ProgramData\Mondoo\mondoo.yml |
Because the user file wins, a mondoo.yml in a user's home directory silently overrides the
system-wide configuration for every command that user runs. If a scan reports to the wrong space,
check for a stray user-level file first.
To see which file cnspec loaded, run cnspec status. The output names the file and the source that selected it:
→ loaded configuration from /etc/opt/mondoo/mondoo.yml using source defaultPoint cnspec at a different file
You can override the search with a flag or an environment variable. When more than one is present, cnspec uses the first match in this order:
MONDOO_CONFIG_BASE64: the entire configuration file, base64 encoded. This is the usual choice for CI/CD, where you store the encoded file as a secret and never write it to disk.--config <path>: a path passed on the command line. Every cnspec command accepts it.MONDOO_CONFIG_PATH: a path from the environment, used only when--configis absent.- The search paths in the table above.
base64 < mondoo.yml | tr -d '\n'cnspec can also read the file from AWS Systems Manager Parameter Store. Pass the region and parameter name with the aws-ssm-ps:// prefix, in the form aws-ssm-ps://region/<region>/parameter/<name>:
cnspec scan local --config aws-ssm-ps://region/us-east-1/parameter/mondoo-configcnspec reads the parameter with the AWS credentials it finds in the environment, the same ones the AWS CLI uses.
How settings are resolved
Three sources feed each setting. Later sources win:
- The configuration file
- Environment variables
- Command line flags
Most settings also have an environment variable equivalent: prefix the key with MONDOO_, uppercase it, and replace hyphens and dots with underscores. So auto_update becomes MONDOO_AUTO_UPDATE and api_endpoint becomes MONDOO_API_ENDPOINT. The log.format and log.color settings are the exception, because cnspec reads them before it applies environment overrides. Set those two in the file.
cnspec reads keys literally and does not expand dotted keys into nested YAML. Write log.format
and log.color exactly as shown in this reference, as single keys with a dot in the name. Nesting
them under a log: block has no effect. The annotations, labels, auth, and scan_interval
settings are the opposite: they are true YAML blocks with nested keys.
Platform connection
cnspec login writes these settings. Treat them as generated values: to change spaces or replace credentials, register again rather than editing them by hand.
| Setting | Description |
|---|---|
mrn | Mondoo resource name of the service account cnspec authenticates as |
agent_mrn | Mondoo resource name that identifies this client |
space_mrn | Mondoo resource name of the space the service account belongs to. This is the key cnspec login writes |
scope_mrn | Mondoo resource name of the space or organization the service account is scoped to. When present, it takes precedence over space_mrn |
certificate | PEM encoded client certificate |
private_key | PEM encoded client private key, used to sign requests to Mondoo Platform |
token | Service account token, for accounts that authenticate by token instead of a certificate |
api_endpoint | URL of Mondoo Platform, https://us.api.mondoo.com by default |
api_proxy | Proxy URL for all traffic to Mondoo Platform |
The configuration file contains a private key. On Linux and macOS, keep it readable only by the
account that runs cnspec (chmod 0600). Never commit it to a repository.
cnspec resolves the scope from the first of these keys that is set: scope_mrn, then space_mrn, then parent_mrn. Registration writes space_mrn, so that is what you see in most files. parent_mrn is deprecated and remains only so that older files keep working.
Registration can also seed a few of the settings below. cnspec login accepts --annotation, --api-endpoint, --updates-url, --timer, and --splay, and writes each one to the file it creates.
To route traffic through a proxy, add:
api_proxy: http://10.0.0.1:8080For more on proxies, read Register cnspec.
Asset metadata
These settings control the metadata cnspec attaches to what it scans from this host.
| Setting | Description |
|---|---|
annotations | Key/value pairs added to every asset this host scans. They display in the Mondoo Console and can drive policy filtering |
labels | Key/value pairs sent with the client registration when cnspec logs in. They describe the client, not the assets it scans |
category | Asset category. Set it to cicd to record scans as CI/CD assets instead of fleet assets |
detect-cicd | Whether to detect CI/CD environments automatically and set the category to cicd. Default true |
annotations:
team: research
owner: cosmo@lunalectric.comTo learn more about annotations and the other ways to set them, read Annotate assets.
Logging
| Setting | Description |
|---|---|
log-level | Log verbosity: error, warn, info, debug, or trace. Default info |
log.format | Set to json for structured log output. Write the key exactly as shown, dot included |
log.color | Set to true for compact, colorized console logs. Write the key exactly as shown |
logging-config | Path to a separate logging configuration file (YAML or JSON) that selects the log writer, level, and writer options. It takes precedence over log-level |
log-level: debug
log.format: jsonUpdates
| Setting | Description |
|---|---|
auto_update | Whether cnspec updates itself and downloads the latest providers as needed. Default true |
updates_url | Base URL for cnspec and provider downloads. Point it at an internal mirror for air-gapped fleets |
auto_update: falseThe configuration key uses an underscore (auto_update), while the command line flag uses a
hyphen (--auto-update=false). Writing auto-update in the file has no effect.
providers_url sets the provider download URL on its own and is deprecated. Use updates_url instead, which covers both cnspec and providers. When you turn off automatic updates, check releases.mondoo.com/providers/ periodically and update providers manually, as described in Manage cnspec providers.
Scheduled scans
When cnspec runs as a service, these settings control the scan schedule:
| Setting | Description |
|---|---|
scan_interval.timer | Minutes between scans. Default 60 |
scan_interval.splay | Maximum random delay in minutes added to each scan, so a fleet doesn't scan in lockstep. Default 60 |
scan_interval:
timer: 360
splay: 30The cnspec serve --timer and --splay flags override these values for a single run. cnspec login --timer and --splay write them into the file at registration.
The inventory file beside it
When cnspec loads a configuration file, it also looks for an inventory.yml in the same directory. If one is there and you did not pass --inventory-file, cnspec scans the assets that inventory defines:
/etc/opt/mondoo/
├── mondoo.yml
└── inventory.ymlcnspec serve always scans every asset the discovered file defines, on every cycle, with no extra flags. This is how a host running cnspec as a service extends its own scan: list the host itself (type: local) alongside another asset, such as the database service running on it, and each cycle produces a result for both instead of just the host.
cnspec serve reads mondoo.yml and this file once, at startup, and keeps that in memory for as long as it runs. It does not watch the file for changes. If you add or edit inventory.yml next to an already-running service, restart the service to pick up the change:
- Linux:
sudo systemctl restart cnspec - Windows:
Restart-Service -Name mondoo
cnspec scan also auto-discovers this file, but only to enrich the target you give it, for
example by copying id_detector settings. If you run cnspec scan local with an auto-discovered
inventory.yml on disk, cnspec scans only local and drops the file's other assets. To scan every
asset an inventory file defines with cnspec scan, pass it explicitly with --inventory-file
instead of relying on auto-discovery.
To learn what belongs in that file, including a worked example of combining a host scan with a local database scan, read Remote scanning with inventory files.
Advanced
| Setting | Description |
|---|---|
features | Client feature flags. Set these only when Mondoo Support asks you to |
auth.method | Authentication method. cnspec sets this itself when it detects a Workload Identity Federation configuration |
A configuration file with type: external_account tells cnspec to authenticate with Workload Identity Federation rather than a certificate and private key. Such a file carries the federation keys audience, issuerUri, jwtToken, subjectTokenType, scopes, and universeDomain. These files are generated, not hand-authored.
A complete example
# service account mrn
mrn: //agents.api.mondoo.app/spaces/lunalectric/serviceaccounts/1utIs5XUQ8XayfB6yiQNTLOqPlD
# agent mrn
agent_mrn: //agents.api.mondoo.app/spaces/lunalectric/agents/1utIqsjg3YSAF8hMMIhg8tBsTPP
# space mrn
space_mrn: //captain.api.mondoo.app/spaces/lunalectric
# api endpoint
api_endpoint: https://us.api.mondoo.com
# pem-encoded certificate
certificate: |
-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
# pem-encoded private key
private_key: |
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
# log level: error, warn, info, debug, trace
log-level: info
# annotations applied to every asset scanned from this host
annotations:
team: research
owner: cosmo@lunalectric.com
# scan every six hours, with up to 30 minutes of jitter
scan_interval:
timer: 360
splay: 30