Skip to main content

Secret Scanning

What's covered

SAT scans notebook source, workspace files (.py, .sql, config, etc.), and cluster configurations for hardcoded credentials, and you manage scan coverage and custom detection rules from the app (Credential Exposure → Scan Settings & Custom Detection Rules). Each finding is tagged with its object type (Notebook, File, or Cluster) and links to the object in its workspace. Remove any credentials you find and store them as Unity Catalog secrets instead of hardcoding them.

Overview​

Developers sometimes hardcode credentials — API keys, tokens, passwords — directly in notebook source, workspace files, or cluster configurations and forget to remove them. These secrets can persist for months, readable by anyone with access to the code or cluster. SAT's secret scanning helps you find and remediate them.

What It Does​

SAT scans for hardcoded credentials with TruffleHog (800+ detector patterns) across three surfaces in one run:

  • Notebook source — every notebook in scope.
  • Workspace files — .py, .sql, .json, .yaml, .sh, and other text/config files.
  • Cluster configurations — spark_env_vars and the init scripts clusters reference (including init scripts on FUSE mount paths such as /Volumes/... and /dbfs/..., scanned as files so secrets in shell scripts are caught, not just env values).

Configure coverage and custom detection rules from the app (Credential Exposure → Scan Settings; see Usage).

Detection covers:

  • AWS credentials: Access keys, secret keys, session tokens
  • Azure secrets: Service principal keys, storage account keys
  • GCP credentials: Service account keys, API keys
  • GitHub tokens: Personal access tokens, OAuth tokens
  • API keys: Stripe, Slack, SendGrid, and other service API keys
  • Database passwords: Connection strings with embedded credentials
  • Private keys: SSH keys, RSA keys, and other cryptographic material
  • Databricks-specific tokens: DKEA, DAPI, DOSE tokens
Built for heavy workspaces
  • Init scripts referenced via FUSE mount paths are scanned alongside spark_env_vars.
  • TruffleHog is installed from a pinned tagged release for supply-chain reproducibility.
  • The cluster scan de-duplicates the many job clusters a busy workspace produces (scanning one per distinct env-var set), retries Delta writes under concurrent load, and fails loudly rather than silently reporting an incomplete scan as clean.

Why It Matters​

Hardcoded credentials — in notebooks, workspace files, or cluster configurations — pose significant security risks:

  • Persistent Exposure: Secrets stay in the code/config until explicitly removed
  • Broad Access: Anyone who can read the notebook, file, or cluster config can see them
  • Compliance Violations: Hardcoded secrets violate security best practices and compliance requirements
  • Attack Surface: Exposed credentials can be used to access cloud resources, databases, and external services

How It Works​

  1. Discovery: SAT enumerates notebooks and workspace files in scope, plus cluster configurations
  2. Pattern Detection: TruffleHog scans the content with 800+ detector patterns (plus any custom rules you add)
  3. Typing: Each finding is tagged with its object type — Notebook, File, or Cluster
  4. Reporting: Findings appear on the app's Credential Exposure page and are stored in your SAT schema (notebooks_secret_scan_results for notebooks and files, clusters_secret_scan_results for clusters)

Viewing Results​

Credential Exposure page​

The app's Credential Exposure page shows all findings together — notebooks, files, and clusters — with per-workspace and per-detector rollups, a type filter, and a summary. Each finding's object name links straight to the notebook, file, or cluster in its workspace.

Database tables​

Results are stored in your SAT schema:

  • notebooks_secret_scan_results — notebook and workspace-file findings (object_type is notebook or file), with the object id/path/name, detector, the secret's SHA‑256 (never the value), workspace, and scan time.
  • clusters_secret_scan_results — cluster findings, with the cluster id/name, the config field/key, detector, SHA‑256, workspace, and scan time.

Example Finding​

Object:   /Repos/dev/etl/load_orders  (Notebook)
Detector: AWS
Workspace: 1657683783405196
Recommendation: remove the hardcoded value; read it from a Unity Catalog secret

Remediation​

Remove hardcoded secrets

