trailofbits.yaml.ansible.unarchive-validate-certs-disabled.unarchive-validate-certs-disabled

profile photo of trailofbitstrailofbits
Author
unknown
Download Count*

Found unarchive download with SSL verification disabled

Run Locally

Run in CI

Defintion

rules:
  - id: unarchive-validate-certs-disabled
    message: Found unarchive download with SSL verification disabled
    languages:
      - yaml
    severity: WARNING
    metadata:
      category: security
      cwe: "CWE-295: Improper Certificate Validation"
      subcategory:
        - audit
      technology:
        - ansible
      confidence: HIGH
      likelihood: HIGH
      impact: HIGH
      references:
        - https://docs.ansible.com/ansible/latest/collections/ansible/builtin/unarchive_module.html#parameter-validate_certs
      license: AGPL-3.0 license
      vulnerability_class:
        - Improper Authentication
    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: validate_certs
      - metavariable-pattern:
          metavariable: $VALUE
          pattern-either:
            - pattern: "false"

Examples

unarchive-validate-certs-disabled.test.yaml

---
- name: Semgrep tests
  hosts: all
  tasks:
    - name: Positive test
      ansible.builtin.unarchive:
        src: https://example.com/example.zip
        dest: /usr/local/bin
        remote_src: yes
        # ruleid: unarchive-validate-certs-disabled
        validate_certs: false
    - name: Negative test (unarchive-unencrypted-url and unarchive-validate-certs-disabled)
      ansible.builtin.unarchive:
        # ok: unarchive-validate-certs-disabled
        src: https://example.com/example.zip
        dest: /usr/local/bin
        remote_src: yes