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

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: 4a0a0047304502203090c27f197b4dafbb78ae06b6317103dcf492a7ecc1285225b5895173701e9c022100e9b523e6c01e124b4f291f7f65bc4fd067c5fdcefeadce6a6291b6da69f3fc93:922c64590222798bb761d5b6d8e72950