trailofbits.yaml.ansible.dnf-unencrypted-url.dnf-unencrypted-url

profile photo of trailofbitstrailofbits
Author
unknown
Download Count*

Found dnf download with unencrypted URL (e.g. HTTP, FTP, etc.)

Run Locally

Run in CI

Defintion

rules:
  - id: dnf-unencrypted-url
    message: Found dnf download with unencrypted URL (e.g. HTTP, FTP, etc.)
    languages:
      - yaml
    severity: WARNING
    metadata:
      category: security
      cwe: "CWE-319: Cleartext Transmission of Sensitive Information"
      subcategory:
        - audit
      technology:
        - ansible
        - dnf
      confidence: HIGH
      likelihood: HIGH
      impact: HIGH
      references:
        - https://docs.ansible.com/ansible/latest/collections/ansible/builtin/dnf_module.html#parameter-name
        - https://docs.ansible.com/ansible/latest/collections/ansible/builtin/dnf5_module.html#parameter-name
      license: AGPL-3.0 license
      vulnerability_class:
        - Mishandled Sensitive Information
    patterns:
      - pattern-inside: |
          $DNF:
            ...
      - metavariable-pattern:
          metavariable: $DNF
          pattern-either:
            - pattern: dnf
            - pattern: ansible.builtin.dnf
            - pattern: dnf5
            - pattern: ansible.builtin.dnf5
      - pattern: "$KEY: '$VALUE'"
      - metavariable-pattern:
          metavariable: $KEY
          pattern-either:
            - pattern: name
            - pattern: pkg
      - metavariable-regex:
          metavariable: $VALUE
          regex: (?i)^(http|ftp)://.*

Examples

dnf-unencrypted-url.test.yaml

---
- name: Semgrep tests
  hosts: all
  tasks:
    - name: Positive test
      ansible.builtin.dnf:
        # ruleid: dnf-unencrypted-url
        name: http://example.com/example.rpm
        state: present
    - name: Negative test
      ansible.builtin.dnf:
        # ok: dnf-unencrypted-url
        name: https://example.com/example.rpm
        state: present