hardcoded-secrets

A security rule for finding passwords, private keys, API keys, tokens, and other credentials written directly into Forge app source or configuration files. Forge is Atlassian's platform for building apps for products such as Jira and Confluence.

In plain words
What is it for?
Scanning Forge app files for hardcoded basic-auth values, bearer tokens, API keys, cloud credentials, private keys, OAuth secrets, and password-containing database URLs.
Why use it?
Credentials committed to source code can be exposed and used by someone else. The rule points developers toward secret storage and environment variables instead.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/atlassian/forge-skills/hardcoded-secrets
Clone the repo
git clone --depth 1 https://github.com/atlassian/forge-skills
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,321 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00015 $0.01321
Opus 5 $0.00008 $0.00660
Sonnet 5 $0.00003 $0.00264
Haiku 4.5 $0.00002 $0.00132

Measured yesterday against content hash 03b28bc5d17a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

hardcoded-secrets scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

const response = await fetch(url, {
skills/forge-security-review/assets/security-rules/forge-secrets-storage/hardcoded-secrets.mdc · 175 lines

How it starts

The opening of the file, as written. The whole thing — 175 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Context

  • Hardcoded credentials in source code enable unauthorized access if code is exposed. Forge apps should use storage.setSecret() or Forge environment variables for sensitive values.
  • Related CWE: CWE-798 (Use of Hard-coded Credentials), CWE-259 (Use of Hard-coded Password).
  • Reference: Internal Forge VULN Guide to Hardcoded Basic Auth.

Scope & Signals

  • Secrets to detect:
    • Basic auth headers: Basic [base64]
    • Bearer tokens: Bearer [token]
    • API keys: api_key, apiKey, api-key with literal values
    • AWS credentials: AKIA..., secret access keys
    • Private keys: -----BEGIN PRIVATE KEY-----
    • OAuth secrets: client_secret with literal values
    • Database connection strings with passwords
  • Locations: Source files, config files (excluding node_modules, test fixtures).

Detection Patterns

# Basic Auth detection (refined)
grep -rlE '"Basic [A-Za-z0-9+/]*={1,2}"' --exclude-dir={node_modules,webpack} .
grep -rlE "'Basic [A-Za-z0-9+/]*={1,2}'" --exclude-dir={node_modules,webpack} .

# Bearer tokens
grep -rE 'Bearer [A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+' .

# API keys (common patterns)
grep -rE '(api[_-]?key|apiKey)\s*[:=]\s*["\047][A-Za-z0-9]{20,}["\047]' .

# AWS access keys
grep -rE 'AKIA[0-9A-Z]{16}' .

Vulnerable Patterns

// VULNERABLE - Hardcoded Basic auth
const headers = {
  'Authorization': 'Basic dXNlcm5hbWU6cGFzc3dvcmQ='
};

// VULNERABLE - Hardcoded API key
const API_KEY = 'sk-1234567890abcdef1234567890abcdef';
const response = await fetch(url, {
  headers: { 'X-API-Key': API_KEY }
});

// VULNERABLE - Hardcoded in config
const config = {
  database: {
    password: 'super_secret_password'
  }
};

// VULNERABLE - Hardcoded OAuth secret
const clientSecret = 'abc123-client-secret-xyz789';

// VULNERABLE - Hardcoded in environment-like object
const ENV = {
  STRIPE_SECRET_KEY: 'sk_live_abcdefghijklmnop'
};

Secure Patterns

// SECURE - Use Forge storage for secrets
import { storage } from '@forge/api';

async function getApiKey() {
  return await storage.getSecret('external-api-key');
}

// SECURE - Use Forge environment variables
// Set via: forge variables set API_KEY "value" --encrypt
const apiKey = process.env.API_KEY;

// SECURE - Use External Auth for OAuth
import { auth } from '@forge/api';

async function getExternalToken() {
  const token = await auth.getExternalAuth('my-external-service');
  return token.accessToken;
}

// SECURE - Retrieve at runtime, never hardcode
async function initializeClient() {
  const credentials = await storage.getSecret('service-credentials');
  return new ServiceClient(JSON.parse(credentials));
}

Detection Checklist

  • Search for Base64-encoded Basic auth headers.
  • Look for Bearer token patterns (JWT format).
  • Find API key variable assignments with literal strings.
  • Check for AWS access key patterns (AKIA...).
  • Search for private key file contents.
  • Review config objects for password/secret fields with values.
  • Exclude test fixtures and mock data from findings.

False Positive Handling

// FALSE POSITIVE - Placeholder in example/documentation
const API_KEY = 'YOUR_API_KEY_HERE';
const token = 'example-token-replace-me';

// FALSE POSITIVE - Test fixture
const mockAuth = 'Basic dGVzdDp0ZXN0';  // test:test

// FALSE POSITIVE - Schema/type definition
interface Config {
  apiKey: string;  // Not a hardcoded value
}

// TRUE POSITIVE - Real credential
const auth = 'Basic cHJvZHVjdGlvbjpyZWFsX3NlY3JldA==';  // Decodes to real secret

Semgrep Rules

rules:
  - id: hardcoded-basic-auth
    patterns:
      - pattern-regex: "Basic [A-Za-z0-9+/]{10,}={0,2}"
    message: "Potential hardcoded Basic auth credential"
    severity: ERROR

  - id: hardcoded-api-key
    patterns:
      - pattern: $VAR = "..."
      - metavariable-regex:
          metavariable: $VAR
          regex: (api[_-]?key|apiKey|API_KEY)
      - pattern-not: $VAR = "YOUR_API_KEY"
      - pattern-not: $VAR = ""
    message: "Potential hardcoded API key"
    severity: WARNING

Read the full file on GitHub · 175 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 175 lines · 15 tokens per session scan A 03b28bc5d17a

Subscribe to this mod's changes

hardcoded-secrets is a cursor rule published in the GitHub repository atlassian/forge-skills (20 stars, last pushed 2d ago), licensed Apache-2.0. It adds 15 tokens to every session and 1,321 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.