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
  metadata:
    verified: true
    max-request: 4
    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: 4a0a004730450221008f3c78e37d6034c88fc8a231da592e10d3f0dd3cffc406c8f8ce4b3bb86ccf7802201eb77dae641b3f6691653ae35bfe9c03af2cc9716703b1d9288c516869363fbb:922c64590222798bb761d5b6d8e72950