agentleFS
terrene-foundationterrene-foundation/pact/.claude/skills/18-security-patterns/SKILL.md

security-patterns

Skill0 starsChanged 7 months agoApache-2.0View on GitHub

Security patterns and best practices for Kailash SDK including input validation, secret management, injection prevention, authentication, authorization, and OWASP compliance. Use when asking about 'security', 'secrets', 'authentication', 'authorization', 'injection prevention', 'input validation', 'OWASP', 'credentials', 'API keys', 'secure coding', or 'security review'.

  • Reads credentials

9 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security-fuzzing and security-payloads.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • EyadkellehSkill

    security-fuzzing

    Essential fuzzing payloads: SQL injection, command injection, special characters. Curated essentials for vulnerability testing.

    Also in 3 projects that use this

  • EyadkellehSkill

    security-payloads

    Essential exploitation payloads: anti-virus test files, file name exploits, malicious files. Curated for testing.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 8 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When making outbound HTTP requests to user-supplied URLs:

    line 104
  2. Distinctive:

    Never return raw exception messages to clients — they leak file paths, class names, database URLs.

    line 116
  3. Distinctive:

    Use this skill when:

    line 149

“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Security Patterns - Kailash SDK

Mandatory security patterns for all Kailash SDK development. These patterns prevent common vulnerabilities and ensure secure application development.

Overview

Security patterns cover:

  • Secret management (no hardcoded credentials)
  • Input validation (prevent injection attacks)
  • Authentication and authorization
  • OWASP Top 10 prevention
  • Secure API design
  • Environment variable handling

Critical Rules

1. NEVER Hardcode Secrets

# ❌ WRONG - Hardcoded credentials
api_key = "sk-1234567890abcdef"
db_password = "mypassword123"

# ✅ CORRECT - Environment variables
import os
api_key = os.environ["API_KEY"]
db_password = os.environ["DATABASE_PASSWORD"]

2. Validate All User Inputs

# ❌ WRONG - No validation
def process_user_input(user_data):
    return db.execute(f"SELECT * FROM users WHERE id = {user_data}")

# ✅ CORRECT - Parameterized queries (via DataFlow)
workflow.add_node("User_Read", "read_user", {
    "id": validated_user_id  # DataFlow handles parameterization
})

3. Use HTTPS for API Calls

# ❌ WRONG - HTTP in production
workflow.add_node("HTTPRequestNode", "api", {
    "url": "http://api.example.com/data"  # Insecure!
})

# ✅ CORRECT - HTTPS always
workflow.add_node("HTTPRequestNode", "api", {
    "url": "https://api.example.com/data"
})

Reference Documentation

Core Security

  • security-secrets - Secret management patterns
  • security-input-validation - Input validation
  • security-injection-prevention - SQL/code injection prevention

Authentication & Authorization

  • security-auth-patterns - Auth best practices
  • security-api-keys - API key management
  • security-tokens - Token handling

OWASP Compliance

  • security-owasp-top10 - OWASP Top 10 prevention
  • security-audit-checklist - Security audit checklist

Security Checklist

Before Every Commit

  • No hardcoded secrets (API keys, passwords, tokens)
  • All user inputs validated
  • SQL/code injection prevented
  • HTTPS used for all API calls
  • Sensitive data not logged
  • Error messages don't expose internals

Before Every Deployment

  • Environment variables configured
  • Secrets stored in secure vault
  • Authentication enabled
  • Authorization rules defined
  • OWASP Top 10 checked
  • Security review completed

SSRF Prevention (Webhook/Outbound HTTP)

When making outbound HTTP requests to user-supplied URLs:

  1. Validate URL scheme — only http:// and https://
  2. Resolve DNS and check IP — block RFC 1918, loopback, link-local, cloud metadata
  3. Check IPv4-mapped IPv6 — ::ffff:127.0.0.1 bypasses IPv4-only blocklists. Extract the mapped IPv4 address and re-validate
  4. Pin resolved IP — replace hostname with resolved IP in the URL to prevent DNS rebinding. Set Host header to original hostname
  5. Block 0.0.0.0/8 — routes to localhost on some systems

Reference implementation: See the Nexus webhook transport source for a working _validate_target_url() pattern.

Error Message Security

Never return raw exception messages to clients — they leak file paths, class names, database URLs.

# ❌ WRONG — leaks internals
return {"error": str(exception)}

# ✅ CORRECT — log internally, return generic message
log_exception("Operation failed")
return {"error": "Internal server error"}

Common Vulnerabilities Prevented

VulnerabilityPrevention Pattern
SQL InjectionUse DataFlow parameterized nodes
Code InjectionAvoid eval(), use PythonCodeNode safely
Credential ExposureEnvironment variables, secret managers
XSSOutput encoding, CSP headers
SSRFDNS-pinned delivery, blocked IP ranges
CSRFToken validation, SameSite cookies
Insecure DeserializationValidate serialized data

Integration with Rules

Security patterns are enforced by:

  • .claude/rules/security.md - Security rules
  • scripts/hooks/validate-bash-command.js - Command validation
  • gold-standards-validator agent - Compliance checking

When to Use This Skill

Use this skill when:

  • Handling user input or external data
  • Storing or transmitting credentials
  • Making API calls to external services
  • Implementing authentication/authorization
  • Conducting security reviews
  • Preparing for deployment

Related Skills

  • 17-gold-standards - Mandatory best practices
  • 16-validation-patterns - Validation patterns
  • 01-core-sdk - Core workflow patterns

Support

For security-related questions, invoke:

  • security-reviewer - OWASP-based security analysis
  • gold-standards-validator - Compliance checking
  • testing-specialist - Security testing patterns

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.