Bypassed Package Signature Validation
Ansible apt tasks are configured with force: yes to bypass signature verification and dependency conflicts, allowing installation of unsigned or tampered packages that could contain malicious code.
Ansible apt tasks configured with force: yes bypass signature validation and downgrade protections, allowing installation of untrusted, tampered, or malicious packages. This creates a critical attack vector where malicious actors can compromise hosts by injecting tampered packages that execute arbitrary code during installation or runtime, leading to full system compromise and persistent attacker control.
# VULNERABLE: Ansible apt task with forced unsigned packages
- name: Install packages without verification
hosts: all
tasks:
# VULNERABLE: Force bypasses signature verification
- name: Install potentially unsafe package
ansible.builtin.apt:
name: custom-package
state: present
force: yes # VULNERABLE: Bypasses signature checks
# VULNERABLE: Force with multiple packages
- name: Install multiple packages unsafely
ansible.builtin.apt:
pkg:
- untrusted-package
- legacy-software
- custom-tool
state: present
force: yes # VULNERABLE: Allows unsigned packages
# VULNERABLE: Force with package downgrade
- name: Downgrade package unsafely
ansible.builtin.apt:
name: important-service=1.0.0
state: present
force: yes # VULNERABLE: Bypasses downgrade protection
allow_downgrade: yes
# VULNERABLE: Force with untrusted repository
- name: Add untrusted repository
ansible.builtin.apt_repository:
repo: "deb [trusted=yes] http://untrusted.example.com/repo stable main"
state: present
- name: Install from untrusted repo
ansible.builtin.apt:
name: malicious-package
state: present
force: yes # VULNERABLE: Installs without verification# SECURE: Ansible apt configuration with signature verification
- name: Install packages securely
hosts: all
tasks:
# SECURE: Add trusted repository GPG key
- name: Add trusted repository GPG key
ansible.builtin.apt_key:
url: https://trusted.example.com/gpg-key.asc
state: present
- name: Add trusted repository
ansible.builtin.apt_repository:
repo: "deb https://trusted.example.com/repo stable main"
state: present
# SECURE: Install packages without force parameter
- name: Install verified package
ansible.builtin.apt:
name: trusted-package
state: present
# SECURE: Omit force - uses default signature verification
update_cache: yes
# SECURE: Install multiple packages with verification
- name: Install packages with verification
ansible.builtin.apt:
pkg:
- trusted-package
- security-tool
- monitoring-agent
state: present
# SECURE: No force parameter - enforces signature checks
# SECURE: Explicitly disable force if needed
- name: Install with explicit verification
ansible.builtin.apt:
name: critical-package
state: present
force: no # SECURE: Explicitly disable forceAnsible apt tasks are configured with force: yes to bypass signature verification and dependency conflicts, allowing installation of unsigned or tampered packages that could contain malicious code.
Sourcery automatically identifies remote code execution via forced unsigned packages in ansible apt task and many other security issues in your codebase.