Remove hardcoded credentials from source and configuration and store them as Unity Catalog secrets, then read them at runtime. UC secrets are governed by Unity Catalog, and dbutils redacts their values in cell output and logs.

  1. Store the secret in Unity Catalog — create it under a catalog.schema you govern (see the Unity Catalog secrets guide). UC secrets use the three-level namespace catalog.schema.secret.
  2. Remove the hardcoded value from the notebook, workspace file, or cluster spark_env_vars.
  3. Read it at runtime with dbutils.secrets.get.
  4. Grant access so the principals and compute that need it can read the secret.

Example: read a Unity Catalog secret instead of hardcoding​

Before (insecure):

AWS_SECRET_ACCESS_KEY = "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"

After (secure) — read it from a Unity Catalog secret:

AWS_SECRET_ACCESS_KEY = dbutils.secrets.get(
catalog="main", schema="prod_app", key="aws_secret_access_key"
)

dbutils.secrets.get requires serverless (environment version 4+) or classic compute on Databricks Runtime 17.3 LTS or later.

Cluster environment variables

A cluster's spark_env_vars can't reference a Unity Catalog secret directly — move the value into a UC secret and read it in code with dbutils.secrets.get.

Configuration​

Configure secret scanning from the app — Credential Exposure → Scan Settings & Custom Detection Rules. Changes save to the scanner's config and take effect on the next scan run, with no redeploy and no editing notebooks.

  • Scan coverage — scan all notebooks and files (the default, so the view reflects your complete current exposure) or only objects modified in the last N days (a faster delta scan; the view then shows only that window).
  • Scan cluster configurations — on by default; turn it off to scan notebook and workspace-file source only.
  • Custom detection rules — add your own patterns (name, keywords, regex) on top of the built-in detectors, listed as editable rows you can change or delete. Rules apply to both notebook/file and cluster scans.
Clusters are always fully scanned

The coverage window applies to notebook and file discovery. Cluster configurations are always scanned in full; to keep a busy workspace tractable, job clusters that share the same spark_env_vars are de-duplicated so only one per distinct set is fetched and scanned.

Which workspaces are scanned​

Secret scanning follows the same collection scope as the rest of SAT (Data Collection → Manage): This workspace only scans the current workspace; Multiple workspaces scans every workspace the SAT service principal is a workspace admin of. Maintain that set with Manage → Sync workspaces — add the service principal as a workspace admin on a workspace and sync to include it, remove it and sync to drop it. See the Usage guide for the full workflow.

Firewall Allowlist Requirements​

If your environment uses firewalls, you may need to allowlist the following GitHub domains to ensure secret scanning can download TruffleHog and access required resources:

Firewall Configuration

If you encounter connection issues during secret scanning, ensure your firewall allows outbound connections to the following domains:

Allow outbound HTTPS (TCP 443) to all of these — the binary download redirects across several of them, so an incomplete list still fails:

  • raw.githubusercontent.com — the install script
  • github.com — the release download URL (returns a redirect)
  • release-assets.githubusercontent.com — where that redirect points (the TruffleHog binary); current GitHub release-asset host
  • objects.githubusercontent.com — legacy GitHub release-asset host (older releases / fallback)

api.github.com is not required — the TruffleHog version is pinned, so the installer builds the download URL directly rather than querying the API.

The binary is cached per compute container and re-downloaded whenever the scan lands on a fresh (cold) serverless container, so this egress must stay open, not just during the first run. If opening egress to GitHub isn't acceptable, host the pinned TruffleHog release on an internal mirror instead.

Best Practices​

Regular Scanning

Run secret scans regularly (weekly or bi-weekly) to catch newly introduced secrets before they become security risks.

Automated Workflows

Use the app's alerts to notify your security team when new secrets are detected in notebooks, files, or cluster configurations.

Developer Training

Educate developers on using Unity Catalog secrets instead of hardcoding credentials. Include this in onboarding and security training.

False Positives

Some patterns may trigger false positives (e.g. a cloud-resource identifier that looks token-shaped, or a template that wraps a value read from a secret). Review findings carefully, and exclude a detector or tune custom rules from the app's scan settings if needed.

Learn More​