Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve formatting + checks in Mondoo Linux policy #446

Merged
merged 31 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
1cdc8ca
Fix incorrect formatting in the Linux Security policy
tas50 Nov 16, 2024
c869b7a
Fix another poor line wrap
tas50 Nov 16, 2024
20f1f07
A few more
tas50 Nov 16, 2024
4268d52
Remove the overview headers
tas50 Nov 16, 2024
f8bef5c
More formatting fixes
tas50 Nov 16, 2024
fb12a38
More formatting fixes
tas50 Nov 16, 2024
9f6d144
Remove weird remote scan sections
tas50 Nov 16, 2024
ab28393
More formatting fixes and text updates
tas50 Nov 16, 2024
7552c66
More formatting fixes
tas50 Nov 16, 2024
7ae9575
More fixes
tas50 Nov 16, 2024
e1c3497
More formatting fixes
tas50 Nov 16, 2024
c29fecf
Add a chapter
tas50 Nov 16, 2024
6e2fa8c
Detect cyrus-imapd as an IMAP server
tas50 Nov 16, 2024
2b42da3
Improve formatting
tas50 Nov 16, 2024
83ad128
Improve formatting and mention exim
tas50 Nov 16, 2024
4dd960a
Better Debian/Ubuntu instructions
tas50 Nov 16, 2024
5facc28
Remove pointless description text
tas50 Nov 16, 2024
8d25e57
Improve platform specific remediation
tas50 Nov 16, 2024
29eac92
Add our own descriptions of some checks
tas50 Nov 16, 2024
c70937c
Detect additional FTP servers
tas50 Nov 16, 2024
ab675b2
Improve the FTP description
tas50 Nov 16, 2024
226b3ca
Remove Intended Audience sections
tas50 Nov 16, 2024
b1d193e
Add SLES instructions for installing auditd
tas50 Nov 16, 2024
6674015
Fix formatting
tas50 Nov 16, 2024
530fdb0
Add more SLES steps
tas50 Nov 17, 2024
6929c9b
Add Debian/Ubuntu support for the DNS server check
tas50 Nov 17, 2024
ccb58d2
Add support for Debian/Ubuntu in the NIS check
tas50 Nov 17, 2024
2ec91e5
Expand the rsh description
tas50 Nov 17, 2024
4ae0a47
Improve the telnet description
tas50 Nov 17, 2024
7c89cf8
Add talk support for Ubuntu/Debian
tas50 Nov 17, 2024
56cdaf9
Fix spelling
tas50 Nov 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/spelling/line_forbidden.patterns
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@
# s.b. AlmaLinux
\bAlma Linux\b

# s.b. CloudLinux
\bCloud Linux\b
\bCloudlinux\b

# s.b. openSUSE
\bOpenSUSE\b

Expand Down
2 changes: 0 additions & 2 deletions community/mondoo-linux-operational-policy.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ policies:
email: [email protected]
docs:
desc: |-
## Overview

Linux Server Operational Policy by Mondoo provides guidance for operational best practices on Linux hosts.

## Local scan
Expand Down
2 changes: 0 additions & 2 deletions community/mondoo-linux-snmp-policy.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ policies:
email: [email protected]
docs:
desc: |
## Overview

Linux Server SNMP Policy by Mondoo provides guidance for vulnerable SNMP configurations on Linux hosts.

## Local scan
Expand Down
2 changes: 0 additions & 2 deletions core/mondoo-aws-security.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ policies:
email: [email protected]
docs:
desc: |
## Overview

The Mondoo AWS Security policy provides guidance for establishing minimum recommended security and operational best practices for Amazon Web Services (AWS). The checks in this policy bundle are based on AWS's Operational Best Practices recommendations as part of the [AWS Config conformance packs](https://docs.aws.amazon.com/config/latest/developerguide/conformance-packs.html).

## Remote scan
Expand Down
26 changes: 12 additions & 14 deletions core/mondoo-azure-security.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ policies:
email: [email protected]
docs:
desc: |-
## Overview

The Mondoo Microsoft Azure Security policy provides guidance for establishing minimum recommended security and operational best practices for Microsoft Azure.

## Getting Started
Expand All @@ -35,7 +33,7 @@ policies:

Step 2: Authentication to Azure
There are two primary methods to authenticate cnspec to your Azure environments:

**a. Azure CLI Login**

```
Expand Down Expand Up @@ -122,14 +120,14 @@ queries:

```bash
az disk list --resource-group "yourResourceGroupName" --query "[].{Name:name, ResourceGroupName:resourceGroup, EncryptionSettings:encryptionSettingsCollection}" -o table
```
```

**Automated Audit with PowerShell:**

