---
title: Ensure the System Wide Crypto Policy Disables Weak MACs
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > Ensure the System Wide Crypto Policy
  Disables Weak MACs
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Ensure the System Wide Crypto Policy Disables Weak MACs
 
## Description{% #description %}

The system wide crypto policy has to disable the message authentication codes (MACs) that the CIS Benchmark considers weak. The rule reads the resolved policy that `update-crypto-policies` writes to `/etc/crypto-policies/state/CURRENT.pol` when it applies a policy. That file has to exist, and its global `mac` line has to list no MAC whose name ends in `-128`, such as `UMAC-128`. To disable these MACs, add the following line to `/etc/crypto-policies/policies/modules/NO-WEAKMAC.pmod`:

```
mac = -*-128*
```

Then add the `NO-WEAKMAC` subpolicy to the system wide crypto policy, together with the subpolicies already in use, for example:

```
$ sudo update-crypto-policies --set DEFAULT:NO-WEAKMAC
```

## Rationale{% #rationale %}

A MAC algorithm protects the integrity and the origin of a message. An attacker who can compute the MAC of a message without the key can alter the messages of a connection, for instance from a man-in-the-middle position, and capture the credentials and data it carries. Weak MAC algorithms make that attack feasible with enough computing power.

## Remediation{% #remediation %}

### Shell script{% #shell-script %}

The following script can be run on the host to remediate the issue.

```bash
#!/bin/bash

# Remediation is applicable only in certain platforms
if rpm --quiet -q crypto-policies; then

current_pol=/etc/crypto-policies/state/CURRENT.pol

if [ ! -f "$current_pol" ] || grep -Eiq '^[[:space:]]*mac[[:space:]]*=[^#]*-128\b' "$current_pol"; then
    module=/etc/crypto-policies/policies/modules/NO-WEAKMAC.pmod
    # End the module with a newline, so that the line appended below starts
    # a line of its own.
    [ -z "$(tail -c 1 "$module" 2>/dev/null)" ] || echo >>"$module"
    grep -qsxF -- 'mac = -*-128*' "$module" || echo 'mac = -*-128*' >>"$module"
    chmod 0644 "$module"
    # Apply NO-WEAKMAC last, after any subpolicy that enables what it disables.
    crypto_policy=$(update-crypto-policies --show | sed -e 's/$/:/' -e 's/:NO-WEAKMAC:/:/g' -e 's/:$//')
    update-crypto-policies --set "$crypto_policy:NO-WEAKMAC"
fi

else
    >&2 echo 'Remediation is not applicable, nothing was done'
fi
```
