Django Secret Key Exposure
ID: django-secret-key
Severity: high
Author: geeknik,DhiyaneshDk
Tags: django,exposure,files
Description
Section titled “Description”The Django settings.py file containing a secret key was discovered. An attacker may use the secret key to bypass many security mechanisms and potentially obtain other sensitive configuration information (such as database password) from the settings file.
YAML Source
Section titled “YAML Source”id: django-secret-key
info: name: Django Secret Key Exposure author: geeknik,DhiyaneshDk severity: high description: | The Django settings.py file containing a secret key was discovered. An attacker may use the secret key to bypass many security mechanisms and potentially obtain other sensitive configuration information (such as database password) from the settings file. reference: https://docs.gitguardian.com/secrets-detection/detectors/specifics/django_secret_key classification: cpe: cpe:2.3:a:djangoproject:django:*:*:*:*:*:*:*:* metadata: verified: true max-request: 7 vendor: djangoproject product: django shodan-query: html:settings.py comments: 'This template downloads the manage.py file to check whether it contains line such as: `os.environ.setdefault("DJANGO_SETTINGS_MODULE", "APP_NAME.settings")` if it does, we extract the APP_NAME to know in what folder to look for the settings.py file.' tags: django,exposure,files
http: - method: GET path: - "{{BaseURL}}/manage.py" - "{{BaseURL}}/settings.py" - "{{BaseURL}}/app/settings.py" - "{{BaseURL}}/django/settings.py" - "{{BaseURL}}/settings/settings.py" - "{{BaseURL}}/web/settings/settings.py" - "{{BaseURL}}/{{app_name}}/settings.py"
stop-at-first-match: true
matchers-condition: and matchers: - type: word part: body words: - "SECRET_KEY ="
- type: word part: header words: - "text/html" negative: true
- type: status status: - 200
extractors: - type: regex part: body group: 1 regex: - '"DJANGO_SECRET_KEY", "(.*)"'
- type: regex part: body internal: true name: app_name group: 1 regex: - "os.environ.setdefault\\([\"']DJANGO_SETTINGS_MODULE[\"'],\\s[\"']([a-zA-Z-_0-9]*).settings[\"']\\)"# digest: 4a0a0047304502206a2773bc55d7570d7a16e541d5e67d97da8c45f10e05168c59d90a1e3714369b022100c333c073e7ffa35e8dadb7308a63377062887d11cb1122d7ec984455963d9832:922c64590222798bb761d5b6d8e72950Guide to check the vulnerabilities
Section titled “Guide to check the vulnerabilities”This template is used to detect vulnerabilities in web applications. It can be used with the Nuclei tool to scan for specific patterns or behaviors.
$ nuclei -u "URL" -t "http/exposures/files/django-secret-key.yaml"