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. It overrides the HTTPS_PROXY environment variable and the Windows proxy settings |
system_proxy | Whether to use the proxy settings of the operating system when neither api_proxy nor HTTPS_PROXY is set. Windows only. Default true |
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:8080On Windows, cnspec uses the proxy configured in the operating system when this setting is empty. For the order in which cnspec considers each proxy source, and how to turn the Windows behavior off, read Proxy configuration.
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 inventory 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 |
update_channel | Release channel that updates and provider installs resolve through: stable or preview. Read Release channels |
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.
Two environment variables act as a hard off switch that even an explicit cnspec update respects: MONDOO_AUTO_UPDATE=false stops both cnspec and provider updates, and MONDOO_AUTO_UPDATE_ENGINE=false stops only the cnspec binary from updating itself.
When updates_url is unset, cnspec reads its release manifest from https://install.mondoo.com and downloads providers from https://releases.mondoo.com/providers. When you set it, cnspec reads the manifest from <updates_url>/package/cnspec/latest.json and downloads providers from <updates_url>/providers, so a mirror must serve both.
providers_url is the deprecated predecessor of updates_url. cnspec 14 still honors it for provider downloads, takes it over updates_url when both are set, and logs a deprecation warning. To move a configuration file over, run cnspec migrate: when providers_url ends in /providers and updates_url isn't set, it adds the matching updates_url and leaves providers_url in place so that older cnspec versions still find it. Because updates_url also sets where cnspec looks for binary updates, the mirror must serve the release manifest as well as /providers once updates_url is in the file.
When you turn off automatic updates, check releases.mondoo.com/providers/ periodically and update providers manually, as described in Manage cnspec providers.
Scanning
| Setting | Description |
|---|---|
strict | Default MQL strict mode for policies that don't declare one: every link in an MQL chain must resolve. Default false. The --strict flag and MONDOO_STRICT set the same default |
parallelism | Number of assets cnspec scan scans at once. Default 0, which uses the value the providers declare, capped at half the CPUs on the machine. 1 scans sequentially. Also MONDOO_PARALLELISM |
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.
Starting with cnspec 14, cnspec serve reloads the inventory and rediscovers its assets before every scan cycle, so an inventory.yml you add, edit, or remove next to a running service takes effect on the next cycle without a restart. If the file is momentarily invalid, for example halfway through an edit, the service logs an error and scans with the last inventory it could read. Two cases still need a restart: an inventory piped in on stdin (--inventory-file -), which can only be read once, and changes to mondoo.yml itself, such as the scan interval.
cnspec 13 and earlier read mondoo.yml and inventory.yml once, at startup. On those versions, restart the service after you add or edit the inventory file:
- 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 |
provider_port_range | Loopback TCP port range, written as min-max (for example 50000-50100), that providers listen on. Windows only. Default: any free port |
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: 30Learn more
Proxies
Where cnspec looks for a proxy for its traffic to Mondoo Platform, in which order, how Windows proxy settings are used automatically, and how to override or turn that off.
Manage cnspec Providers
Learn how cnspec providers work, when to manage them yourself, and how to install, update, and remove them.