Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [SECURITY] sensitive configurations leaked in unauthenticated html endpoint #738

Open
3 tasks
chrislujan opened this issue Mar 22, 2024 · 0 comments
Open
3 tasks

Comments

@chrislujan
Copy link

Describe the bug

An instance of rswag configured like:

Rswag::Ui.configure do |c|
  c.swagger_endpoint '/apidocs', 'API V1 Docs'

  c.basic_auth_enabled = true
  c.basic_auth_credentials 'aaa', 'XXX'
end

Will leak the contents of the configuration, including the credentials in index.html of the swagger docs.

    var configObject = JSON.parse('{"urls":[{"url":"/apidocs","name":"API V1 Docs"}],"basic_auth":{"username":"aaa","password":"XXX"}}');

due to the code found at

var configObject = JSON.parse('<%= config_object.to_json %>');
var oauthConfigObject = JSON.parse('<%= oauth_config_object.to_json %>');

Steps to Test or Reproduce

  1. Configure rswag with basic_auth_credentials
  2. Visit the URL where swagger docs can be reached
  3. You should have a basic auth input form
    Screenshot 2024-03-22 at 2 41 59 PM
  4. Click cancel, an error should render
    Screenshot 2024-03-22 at 2 43 12 PM
  5. Inspect the source of the page and search for the term configObject, it should be in a script tag towards the bottom of the page

Expected behavior

Configurations and Configurations should not be exposed unless necessary, always practice the principle of least privilege and ensure you systems fail securely.

Screenshots

(see above)

Additional context

Add any other context about the problem here.

Dependency versions

The version of are you using for:

  • Rswag: (2.8.0)
  • RSpec:
  • Rails: 7.0.3.1
  • Ruby: ruby-3.1.1

Relates to which version of OAS (OpenAPI Specification)

  • OAS2
  • OAS3
  • OAS3.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant