Verify Permissions on /etc/apt/auth.conf.d Directory

Description

To properly set the permissions of /etc/apt/auth.conf.d, run the command:

$ sudo chmod 0755 /etc/apt/auth.conf.d

Rationale

The /etc/apt/auth.conf.d directory contains configuration that may include repository credentials. Its permissions should prevent unauthorized changes.

Remediation

Shell script

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

#!/bin/bash

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

Ansible playbook

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

- name: Find /etc/apt/auth.conf.d/ file(s)
  ansible.builtin.command: 'find -P /etc/apt/auth.conf.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_auth_conf_d
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed

- name: Set permissions for /etc/apt/auth.conf.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_auth_conf_d
  - low_complexity
  - low_disruption
  - medium_severity
  - no_reboot_needed