```powershell
Get-AzDisk -ResourceGroupName "yourResourceGroupName" | Select-Object Name, ResourceGroupName, EncryptionSettingsCollection
```

Ensure the EncryptionType is set to EncryptionAtRestWithCustomerKey for OS disks.
remediation: |
### Microsoft Azure Portal
Expand Down Expand Up @@ -229,7 +227,7 @@ queries:
desc: |
Restricting SSH access from the internet minimizes the risk of brute force and other unauthorized access attempts on Azure resources such as virtual machines. Public internet exposure of SSH, especially on the default port 22, significantly increases the attack surface. It's crucial to evaluate and restrict SSH access by configuring network security groups (NSGs) to allow only necessary connections, preferably from known, secure sources. Implementing stringent access controls for SSH enhances security by preventing attackers from using compromised VMs as a pivot point for broader network intrusions.
audit: |
**Manual Audit via Azure Portal:**
**Manual Audit via Azure Portal:**

**Checking via Network Security Groups (NSGs) for All Resources:**
1. From the main Azure Portal menu, navigate to **Network security groups**.
Expand Down Expand Up @@ -345,7 +343,7 @@ queries:
desc: |
Restricting RDP access from the internet is crucial for protecting Azure resources against unauthorized access and potential security breaches. RDP, typically listening on TCP port 3389, is a common target for many Cyber attacks. By limiting RDP access to only trusted internal networks or through secure tunnels, the risk of these attacks is significantly reduced. This security measure is essential for maintaining the integrity and security of Azure environments, preventing attackers from using compromised VMs as launch points for further attacks within and beyond the Azure network.
audit: |
**Manual Audit via Azure Portal:**
**Manual Audit via Azure Portal:**

1. Log into the Azure Portal.
2. Navigate to **Network security groups** under the Networking or directly through the search bar.
Expand Down Expand Up @@ -530,7 +528,7 @@ queries:

```
az storage account show --name <yourStorageAccountName> --query allowBlobPublicAccess
```
```

remediation: |
### Terraform
Expand All @@ -557,7 +555,7 @@ queries:
```
az storage account update --name <storage-account> --resource-group <resource-group> --public-network-access Disabled
```

- Set blob containers to private access:
```
az storage container set-permission --name <container_name> --public-access off --account-name <account_name> --account-key <account_key>
Expand Down Expand Up @@ -1046,7 +1044,7 @@ queries:
It is highly recommended to use the latest TLS version available with Azure App Services for all secure Web App connections. Currently Azure App Services supports TLS 1.2.
audit: |
**From Azure Portal:**

1. Log in to the Azure Portal at https://portal.azure.com.
2. Navigate to **App Services**.
3. Select an app service and select **TLS/SSL settings** under **Settings**.
Expand All @@ -1055,7 +1053,7 @@ queries:
**From Azure CLI:**

Verify that the minimum TLS version is set to 1.2 for each App Service:

```bash
az webapp config show --resource-group <RESOURCE_GROUP_NAME> --name <APP_NAME> --query minTlsVersion
```
Expand All @@ -1076,7 +1074,7 @@ queries:
b. Select **Configuration** and select the **General settings** tab.
c. Under **Minimum Inbound TLS Version**, select **1.2**.
d. Select **Save**.

**From Azure CLI:**

Set the minimum TLS version to 1.2 for an existing app service:
Expand Down Expand Up @@ -1157,7 +1155,7 @@ queries:
a. Select the key vault.
b. Select **Keys** or **Secrets**.
c. Make sure that the key/secret in the key vault has an expiration date.

**From Azure CLI:**

- For keys:
Expand Down Expand Up @@ -2197,4 +2195,4 @@ queries:
disallowedPortUDP = _
disallowedPortUDP
allNsgUDP.all(securityRules.none(destinationPortRange.any(fromPort <= disallowedPortUDP && toPort >= disallowedPortUDP)))
}
}
2 changes: 0 additions & 2 deletions core/mondoo-dns-security.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ policies:
email: [email protected]
docs:
desc: |
## Overview

The Mondoo DNS Security policy includes checks for assessing the configuration of DNS records.

## Remote scan
Expand Down
12 changes: 5 additions & 7 deletions core/mondoo-dockerfile-security.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ policies:
email: [email protected]
docs:
desc: |-
## Overview

The Dockerfile Security policy by Mondoo provides guidance for establishing secure Docker container configurations and deployments by securing Dockerfiles used to build container images.

