GitLab stores AWS, Slack, Askimet, reCaptcha tokens in plaintext
GitLab stored several sensitive credentials (AWS keys, Akismet API key, reCAPTCHA keys, Slack app secret) in plaintext in the application_settings database table. An attacker with database access could read these secrets directly.
GitLab
Originally disclosed on GitLab
- Fixed in 2 months
- Disclosed after 2 months
HackerOne report #692439 by xanbanx on 2019-09-11, assigned to hackerjuan:
Hi GitLab security team,
Summary
I was looking at the application code and my database and observed that GitLab stores sensitive credentials in plaintext in the database. In particular, saw that the application settings store the following credentials in plaintext:
- AWS keys for elastic search cluster
- Askimet API key
- reCAPTCHA site and private key
- Slack APP_SECRET
Furthermore, these tokens are directly visible to any administrator and anyone looking at their computer. In general, it's good practice to redact entered tokens and do not show them in the user interface of GitLab.
Steps to reproduce
Tested on a local installation of GitLab Enterprise.
- Fill in the tokens mentioned above. Concrete values do not matter.
- Start a PSQL console. On a GDK you can do that via
bundle exec rails db - Execute the following command:
SELECT (elasticsearch_aws_access_key,elasticsearch_aws_secret_access_key,slack_app_secret,slack_app_verification_token,akismet_api_key,recaptcha_site_key,recaptcha_private_key) FROM application_settings;
This will reveal directly the tokens in plaintext.
Impact
An attacker with access to the system could read sensitive information stored in plaintext.
What is the current bug behavior?
Various tokens are stored in plaintext.
What is the expected correct behavior?
Sensitive tokens need to be stored encrypted. It seems there is already infrastructure available for that in the application settings since there are other fields already encrypted.
Relevant logs and/or screenshots
Output of checks
System information
System: Ubuntu 18.04
Proxy: no
Current User: xanbanx
Using RVM: no
Ruby Version: 2.6.3p62
Gem Version: 3.0.3
Bundler Version:1.17.2
Rake Version: 12.3.2
Redis Version: 4.0.9
Git Version: 2.23.0
Sidekiq Version:5.2.7
Go Version: go1.12.6 linux/amd64
GitLab information
Version: 12.3.0-pre
Revision: d777fa6dd9f
Directory: /home/xanbanx/gdk/gdk-ee/gitlab
DB Adapter: PostgreSQL
DB Version: 10.10
URL: http://localhost:3001
HTTP Clone URL: http://localhost:3001/some-group/some-project.git
SSH Clone URL: ssh://xanbanx@localhost:2222/some-group/some-project.git
Elasticsearch: yes
Geo: no
Using LDAP: no
Using Omniauth: yes
Omniauth Providers:
GitLab Shell
Version: 10.0.0
Repository storage paths:
- default: /home/xanbanx/gdk/gdk-ee/repositories
GitLab Shell path: /home/xanbanx/gdk/gdk-ee/gitlab-shell
Git: /usr/bin/git
Best regards,
Xanbanx
Impact
See above.
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 application settings model did not apply the existing encryption mechanism to these particular credential fields, so they were persisted as plaintext.
Impact
An attacker with access to the system could read sensitive information stored in plaintext.
What the attacker needed
Access to the GitLab database; administrator access to enter tokens
The fix
Sensitive tokens should be stored encrypted, using the encryption infrastructure already present for other application settings fields.
How it was found
- Enter the tokens in the GitLab settings.
- Open a PostgreSQL console (on a GDK via the rails db command).
- Run a query selecting the credential columns from application_settings.
- Observe the tokens returned in plaintext.
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.
When a website saves a password or API key, it should scramble it (encrypt it) so that anyone who peeks at the database cannot read it. Here, GitLab saved several keys as ordinary readable text, so someone who got into the database could simply read them. The reporter also noted the keys were shown openly in the admin interface.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.