id: aws-bucket-takeover

info:
  name: AWS Bucket Takeover Detection
  author: pdteam,pwnhxl,zy9ard3
  severity: high
  description: AWS Bucket takeover was detected.
  reference:
    - https://github.com/EdOverflow/can-i-take-over-xyz/issues/36
  metadata:
    max-request: 1
  tags: takeover,aws,bucket

http:
  - method: GET
    path:
      - "{{BaseURL}}"

    matchers-condition: and
    matchers:
      - type: dsl
        dsl:
          - Host != ip

      - type: word
        words:
          - "The specified bucket does not exist"
          - "BucketName"
        condition: and

      - type: dsl
        dsl:
          - contains(tolower(header), 'x-guploader-uploadid')
          - contains(tolower(header), "aliyunoss")
        negative: true

      - type: word
        part: host
        words:
          - "amazonaws.com"
          - "ks3.ksyun.com"
          - "kss.ksyun.com"
          - "kss3.ksyun.com"
          - "ks3-cn-beijing.ksyun.com"
          - "ks3-cn-guangzhou.ksyun.com"
          - "ks3-cn-hk-1.ksyun.com"
          - "ks3-cn-shanghai.ksyun.com"
          - "ks3-jr-beijing.ksyun.com"
          - "ks3-jr-shanghai.ksyun.com"
          - "ks3-rus.ksyun.com"
          - "ks3-sgp.ksyun.com"
          - "obs.jrzq.huaweicloud.com"
          - "obs.petalpay.huaweicloud.com"
          - "oss-cn-hangzhou.aliyuncs.com"
          - "oss-cn-shanghai.aliyuncs.com"
          - "oss-cn-qingdao.aliyuncs.com"
          - "oss-cn-beijing.aliyuncs.com"
          - "oss-cn-zhangjiakou.aliyuncs.com"
          - "oss-cn-huhehaote.aliyuncs.com"
          - "oss-cn-shenzhen.aliyuncs.com"
          - "oss-cn-hongkong.aliyuncs.com"
          - "oss-us-west-1.aliyuncs.com"
          - "oss-us-east-1.aliyuncs.com"
          - "oss-ap-southeast-1.aliyuncs.com"
          - "oss-ap-southeast-2.aliyuncs.com"
          - "oss-ap-southeast-3.aliyuncs.com"
          - "oss-ap-southeast-5.aliyuncs.com"
          - "oss-ap-south-1.aliyuncs.com"
          - "oss-ap-northeast-1.aliyuncs.com"
          - "oss-eu-central-1.aliyuncs.com"
          - "oss-me-east-1.aliyuncs.com"
        negative: true


    extractors:
      - type: regex
        part: body
        group: 1
        regex:
          - '<li>BucketName: (.*?)</li>'
          - '<BucketName>(.*?)</BucketName>'
# digest: 4b0a00483046022100f9971da068265c7bdf27a98174406257097863d2f626d5766188ff816740fa63022100ebd12a06f36b24104a4b81b1fce912f186cdcd0fb008ae188105be7e4f31af0f:922c64590222798bb761d5b6d8e72950