If you have questions, comments, or ways to improve this policy, please write us at [email protected], or reach out in GitHub Discussions.
Expand Down Expand Up @@ -72,7 +70,7 @@ queries:
desc: |
Management ports such as SSH (port 22), Docker Remote API (port 2375), Consul (port 8500), and Kubernetes API (port 6443) are commonly targeted by attackers. Exposing these ports in Docker containers increases the risk of unauthorized access and security vulnerabilities. This test ensures that these management ports are not exposed in Docker container configurations.
remediation: |
Review and update your Dockerfile to ensure that management ports (22 for SSH, 2375 for Docker Remote API, 8500 for Consul HTTP API, 6443 for Kubernetes API) are not exposed.
Review and update your Dockerfile to ensure that management ports (22 for SSH, 2375 for Docker Remote API, 8500 for Consul HTTP API, 6443 for Kubernetes API) are not exposed.
- Remove or restrict the exposure of these ports using the `EXPOSE` instruction in your Dockerfile.
- Use Docker's port mapping options (`-p` or `--publish`) cautiously to avoid exposing these ports.
- Ensure that any required management access is secured and appropriately managed.
Expand All @@ -89,7 +87,7 @@ queries:
Disabling certificate validation can expose the system to man-in-the-middle attacks and other security vulnerabilities.
remediation: |
- Review the Dockerfile and ensure that package managers are configured to use SSL certificate validation.
- Use secure practices for package installations to maintain system integrity: Remove any insecure options such as `--nogpgcheck`, `--no-check-certificate`, `--no-gpg-check`, and similar flags.
- Use secure practices for package installations to maintain system integrity: Remove any insecure options such as `--nogpgcheck`, `--no-check-certificate`, `--no-gpg-check`, and similar flags.
- uid: mondoo-docker-security-no-insecure-certificate-validation-apt
title: Don’t disable certificate validation in APT
impact: 100
Expand All @@ -114,7 +112,7 @@ queries:
Disabling certificate validation can expose the container to man-in-the-middle attacks and other security risks.
remediation: |
- Review the `CMD` or `ENTRYPOINT` commands in your Dockerfile and any scripts executed within the container.
- Avoid using `curl` with `--insecure` or `-k` options.
- Avoid using `curl` with `--insecure` or `-k` options.
- Ensure that proper SSL certificate validation is enabled for all `curl` operations.
- uid: mondoo-docker-security-no-insecure-certificate-validation-wget
title: Don’t disable certificate validation in Wget
Expand All @@ -139,7 +137,7 @@ queries:
as it grants elevated permissions that can be exploited if not handled properly.
By avoiding `sudo`, you ensure that all commands run with the default user privileges, which enhances the security of the container.
remediation: |
- Review the Dockerfile and remove any instances of `sudo`.
- Review the Dockerfile and remove any instances of `sudo`.
- Ensure that all commands are executed with the least privileges required.
- Configure containers to operate with non-root users where possible, and avoid privilege escalation techniques.
- uid: mondoo-docker-security-no-gpg-skip-yum
Expand Down Expand Up @@ -212,4 +210,4 @@ queries:
desc: |
Ensure that Dockerfiles use the `apt-get` CLI instead of `apt`. The `apt-get` CLI provides more predictable behavior in scripting contexts and is generally preferred for use in Dockerfiles for its consistency and reliability.
remediation: |
Review the Dockerfile `RUN` instructions to replace any `apt` commands with `apt-get`. This ensures that package management operations are performed using the recommended and more stable CLI.
Review the Dockerfile `RUN` instructions to replace any `apt` commands with `apt-get`. This ensures that package management operations are performed using the recommended and more stable CLI.
8 changes: 4 additions & 4 deletions core/mondoo-edr-policy.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ policies:
By implementing this policy, we take a proactive approach to instill confidence in our security posture and reinforce our commitment to safeguarding sensitive data, critical assets, and the integrity of our digital infrastructure.

Additionally, it is highly recommended that antivirus signatures are updated daily to ensure protection against the latest threats. For instance, Windows Defender signatures can be updated using the following PowerShell command:

```powershell
Update-MpSignature
```
Expand Down Expand Up @@ -86,9 +86,9 @@ queries:
- uid: mondoo-edr-policy-ensure-edr-agent-is-installed-macos
filters: asset.platform == 'macos'
mql: |
package('Falcon').installed ||
package('SentinelOne Extensions').installed ||
package('ESET Endpoint Security').installed ||
package('Falcon').installed ||
package('SentinelOne Extensions').installed ||
package('ESET Endpoint Security').installed ||
file('/Library/Ossec').exists ||
['Cortex XDR', 'Cortex XDR Agent'].all(package(_).installed)
- uid: mondoo-edr-policy-ensure-edr-agent-is-installed-linux
Expand Down
2 changes: 0 additions & 2 deletions core/mondoo-email-security.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ policies:
email: [email protected]
docs:
desc: |
## Overview

