trailofbits.yaml.ansible.apt-unencrypted-url.apt-unencrypted-url

profile photo of trailofbitstrailofbits
Author
unknown
Download Count*

Found apt deb with unencrypted URL (e.g. HTTP, FTP, etc.)

Run Locally

Run in CI

Defintion

rules:
  - id: apt-unencrypted-url
    message: Found apt deb 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
        - apt
      confidence: HIGH
      likelihood: HIGH
      impact: HIGH
      references:
        - https://docs.ansible.com/ansible/latest/collections/ansible/builtin/apt_module.html#parameter-deb
      license: AGPL-3.0 license
      vulnerability_class:
        - Mishandled Sensitive Information
    patterns:
      - pattern-inside: |
          $APT:
            ...
      - metavariable-pattern:
          metavariable: $APT
          pattern-either:
            - pattern: apt
            - pattern: ansible.builtin.apt
      - pattern: "$KEY: '$VALUE'"
      - metavariable-pattern:
          metavariable: $KEY
          pattern-either:
            - pattern: deb
      - metavariable-regex:
          metavariable: $VALUE
          regex: (?i)^(http|ftp)://.*

Examples

apt-unencrypted-url.test.yaml

---
- name: Semgrep tests
  hosts: all
  tasks:
    - name: Positive test
      ansible.builtin.apt:
        # ruleid: apt-unencrypted-url
        deb: http://example.com/package.deb
    - name: Negative test
      ansible.builtin.apt:
        # ok: apt-unencrypted-url
        deb: https://example.com/package.deb