trailofbits.yaml.ansible.unarchive-unencrypted-url.unarchive-unencrypted-url

profile photo of trailofbitstrailofbits
Author
unknown
Download Count*

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

Run Locally

Run in CI

Defintion

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

Examples

unarchive-unencrypted-url.test.yaml

---
- name: Semgrep tests
  hosts: all
  tasks:
    - name: Positive test
      ansible.builtin.unarchive:
        # ruleid: unarchive-unencrypted-url
        src: http://example.com/example.zip
        dest: /usr/local/bin
        remote_src: yes
    - name: Negative test
      ansible.builtin.unarchive:
        # ok: unarchive-unencrypted-url
        src: https://example.com/example.zip
        dest: /usr/local/bin
        remote_src: yes