This policy bundle verifies best practices for authenticating email messages using security protocols such as Sender Policy Framework (SPF), Domain Keys Identified Mail (DKIM), and Domain-based Message Authentication, Reporting & Conformance (DMARC).

### Running the Policy
Expand Down
4 changes: 1 addition & 3 deletions core/mondoo-gcp-security.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ policies:
email: [email protected]
docs:
desc: |-
## Overview

The Mondoo Google Cloud Security policy provides guidance for establishing minimum recommended security and operational best practices for Google Cloud.

## Remote scan
Expand Down Expand Up @@ -712,4 +710,4 @@ queries:
)
- uid: gcp-storage-cloud-storage-buckets-uniform-bucket-level-access-enabled-single
filters: asset.platform == "gcp-storage-bucket"
mql: gcp.storage.bucket.iamConfiguration.UniformBucketLevelAccess.enabled == true
mql: gcp.storage.bucket.iamConfiguration.UniformBucketLevelAccess.enabled == true
10 changes: 0 additions & 10 deletions core/mondoo-github-best-practices.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ policies:

The Mondoo GitHub Repository Best Practices policy provides assessments of public and private GitHub repositories to ensure a minimum recommended operational best practices.

## About remote scanning

Remote scans with cnspec provide on demand security assessments of infrastructure and services without the need to install any agents or integrations. cnspec comes with a growing list of providers to connect and scan local and remote targets.

A complete list of providers can be found by running this command:

```bash
cnspec scan --help
```

### cnspec GitHub provider

This policy uses the `github` provider to authenticate with GitHub's API in order to remotely scan GitHub repositories. Additional information on the `github` provider can be found by running this command:
Expand Down
22 changes: 0 additions & 22 deletions core/mondoo-github-security.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,8 @@ policies:
email: [email protected]
docs:
desc: |
## Overview

The Mondoo GitHub Organization Security policy provides guidance for establishing minimum recommended security and operational best practices for GitHub organizations.

## About remote scanning

Remote scans with cnspec provide on demand security assessments of infrastructure and services without installing any agents or integrations. cnspec comes with a growing list of providers to connect and scan local and remote targets.

A complete list of providers can be found by running this command:

```bash
cnspec scan --help
```

### cnspec GitHub provider

This policy uses the `github` provider to authenticate with GitHub's API in order to remotely scan GitHub organizations. Additional information on the `github` provider can be found by running this command:
Expand Down Expand Up @@ -105,16 +93,6 @@ policies:

GitHub Repository Security by Mondoo provides security assessments of public and private GitHub repositories to ensure minimum recommended security and operational best practices. This policy is also designed to assess public repositories and open source projects your team depends on to evaluate the risk a project poses to your business. Open source projects that do not adhere to GitHub's recommended security best practices pose a higher risk of malicious code making its way into your environments.

## About remote scanning

Remote scans with cnspec provide on demand security assessments of infrastructure and services without installing any agents or integrations. cnspec comes with a growing list of providers to connect and scan local and remote targets.

A complete list of providers can be found by running this command:

```bash
cnspec scan --help
```

### cnspec GitHub Provider

This policy uses the `github` provider to authenticate with GitHub's API in order to remotely scan GitHub repositories. Additional information on the `github` provider can be found by running this command:
Expand Down
12 changes: 0 additions & 12 deletions core/mondoo-gitlab-security.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,8 @@ policies:
email: [email protected]
docs:
desc: |
## Overview

The Mondoo GitLab Security policy offers guidance on establishing minimum recommended security best practices for GitLab groups and projects.

## Remote scan

Remote scans use cnspec providers to retrieve on-demand scan results without having to install any agents.

A complete list of providers can be found by running this command:

```bash
cnspec scan --help
```

### Prerequisites

Remote scans of GitLab require a [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html) with access to the group and projects you plan to scan.
Expand Down
4 changes: 1 addition & 3 deletions core/mondoo-http-security.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ policies:
email: [email protected]
docs:
desc: |
## Overview

The Mondoo HTTP Security policy includes checks for ensuring the security of HTTP headers.

## Remote scan
Expand Down Expand Up @@ -131,4 +129,4 @@ queries:
The Public-Key-Pins header is deprecated and should not be used anymore.
refs:
- url: https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Headers_Cheat_Sheet.html#public-key-pins-hpkp
title: OWASP HTTP Security Response Headers Cheat Sheet
title: OWASP HTTP Security Response Headers Cheat Sheet
2 changes: 0 additions & 2 deletions core/mondoo-kubernetes-best-practices.mql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ policies:
email: [email protected]
docs:
desc: |-
## Overview

The Mondoo Kubernetes Best Practices policy bundle provides guidance for establishing reliable Kubernetes clusters by encouraging the adoption of best practices.

## Remote scan
Expand Down
Loading