Version 1.4
5 September 2024
Shlomi Shaki, @Sentry01
GitHub Copilot GTM Lead, Asia Pacific & Japan
In today’s digital age, the security of sensitive systems and information is more important than ever. With the rise of cyberattacks and data breaches, it’s crucial for organizations to take proactive measures to protect their systems from unauthorized access through stolen credentials and secrets that were left in plain sight.
The real cost of remediating leaked secrets is often misunderstood or underestimated by engineering and security teams alike. The purpose of this document is to raise awareness to the hidden costs and activities that are associated with mismanaged secrets in repositories or code.
Through research and conversations with a number of large enterprise organizations, the remediation of secrets often takes a number of days through to weeks and could cost an estimated $3,000-$16,000 per secret remediation
In this brief, we will discuss the importance of proper secret management to prevent leaks and the steps that organizations need to take when they find a secret in the code.
Secrets are sensitive pieces of information that should be kept confidential. They can include passwords, API keys, and other credentials that are used to access systems or services. Secrets are often stored in code repositories, issues, discussions, or configuration files, making them vulnerable to unauthorized access through accidental or malicious activities.
Secure secret management is important and is imperative to prevent unauthorized access to sensitive information. Unfortunately, many developers fail to use proper secret management practices despite knowing that hardcoding passwords or secrets is risky. Secrets that are not properly managed can be exposed accidentally or maliciously to attackers who can then use them to gain access to systems or services. This could result in data breaches, financial loss, reputational damage, and even loss of lives. Credential theft and exploitation are often the most common attack vectors.
Here are some of the most common best practices for secure secret management:
Detailed best practices on managing secrets are out of scope for this document, however, more can be read on this topic from OWASP here: Secrets Management - OWASP Cheat Sheet Series. You can also read more from Microsoft Azure Key Vault here Best practices for secrets management in Key Vault - Microsoft Learn.
Once secrets have been detected in your code by a secret scanning tool like GitHub Advanced Security’s secret scanning, they ultimately must be revoked/rotated, although there are a number of other activities that need to be taken into account. Once detected, time is of the essence as the secret may further spread and malicious attackers may be able to use that secret to gain unauthorized access to key infrastructure and cloud assets to establish a foothold and move laterally.
Dealing with secrets that were found in your code and repositories is often misunderstood, underestimated, and undocumented. Often, developers believe that removing those from the code itself is sufficient but forget that the secret may have already been accessed or leaked, as well as the fact that they still exist in the Git history and could leak out if the entire repository was cloned.
The diagram below shows an example process flow to handle secrets that are found. Note the time and effort each step takes. Shifting left to eliminate those mistakes will save considerable time, costs, and effort in remediation.
Note: Many of the steps below should happen in parallel. Some of those steps are almost always cyclical (such as re-validating, testing, and remediating multiple apps in case of shared secrets)
Removing secrets from code and Git history can be complex and has many considerations. Here are some of the challenges that organizations may face when implementing secret removal:
Detailed steps to take once a secret is found in the repository:
There are numerous costs associated with hardcoded secrets, including the risk assessment, investigation, code remediation, auditing, and in unfortunate cases where the leaked secret has been exploited, the costs associated with a breach.
In order to help quantify the cost to remediate each secret, we need to calculate the effort of each remediation step (in FTE days) and multiply it by daily fully loaded cost per day.
Remediation costs per one secret = effort to remediate the secret * fully loaded daily rate
The cost of remediation usually grows exponentially with the size and complexity of the organization. As such, we need to make a distinction between large complex enterprise organizations and smaller organizations.
At an estimated US$640 fully loaded cost per engineering day smaller organizations could spend around $1,600 on average per leaked secret (provided it has not been used in multiple apps) and in large complex organizations this could escalate to $3,200-$16,000 on average. See the total economic impact by Forrester
Complex enterprise organizations: (more than 1,500 engineers)
Estimated between 5 - 25 FTE days of remediation effort per secret found * $640 per day
Cost to remediate a single secret = $3,200-$16,000
Small organizations:
Estimated between 0.5 - 5 FTE of remediation effort days per secret found * $640 per day
Cost to remediate a single secret = $320- $3,200
Below is a simple secret remediation cost calculator example:
Notes:
The below screenshot from GitHub’s security overview demonstrates the amount of secrets that have been successfully blocked before they ever manage to leak into the Git history and repository, allowing organizations to avoid the associated potential secret remediation costs.
How do I stay clean:
Organizations can avoid the most common mistakes pertaining to secrets and therefore avoid costly and lengthy remediation, by applying good security awareness practices to the developers, and ensuring policies for secure secret management are being followed.
In addition, we recommend organizations activate GitHub’s (or Microsoft’s ADO) push protection to alert developers from accidentally including hardcoded secrets in the code repositories or in GitHub Issues. Consider delegated bypass for push protection to add another line of review and defense.
To learn more: Push protection for repositories and organizations - GitHub Enterprise Cloud Docs
Secure secret management is critical for protecting sensitive information from unauthorized access. By following best practices for secure secret management and taking proactive measures when secrets are found in code, organizations can reduce the risk of data breaches and reputational damage whilst also avoiding unnecessary remediation and investigation costs due to leaked secrets.
Finally, it is exponentially cheaper to prevent the secrets from ever being hardcoded, than to remediate them after the fact.