---
title: Verify Permissions on /etc/apt/trusted.gpg.d Directory
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > Datadog Security > OOTB Rules > Verify Permissions on
  /etc/apt/trusted.gpg.d Directory
---

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

# Verify Permissions on /etc/apt/trusted.gpg.d Directory
 
## Description{% #description %}

To properly set the permissions of `/etc/apt/trusted.gpg.d`, run the command:

```
$ sudo chmod 0755 /etc/apt/trusted.gpg.d
```

## Rationale{% #rationale %}

A non-privileged user with write access to /etc/apt/trusted.gpg.d can compromise the APT chain of trust by adding trusted keys.

## Remediation{% #remediation %}

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

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

```bash
#!/bin/bash

find -H /etc/apt/trusted.gpg.d/ -maxdepth 0 -perm /u+s,g+ws,o+wt -type d -exec chmod u-s,g-ws,o-wt {} \;
```

### Ansible playbook{% #ansible-playbook %}

The following playbook can be run with Ansible to remediate the issue.

```
- name: Find /etc/apt/trusted.gpg.d/ file(s)
  ansible.builtin.command: 'find -P /etc/apt/trusted.gpg.d/ -maxdepth 0 -perm /u+s,g+ws,o+wt  -type
    d '
  register: files_found
  changed_when: false
  failed_when: false
  check_mode: false
  tags:
  - configure_strategy
  - directory_permissions_apt_trusted_gpg_d
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed

- name: Set permissions for /etc/apt/trusted.gpg.d/ file(s)
  ansible.builtin.file:
    path: '{{ item }}'
    mode: u-s,g-ws,o-wt
    state: directory
  with_items:
  - '{{ files_found.stdout_lines }}'
  tags:
  - configure_strategy
  - directory_permissions_apt_trusted_gpg_d
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed
```
