SecretBench: A Dataset of Software Secrets

July 24, 2023 · View on GitHub

License: MIT DOI

Accepted at the Data and Tool Showcase Track of the 20th International Conference on Mining Software Repositories (MSR 2023)

Table of Contents

Introduction

Throughout 2021, GitGuardian’s monitoring of public GitHub repositories revealed a two-fold increase in the number of secrets (API keys, Authentication Tokens, Database Credentials, and other credentials) exposed compared to 2020, accumulating more than six million secrets. However, no benchmark dataset is publicly available for researchers and tool developers to improve secret detection tools to avoid secret leakage.

We present a large and versatile dataset, SecretBench, consisting of 97,479 manually labeled secrets of various secret types extracted from 818 public GitHub repositories. The dataset contains 15,084 true secrets out of 97,479 secrets. Our dataset covers 49 programming languages and 311 file types. We have made the dataset available for researchers and tool developers in Google BigQuery and Cloud Storage.

How to Use

The dataset is stored in Google BigQuery and Cloud Storage. First, you need to create a Google Cloud Account. Google Cloud gives a $300 free credit after opening the account. You can run SQL queries in Google BigQuery to access the secrets and download repositories and related files from Google Cloud Storage.

  • Google BigQuery Dataset id (dev-range-332204.secretbench.secrets): Google BigQuery contains 97,479 secrets with ground truth info, whether the secret is true or false. Addition metadata information regarding the secrets such as commit id, start line, and end line can also be accessed. More details of the metadata is described in Data Overview section.
  • Google Cloud Storage (bucket-name: secretbench): The mined 818 public GitHub repositories are stored in Google Cloud Storage in a "Repos.zip" file. We have also stored the individual files containing the secrets in a "Files.zip" file.

Important: The researchers and developers who want to use our dataset need to contact us. Since the dataset contains sensitive information, a data protection agreement has to be signed with us to avoid any unethical use of the data. Later, we will give access to the dataset using their email addresses.

Data Overview

Regular Expressions:

We used 761 regular expression patterns to collect candidate repositories containing secrets. A snapshot of 10 regular expression patterns is presented in the below table. The complete list of regular expression patterns can be found here.

