id: ruby-secrets-file

info:
  name: Ruby on Rails secrets.yml File Exposure
  author: DhiyaneshDK
  severity: high
  description: Ruby on Rails internal secret file is exposed.
  reference:
    - https://www.exploit-db.com/ghdb/6283
  classification:
    cpe: cpe:2.3:a:rubyonrails:rails:*:*:*:*:*:*:*:*
  metadata:
    verified: true
    max-request: 4
    vendor: rubyonrails
    product: rails
    google-query: intitle:"index of" "secrets.yml"
  tags: cloud,devops,files,exposure,misconfig,vuln

http:
  - method: GET
    path:
      - "{{BaseURL}}/secrets.yml"
      - "{{BaseURL}}/config/secrets.yml"
      - "{{BaseURL}}/test/config/secrets.yml"
      - "{{BaseURL}}/redmine/config/secrets.yml"

    stop-at-first-match: true

    matchers-condition: and
    matchers:
      - type: regex
        regex:
          - 'secret_key_base: ([a-z0-9]+)'

      - type: word
        part: header
        words:
          - "application/json"
          - "text/html"
        negative: true
        condition: and

      - type: status
        status:
          - 200

    extractors:
      - type: regex
        part: body
        group: 1
        regex:
          - 'secret_key_base: ([a-z0-9]+)'
# digest: 4a0a00473045022100d31920a1da2768b3532b344331e91fe4bf596ec3d30a75499eaa7665ed12d98202200d5d19ea4cb4d099269eb468644fcbf5816e9d51e1255c9f4ff6ccf5eec2a0e1:922c64590222798bb761d5b6d8e72950