---
title: Ensure system wide crypto policy is not set to legacy
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > Ensure system wide crypto policy is not
  set to legacy
---

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

# Ensure system wide crypto policy is not set to legacy
 
## Description{% #description %}

When a system-wide policy is set up, the default behavior of applications will be to follow the policy. Applications will be unable to use algorithms and protocols that do not meet the policy, unless you explicitly request the application to do so. The system-wide crypto-policies followed by the crypto core components allow consistently deprecating and disabling algorithms system-wide. The `LEGACY` policy ensures maximum compatibility with legacy systems at the cost of being less secure. It allows the TLS 1.2, and TLS 1.3 protocols, as well as IKEv2 and SSH2. DSA is not allowed, while RSA and Diffie-Hellman parameters are accepted if no less than 2048 bits. This policy provides at least 80-bit security. The rule checks that `/etc/crypto-policies/config` and `/etc/crypto-policies/state/current` name a base policy other than `LEGACY`. Crypto policy modules follow the base policy after a colon, so `LEGACY:AD-SUPPORT` counts as `LEGACY`. The rule also checks that the configured policy is applied: `/etc/crypto-policies/state/current` is at least as recent as `/etc/crypto-policies/config`, and `/etc/crypto-policies/back-ends/nss.config` exists.

## Rationale{% #rationale %}

Centralized cryptographic policies simplify applying secure ciphers across an operating system and the applications that run on that operating system. Use of weak or untested encryption algorithms undermines the purposes of utilizing encryption to protect data. The `LEGACY` system-wide crypto policy includes support for outdated and weakened algorithms to ensure maximum compatibility with Red Hat Enterprise Linux 6 and earlier; it is less secure due to an increased attack surface.

## Remediation{% #remediation %}

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

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

```bash
#!/bin/bash

crypto_policy=$(update-crypto-policies --show)
case "$crypto_policy" in
LEGACY | LEGACY:*)
    crypto_policy="DEFAULT${crypto_policy#LEGACY}"
    ;;
esac
if [ "$crypto_policy" != "$(cat /etc/crypto-policies/state/current 2>/dev/null)" ] ||
    [ /etc/crypto-policies/config -nt /etc/crypto-policies/state/current ] ||
    [ ! -e /etc/crypto-policies/back-ends/nss.config ]; then
    update-crypto-policies --set "$crypto_policy"
fi
```

## Warning{% #warning %}

System Crypto Modules must be provided by a vendor that undergoes FIPS-140 certifications. FIPS-140 is applicable to all Federal agencies that use cryptographic-based security systems to protect sensitive information in computer and telecommunication systems (including voice systems) as defined in Section 5131 of the Information Technology Management Reform Act of 1996, Public Law 104-106. This standard shall be used in designing and implementing cryptographic modules that Federal departments and agencies operate or are operated for them under contract. See **[https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.140-2.pdf](https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.140-2.pdf)** To meet this, the system has to have cryptographic software provided by a vendor that has undergone this certification. This means providing documentation, test results, design information, and independent third party review by an accredited lab. While open source software is capable of meeting this, it does not meet FIPS-140 unless the vendor submits to this process.
