Harness secrets

From Intense-Visions/harness-engineering · View interactive version

Harness secrets is an AI agent skill from the GitHub repository Intense-Visions/harness-engineering. > Secret detection, credential hygiene, and vault integration. Find exposed secrets, classify risk, and enforce externalization before they reach production.

How to use this skill

Skill file

Harness Secrets

Secret detection, credential hygiene, and vault integration. Find exposed secrets, classify risk, and enforce externalization before they reach production.

When to Use

Process

Phase 1: SCAN -- Detect Secrets in Source Code

  1. Scan source files for secret patterns. Search for common secret formats:
  1. Scan configuration files. Check files that commonly contain secrets:
  1. Check .gitignore coverage. Verify that sensitive files are excluded from version control:
  1. Scan git history for leaked secrets. Check recent commits:
  1. Present scan results:

```

Secret Scan: 7 findings in 5 files

CRITICAL (2):

src/config/database.ts:8 -- Hardcoded PostgreSQL connection string with password

src/services/stripe.ts:3 -- Stripe secret key (sk_example_...)

HIGH (3):

docker-compose.yml:15 -- MySQL root password in plaintext

src/config/aws.ts:12 -- AWS access key pattern (AKIA...)

.env.production:1 -- File committed to git (should be gitignored)

MEDIUM (2):

src/utils/auth.ts:45 -- JWT secret as string literal

config/app.json:22 -- Generic "apiKey" field with literal value

```


Phase 2: CLASSIFY -- Categorize by Risk and Type

  1. Assign severity levels. Classify each finding:
  1. Identify secret type. Categorize each finding:
  1. Assess blast radius. For each CRITICAL and HIGH finding:
  1. Check for false positives. Verify findings are actual secrets:
  1. Generate classification report:

```

Classification:

CRITICAL: 2 (require immediate rotation)

HIGH: 3 (require rotation within 24 hours)

MEDIUM: 2 (require externalization)

LOW: 0

False positives: 1 (removed from findings)

Affected systems:

```


Phase 3: REMEDIATE -- Extract and Secure Secrets

  1. Recommend secret externalization. For each finding, provide the remediation:
  1. Recommend secret management integration. Based on the project's infrastructure:
  1. Recommend rotation procedure. For each CRITICAL and HIGH finding:
  1. Provide code transformation examples. Show before/after for each finding:

```typescript

// BEFORE (hardcoded)

const stripe = new Stripe('sk_example_abc123...');

// AFTER (externalized)

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);

```

  1. If --fix flag is set, apply automatic transformations:

Phase 4: VALIDATE -- Verify Remediation Completeness

  1. Re-scan after remediation. Run the same scan from Phase 1 to verify:
  1. Verify .gitignore coverage. Confirm:
  1. Verify .env.example completeness. Check that:
  1. Check git history for residual exposure. If secrets were previously committed:
  1. Generate validation report:

```

Secret Validation: [PASS/WARN/FAIL]

Rescan: PASS (0 CRITICAL, 0 HIGH findings)

.gitignore: PASS (all sensitive patterns covered)

.env.example: WARN (missing STRIPE_WEBHOOK_SECRET entry)

Git history: WARN (2 secrets exist in history -- rotation required)

Actions remaining:

1. Add STRIPE_WEBHOOK_SECRET to .env.example

2. Rotate PostgreSQL password (exposed in commit abc1234)

3. Rotate Stripe key (exposed in commit def5678)

4. Consider git history rewrite after rotation

```


Harness Integration

Success Criteria

Examples

Example: Express.js API with Hardcoded Stripe Keys

Phase 1: SCAN
  Scanned: 86 files
  Findings: 4

  CRITICAL: src/payments/stripe.ts:5 -- sk_example_EXAMPLE_KEY_REDACTED_0000
  HIGH: docker-compose.yml:22 -- POSTGRES_PASSWORD=supersecret
  MEDIUM: src/config/jwt.ts:3 -- JWT_SECRET = "my-jwt-secret-key"
  LOW: tests/fixtures/auth.ts:8 -- fake-api-key-for-testing (false positive)

Phase 2: CLASSIFY
  CRITICAL: 1 (Stripe production secret key -- full payment access)
  HIGH: 1 (PostgreSQL password -- database access)
  MEDIUM: 1 (JWT secret -- token forgery risk)
  False positives: 1 (test fixture removed from findings)

Phase 3: REMEDIATE
  1. Stripe key -> process.env.STRIPE_SECRET_KEY
  2. Postgres password -> ${POSTGRES_PASSWORD} in compose, actual value in .env
  3. JWT secret -> process.env.JWT_SECRET
  Added 3 entries to .env.example
  Updated .gitignore with .env* pattern

Phase 4: VALIDATE
  Rescan: PASS (0 findings)
  .gitignore: PASS
  .env.example: PASS (all 3 variables documented)
  Git history: WARN (Stripe key in commit history)
  Result: WARN -- secrets externalized, rotation required for Stripe and Postgres

Example: Django Application with AWS Credentials

Phase 1: SCAN
  Scanned: 124 files
  Findings: 5

  CRITICAL: settings/production.py:45 -- AWS_ACCESS_KEY_ID = "AKIA..."
  CRITICAL: settings/production.py:46 -- AWS_SECRET_ACCESS_KEY = "wJal..."
  HIGH: .env.production committed to git (12 secrets inside)
  MEDIUM: settings/base.py:88 -- SECRET_KEY = "django-insecure-..."
  MEDIUM: settings/base.py:92 -- DATABASE_URL with embedded password

Phase 2: CLASSIFY
  CRITICAL: 2 (AWS IAM credentials -- full account access)
  HIGH: 1 (.env.production in git -- 12 leaked values)
  MEDIUM: 2 (Django secret key and database URL)

Phase 3: REMEDIATE
  1. AWS credentials -> boto3 credential chain (env vars or IAM role)
  2. Remove .env.production from git, add to .gitignore
  3. Django SECRET_KEY -> os.environ["DJANGO_SECRET_KEY"]
  4. DATABASE_URL -> os.environ["DATABASE_URL"]
  Recommend: Switch to django-environ for all settings
  Recommend: Use IAM roles instead of access keys for production

Phase 4: VALIDATE
  Rescan: PASS
  .gitignore: PASS
  .env.example: PASS
  Git history: CRITICAL (AWS keys and .env.production in history)
  Result: FAIL -- rotation required before deployment, history rewrite recommended

Rationalizations to Reject

| Rationalization | Reality |

| ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| "That key is read-only so it's not a big deal if it leaks" | Read-only credentials still enable data exfiltration, reconnaissance, and discovery of other vulnerabilities. A leaked read-only database credential exposes every row in the database. Scope does not eliminate risk. |

| "We removed it from the file — it's cleaned up now" | Removing a secret from the current tree does not remove it from git history. Anyone with a clone of the repository can recover the secret with git log -p. Rotation is required regardless of file deletion. |

| "That's a test environment key, not production" | Test environment credentials are frequently reused, shared informally, and rotated less often. Leaked test keys also reveal credential patterns and naming conventions that help attackers guess production secrets. |

| "It's in a private repo so only our team can see it" | Private repos are accessed by CI/CD systems, third-party integrations, contractors, and former employees. Repository access controls are not a substitute for secret externalization. Breaches routinely originate from compromised internal access. |

| "We'll move it to an environment variable before we deploy" | Intent does not prevent exposure. The secret is in the codebase now and may already be in commit history, CI logs, or developer machine caches. Remediation must happen at the moment of detection, not at deployment time. |

Gates

Escalation

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.