Safeguard
Security Guides•

How do you teach developers good secrets handling habits?

Teach secrets handling with a clear rule set, a hands on exercise and a leak drill. Built on the OWASP CI/CD Insufficient Credential Hygiene risk.

Safeguard Security Team
3 min read

Teach secrets handling with three things: a plain rule set (no credentials in code, chat or tickets), a hands on exercise using your own tooling for storing and rotating them, and a drill for what to do the minute a credential leaks. Habits form through practice, not warnings.

Why habits beat rules

Everyone knows credentials should not be pasted into code. People still do it when a deadline is close and the proper path is slow. The rule fails because the safe way is harder than the unsafe way.

OWASP lists Insufficient Credential Hygiene as CICD-SEC-6 in its Top 10 CI/CD Security Risks, which shows how familiar and persistent the problem is in delivery pipelines.

The rule set

Keep it short enough to remember.

  1. Credentials live in the approved secrets store, never in code, config files in a repository, tickets or chat.
  2. Each credential has an owner and an expiry or rotation plan.
  3. Use the narrowest scope that works.
  4. Never reuse a credential across environments.
  5. If you suspect exposure, report immediately. No blame for reporting.

Rule five matters most. People hide mistakes when punished, and a hidden leaked credential is the worst case.

Make the safe path the easy path

Training will not hold if the approved method is painful. Before teaching, check that a developer can get a new credential into the right place in minutes. If not, fix the process first.

A hands on exercise

StepTask
1Create a test credential in the approved store
2Retrieve it from a sample app without writing it into code
3Rotate it and confirm the app still works
4Revoke it and observe the failure

Run it in a sandbox with throwaway credentials. Fifteen to twenty minutes is enough.

The leak drill

Walk through this sequence on paper once a quarter:

  1. Revoke or rotate the credential first, before cleanup.
  2. Work out what it could access and check for use during the exposure window.
  3. Remove it from the place it leaked. Remember that removing it from the latest commit does not remove it from history.
  4. Record what happened and what change would prevent a repeat.
  5. Tell the people who need to know.

The key lesson: treat any exposed credential as compromised, whatever the audience seemed to be.

Common traps to teach

  • Credentials in sample code that gets copied.
  • Credentials echoed in build logs.
  • Long lived keys created for a one off task and forgotten.
  • Shared accounts with no clear owner.

Where Safeguard fits

Safeguard offers policies and gates, compliance evidence automation and agent identity. It does not offer secret scanning, and it does not offer training courses. Use your existing secrets tooling for detection. A free dependency and code scan is at gold.safeguard.sh/scan.

Quick check

Is deleting a leaked secret from the repository enough?

No. It stays in history and may already be copied. Revoke or rotate it first.

How often should credentials be rotated?

Set a schedule based on sensitivity and what your tooling supports, and rotate immediately on suspected exposure.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.