trailofbits.yaml.ansible.rpm-key-validate-certs-disabled.rpm-key-validate-certs-disabled

profile photo of trailofbitstrailofbits
Author
unknown
Download Count*

Found RPM key with SSL verification disabled

Run Locally

Run in CI

Defintion

rules:
  - id: rpm-key-validate-certs-disabled
    message: Found RPM key with SSL verification disabled
    languages:
      - yaml
    severity: WARNING
    metadata:
      category: security
      cwe: "CWE-295: Improper Certificate Validation"
      subcategory:
        - audit
      technology:
        - ansible
        - rpm
      confidence: HIGH
      likelihood: HIGH
      impact: HIGH
      references:
        - https://docs.ansible.com/ansible/latest/collections/ansible/builtin/rpm_key_module.html#parameter-validate_certs
      license: AGPL-3.0 license
      vulnerability_class:
        - Improper Authentication
    patterns:
      - pattern-inside: |
          $RPMKEY:
            ...
            key: ...
            ...
      - metavariable-pattern:
          metavariable: $RPMKEY
          pattern-either:
            - pattern: rpm_key
            - pattern: ansible.builtin.rpm_key
      - pattern: "$KEY: $VALUE"
      - metavariable-pattern:
          metavariable: $KEY
          pattern-either:
            - pattern: validate_certs
      - metavariable-pattern:
          metavariable: $VALUE
          pattern-either:
            - pattern: "false"

Examples

rpm-key-validate-certs-disabled.test.yaml

---
- name: Semgrep tests
  hosts: all
  tasks:
    - name: Positive test (rpm-key-validate-certs-disabled)
      ansible.builtin.rpm_key:
        state: present
        key: https://example.com/RPM-GPG-KEY.dag.txt
        # ruleid: rpm-key-validate-certs-disabled
        validate_certs: false
    - name: Negative test (rpm-key-unencrypted-url and rpm-key-validate-certs-disabled)
      ansible.builtin.rpm_key:
        # ok: rpm-key-validate-certs-disabled
        state: present
        key: https://example.com/RPM-GPG-KEY.dag.txt