Pattern IDSecret TypeRegular ExpressionSource
65AWS API Secret\b([A-Za-z0-9+/]{40})[ \r\n'"\x60]TruffleHog
71Azure Client Secret(?i)(%s).{0,20}([a-z0-9_.-~]{34})TruffleHog
216Dropbox API Key\b(sl.[A-Za-z0-9-_]{130,140})\bTruffleHog
237Facebook Access TokenEAACEdEose0cBA[0-9A-Za-z]+Meli et al.
278Generic Pattern(?i)(?:pass|token|cred|secret|key)(?:.|[\n\r]){0,40}(\b[\x21-\x7e]{16,64}\b)TruffleHog
290Github Token\b((?:ghp|gho|ghu|ghs|ghr)_[a-zA-Z0-9]{36,255})\bTruffleHog
605Slack Token(xoxb|xoxp|xapp|xoxa|xoxr)-[0-9]{10,13}-[a-zA-Z0-9-]*TruffleHog
640Stripe API Key[rs]k_live_[a-zA-Z0-9]{20,30}TruffleHog
691Twitter Access Token(?i)(?:twitter)(?:.|[\n\r]){0,40}\b[1-9][0-9]+-[0-9a-zA-Z]{40}\bMeli et al.
747Youtube/Google OAuth ID[0-9]+-[0-9A-Za-z_]{32}.apps.googleusercontent.comMeli et al.

Overview of SecretBench Metadata:

We curated 818 public Github repositories and extracted 97,479 candidate secrets. Out of 97,479 secrets, we labeled 15,084 secrets as true secrets. Each secret is manually labeled by finding out whether the secret is actual or not after inspecting the secret and the source code context of the secret. Below we present an overview of the SecretBench data.

Field NameDescriptionData Type
idUnique identifier of the secret.String
secretCandidate secret string. The secret is surrounded by "[]" parenthesis.String
repo_nameName of the repository. For example: "setu1421/SecretBench"String
domainDomain of the repository such as GitHubString
commit_idCommit hash where the secret is added. For example: "a074a5afe1d2663fda756c1bf3c87bad426cf7de"String
file_pathFile path where the secret is included. For example: "dev.config" and "config/test.env".String
file_typeType of the file such as .py and .config.String
start_lineStart line no. in the file where the secret is present.Integer
end_lineEnd line no. in the file where the secret is present. For secrets present in a single line, the start_line and end_line will be same.Integer
start_columnStart index of the secret in the start line.Integer
end_columnEnd index of the secret in the end line.Integer
committer_emailEmail address of the developer who committed the secret.String
commit_dateThe timestamp of the commit. For example: 2018-10-24T21:22:19ZTimeStamp
labelThe ground truth label of the secret. "True" for actual secret and "False" for fake/dummy secret.Boolean
is_templateFlag to indicate if the secret is a placeholder such as "MY_PASSWORD" and "Place_Your_Token_Here".Boolean
in_urlFlag to indicate if the secret is part of URL such as "http://user:pwd@site.com".Boolean
entropyShannon entropy value of the secret.Float
character_setCharacters used in the secret such as NumberOnly, CharOnly and Any.String
has_wordsFlag to indicate if any common English word of at least length of 4 is present within the secret.Boolean
lengthLength of the secret.Integer
is_multilineFlag to indicate if the secret is present in multiple lines. Most of the time true for private keys.Boolean
categoryThe category of the secret. The secrets are categorized in eight categories. See section Secret Categorization.String
file_identifierUnique identifier of the file to check the secret from local system.String
repo_identifierUnique identifier of the repository to check the secret from local system.String
commentA description of the secret types such as Slack Token, AWS Access Key ID and Value with "key" as part of attribute name.String

The "repo_identifier" and "file_identifier" can be used to locate the specific repository and the file where the secret is present. The repositories and files can be downloaded from Google Cloud Storage. See Section How to Use.

Secret Categorization:

The secrets present in our dataset in categorized into eight categories. In the table below, we present the number of total candidate secrets, true secrets, and the category description.

Category NameDescriptionTrue SecretsTotal Secrets
Private KeyThis category contains the private keys such as cryptographic RSA private key and EC private key.5,7898,584
API Key and SecretThis category contains any API Keys and secret such as Twillo API key and Stripe API key.4,5295,162
Authentication Key and TokenThis category contains the access keys and tokens such as AWS Access Key ID and Slack Token.3,5695,833
Generic SecretThis category contains any generic secrets such application package secret, recaptcha site key.334439
Database and Server URLThis category contains the database and server URLs. For example. any mongoDB connection string and any FTP server url.1629,970
PasswordThis category contains any plain text passwords.150705
UsernameThis category contains any plain text usernames.2796
OtherThis category contains other possible secrets such as Package Key ID or any random string.52466,690

Programming Languages:

Our dataset covers 49 programming languages. Note that each GitHub repository can have multiple programming languages. The top 10 programming languages based on the number of repositories is presented below. The full list of programming languages can be found here.

Language NameNo. of Repository
Shell459
JavaScript414
Python312
Java180
Ruby172
C128
Batch124
C++111
PHP107
Go88

File Types:

Our dataset consists of secrets present in 311 file types. Below we present the top 5 file types based on the number of candidate secrets in our dataset. The full list of file types can be found here.

File typeDescriptionTotal Secrets
jsJavascript file10,412
nixPackage Manager File8,623
jsonJavaScript Object Notation File8,132
txtText File7,737
xmlExtensible Markup Language File6,429

In addition, we present the top 5 file types based on the number of true secrets in our dataset.

File typeDescriptionTotal Secrets
txtText File2,935
tomlConfiguration File1,985
jsJavascript file1,583
htmlHypertext Markup Language File1,337
pemPrivacy Enhanced Mail Format File813

Future RoadMap:

  • Currently, our dataset consists of only GitHub repositories. We will expand our dataset by including repositories from other version control systems such as Gitlab and Bitbucket.
  • We will enrich our dataset with more features related to secrets, such as whether the secrets have parentheses (possible function call) and begin with a $ sign (possible variable). The complete list of our additional features is available here.

License:

This project is licensed under the terms of the MIT license. Please check LICENSE for more details.

Ethics:

Since our dataset contains sensitive information, we will make available to dataset only to researchers and tool developers. The researchers and tool developers will sign an agreement to protect the data from any unethical use.

How to Contribute

Please email us if you want to contribute. See Authors section for contact information.

Authors:

Cite our work:

BibTex

@INPROCEEDINGS{10174157,
  author={Basak, Setu Kumar and Neil, Lorenzo and Reaves, Bradley and Williams, Laurie},
  booktitle={2023 IEEE/ACM 20th International Conference on Mining Software Repositories (MSR)}, 
  title={SecretBench: A Dataset of Software Secrets}, 
  year={2023},
  volume={},
  number={},
  pages={347-351},
  doi={10.1109/MSR59073.2023.00053}}

Plain Text

S. K. Basak, L. Neil, B. Reaves and L. Williams, "SecretBench: A Dataset of Software Secrets," 2023 IEEE/ACM 20th International Conference on Mining Software Repositories (MSR), Melbourne, Australia, 2023, pp. 347-351, doi: 10.1109/MSR59073.2023.00053.