Skip to main content

Hardcoded Secrets Check

Credentials embedded in metadata can travel with it to another org. The Hardcoded Secrets check runs among the pre-deployment checks and lists potential credentials as masked findings for you to review before deploying.

Hardcoded Secrets check with three findings, each with the component, line, secret type and a masked value

What is scanned​

The check reads the selected component bodies already available to this deployment, including manual overrides. Supported types are:

  • Apex classes, triggers, Visualforce pages and components
  • Lightning components (Aura and LWC)
  • Static resources, including text files inside zip archives
  • Custom metadata records, custom labels and flows
  • Named credentials and remote site settings

Binary files and text files larger than 5 MiB are skipped. A scan is limited to 60 MiB of text and up to 3,000 file entries per static-resource ZIP. Bodies that have not been loaded, cannot be read, or are fetched only during deployment are not scanned. A passed check describes the content that was scanned, not a guarantee that every file in the eventual deployment was checked.

The check is shown only when the deployment contains one of the supported types.

The scanner looks for API keys and access tokens of common services, Salesforce access and refresh tokens, private keys, passwords assigned in code or written into URLs, and similar credentials.

Reading the findings​

Each finding shows the component, the line, the type of secret and a masked value, for example b2dc••••••••. The check moves to Review when it finds something. It doesn't block the deployment.

To fix a finding, move the value out of the code into an appropriate credential store, such as a Named Credential, and reference it from the component.

Hiding a finding that isn't a secret​

Some values only look like credentials: a placeholder, a test key from vendor documentation, code from a managed package. Click Hide… next to the finding and choose what to hide:

  • This finding: this value in this file. The same value anywhere else is still reported.
  • Whole file: every secret found at this file location, including values added there later. For a bundle or static-resource ZIP, this covers the reported file or entry, not the whole bundle or archive.
  • This value everywhere: this exact value in every file of the team, in any deployment.

Then pick a reason (Not a secret, Third-party code or Accepted risk), describe it in one sentence, and set an expiry date. The default is 90 days, and the maximum is 180. When the exception expires, the check shows the finding again.

Hide secret finding dialog with the three options, the reason and the expiry date

Exceptions belong to the team and apply to all of its deployments. The check card keeps hidden findings under Show N findings hidden by team exceptions.

To see every exception of the team, open Team Settings → Secret scan, or click View all team exceptions in the check. The list shows who hid each finding, why, and when the exception expires. Reopen lifts an exception, so the check shows the finding again. Who hid it and why stays in the list.

Hiding and reopening findings requires the Manage Exceptions permission under Secret Scan in Team Settings → Roles & permissions.

Your secrets and your metadata​

  • Found secrets are not stored. mtdt.io keeps only a one-way hash of each value. The hash lets an exception recognise the same value in later scans, but the value can't be recovered from it. For convenience, mtdt.io also keeps the length of the value and a short prefix of long secrets, so you can find them later.
  • The scan runs on mtdt.io's own servers with gitleaks, an open-source secret scanner. The check reads the component bodies that mtdt.io already holds for this deployment and does not send those files to a third-party scanning service. The files are written to a temporary folder for the scan and deleted as soon as it finishes.