id: cdn-cache-poisoning

info:
  name: Misconfigured CDN Cache Poisoning via X-Amz-Server-Side-Encryption Header
  author: 0xcharan
  severity: unknown
  description: |
    When the X-Amz-Server-Side-Encryption header is sent with user controlled value, it can lead to a misconfigured CDN cache response with a 400 status code, making the page inaccessible.
  reference:
    - https://portswigger.net/web-security/web-cache-poisoning
  metadata:
    verified: true
    max-request: 2
    shodan-query: X-Amz-Server-Side-Encryption
  tags: cache,aws,poisoning,cdn,misconfig,vuln
variables:
  string: "{{to_lower(rand_base(8))}}={{to_lower(rand_base(8))}}"

http:
  - raw:
      - |
        GET /?{{string}} HTTP/1.1
        Host: {{Hostname}}
        X-Amz-Server-Side-Encryption: {{randstr}}

      - |
        GET /?{{string}} HTTP/1.1
        Host: {{Hostname}}

    matchers:
      - type: dsl
        dsl:
          - 'contains(body_2, "{{randstr}}")'
          - 'status_code_2==400'
        condition: and
# digest: 4a0a00473045022100fc49a8fb5259a974b20df29de49a5425b4caf07c46c4480c7aacb5a3aae612dd02207755172c01828fbd1bdf2d0f30ad8654348991970177f06e80c78dbb5664ec42:922c64590222798bb761d5b6d8e72950