Skip to content
Leaked secrets Disclosed report Beginner

Gratipay rails secret token (secret_key_base) publicly exposed in GitHub

The Rails secret_key_base was committed to a public GitHub repository. An attacker who knows this secret could forge signed cookies and impersonate any user.

sp4rrow Follow

Originally disclosed on HackerOne

  • Disclosed after under an hour

Summary

Gratipay's Rails secret token is publicly exposed on GitHub. Knowing the secret token allows an attacker to impersonate any user in the application.

Thanks to EdOverflow for sharing the tips for finding security issues in GitHub projects, below is the referenced github for the analysis.

Description

The secret_token.rb file's content includes a long randomized string which is used to verify the integrity of signed cookies (such as user sessions when people are signed into your web app). Documentation says:

Use your existing secret_key_base from the secret_token.rb initializer to set the SECRET_KEY_BASE environment variable for whichever users run the Rails app in production mode. Alternately, you can simply copy the existing secret_key_base from the secret_token.rb initializer to secrets.yml under the production section, replacing <%= ENV["SECRET_KEY_BASE"] %>. Make sure your secret_key_base is kept private if you're sharing your code publicly.

Further Details: Knowing the secret token allows an attacker to impersonate any user in the application.

Steps To Reproduce

Go to the Gratipay "Access Dashboard" project (https://github.com/gratipay/access-dashboard/blob/rails-recode/config/initializers) In the secret_token.rb file the secret_key_base is publicly disclosed. As per the comments in the code as well as the documentation the key should always be kept private, looks like the developer forgot to remove the token. Happens! Too much work sometimes and the expected delivery deadlines :)

Patch

Removing the secret key would do the work!

Supporting Material/References:

Thanks to EdOverflow for sharing the tips for finding security issues in GitHub projects. :) (https://gist.github.com/EdOverflow/922549f610b258f459b219a32f92d10b)

Please let me know if any further information is needed on this.

BR, null

The original report as published on HackerOne, by sp4rrow. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the developer committed the Rails initializer containing the secret_key_base to a public repository instead of keeping it in an environment variable or private configuration.

What the attacker needed

Public access to the GitHub repository

The fix

The secret key should be removed from the repository.

How it was found

  1. Open the project's config/initializers directory on GitHub.
  2. Open the secret_token.rb file.
  3. Observe that the secret_key_base value is publicly visible.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Web applications often store a secret key that is used to sign cookies, so the server can tell whether a cookie was really issued by it. If that key is published, anyone can create valid-looking cookies for any user. Here the key was left in a file in a public code repository.

What is Leaked secrets?

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.

More from Gratipay

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Leaked secrets and credentials

The lesson behind this report.

Keys, tokens or passwords left in public code, apps, logs or responses, that grant real access.