Generated banner for Sharp Edges
Generated logo for Sharp Edges

Sharp Edges

Trail of BitsOfficialPublished by Trail of Bits

  • Skill
  • Guidelines
  • Security
  • CC-BY-SA-4.0
  • Medium risk

From the author

Identifies error-prone APIs, dangerous configurations, and footgun designs that enable security mistakes. Use when reviewing API designs, configuration schemas, cryptographic library ergonomics, or evaluating whether code follows 'secure by default' and 'pit of success' principles. Triggers: footgun, misuse-resistant, secure defaults, API usability, dangerous configuration.
— the description by Trail of Bits

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

Sharp Edges is a systematic analysis framework designed to identify 'footguns'—design patterns in APIs, libraries, and configurations that make it easy for developers to inadvertently introduce security flaws. By focusing on the 'pit of success' principle, this skill helps auditors and developers ensure that the path of least resistance is also the most secure one. It provides a structured workflow to probe for common pitfalls like weak algorithm selection, insecure defaults, silent failures, and type confusion, moving beyond simple bug hunting to address the root causes of developer-induced security mistakes.

What it does

  • Maps security-relevant APIs and configuration schemas for potential misuse.
  • Probes for edge cases like zero, null, or negative values that bypass security logic.
  • Evaluates whether default settings are secure by design.
  • Identifies cryptographic and authentication patterns prone to developer error.
  • Assesses the risk of silent failures and stringly-typed security interfaces.
  • Classifies findings by severity based on how easily a developer can trigger a vulnerability.

When to use it

  • During the design phase of new APIs or configuration schemas.
  • When auditing cryptographic library ergonomics and usage patterns.
  • When reviewing authentication and authorization interfaces.
  • When assessing whether code follows secure-by-default principles.
  • When evaluating the impact of developer-facing configuration options.

Advantages

  • Focuses on design-level flaws rather than just implementation bugs.
  • Promotes the 'pit of success' by identifying where secure usage is difficult.
  • Provides a repeatable, four-phase workflow for consistent analysis.
  • Helps prevent common security mistakes like algorithm confusion and insecure defaults.
  • Encourages the creation of misuse-resistant APIs.

Usage examples

“Analyze this authentication library for potential sharp edges.”
The agent will identify if the library allows empty passwords, uses predictable token generation, or has insecure default session timeouts.
“Review this configuration schema for dangerous options.”
The agent will flag boolean flags that disable security, unvalidated constructor parameters, or magic values that could lead to catastrophic failure.

Install

  1. Download the skill as a ZIP:

    https://mp-staging.autogineer.com/agent-skills/trailofbits/sharp-edges/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip sharp-edges.zip -d .agents/skills

Documentation by Trail of Bits

Sharp Edges Analysis

Evaluates whether APIs, configurations, and interfaces are resistant to developer misuse. Identifies designs where the "easy path" leads to insecurity.

When to Use

  • Reviewing API or library design decisions

  • Auditing configuration schemas for dangerous options

  • Evaluating cryptographic API ergonomics

  • Assessing authentication/authorization interfaces

  • Reviewing any code that exposes security-relevant choices to developers

When NOT to Use

  • Implementation bugs (use standard code review)

  • Business logic flaws (use domain-specific analysis)

  • Performance optimization (different concern)

Agent

The sharp-edges-analyzer agent runs the full sharp edges analysis workflow autonomously. Use it when you want a dedicated analysis of APIs, configurations, or interfaces for misuse resistance and footgun potential. The agent follows the four-phase workflow (Surface Identification, Edge Case Probing, Threat Modeling, Validate Findings) and reads language-specific references on demand.

Core Principle

The pit of success: Secure usage should be the path of least resistance. If developers must understand cryptography, read documentation carefully, or remember special rules to avoid vulnerabilities, the API has failed.

Rationalizations to Reject

RationalizationWhy It's WrongRequired Action
"It's documented"Developers don't read docs under deadline pressureMake the secure choice the default or only option
"Advanced users need flexibility"Flexibility creates footguns; most "advanced" usage is copy-pasteProvide safe high-level APIs; hide primitives
"It's the developer's responsibility"Blame-shifting; you designed the footgunRemove the footgun or make it impossible to misuse
"Nobody would actually do that"Developers do everything imaginable under pressureAssume maximum developer confusion
"It's just a configuration option"Config is code; wrong configs ship to productionValidate configs; reject dangerous combinations
"We need backwards compatibility"Insecure defaults can't be grandfather-clausedDeprecate loudly; force migration

Sharp Edge Categories

1. Algorithm/Mode Selection Footguns

APIs that let developers choose algorithms invite choosing wrong ones.

The JWT Pattern (canonical example):

  • Header specifies algorithm: attacker can set "alg": "none" to bypass signatures

  • Algorithm confusion: RSA public key used as HMAC secret when switching RS256→HS256

  • Root cause: Letting untrusted input control security-critical decisions

Detection patterns:

  • Function parameters like algorithm, mode, cipher, hash_type

  • Enums/strings selecting cryptographic primitives

  • Configuration options for security mechanisms

Example - PHP password_hash allowing weak algorithms:

// DANGEROUS: allows crc32, md5, sha1
password_hash($password, PASSWORD_DEFAULT); // Good - no choice
hash($algorithm, $password); // BAD: accepts "crc32"
2. Dangerous Defaults

Defaults that are insecure, or zero/empty values that disable security.

The OTP Lifetime Pattern:

# What happens when lifetime=0?
def verify_otp(code, lifetime=300):  # 300 seconds default
    if lifetime == 0:
        return True  # OOPS: 0 means "accept all"?
        # Or does it mean "expired immediately"?

Detection patterns:

  • Timeouts/lifetimes that accept 0 (infinite? immediate expiry?)

  • Empty strings that bypass checks

  • Null values that skip validation

  • Boolean defaults that disable security features

  • Negative values with undefined semantics

Questions to ask:

  • What happens with timeout=0? max_attempts=0? key=""?

  • Is the default the most secure option?

  • Can any default value disable security entirely?

3. Primitive vs. Semantic APIs

APIs that expose raw bytes instead of meaningful types invite type confusion.

The Libsodium vs. Halite Pattern:

// Libsodium (primitives): bytes are bytes
sodium_crypto_box($message, $nonce, $keypair);
// Easy to: swap nonce/keypair, reuse nonces, use wrong key type

// Halite (semantic): types enforce correct usage
Crypto::seal($message, new EncryptionPublicKey($key));
// Wrong key type = type error, not silent failure

Detection patterns:

  • Functions taking bytes, string, []byte for distinct security concepts

  • Parameters that could be swapped without type errors

  • Same type used for keys, nonces, ciphertexts, signatures

The comparison footgun:

// Timing-safe comparison looks identical to unsafe
if hmac == expected { }           // BAD: timing attack
if hmac.Equal(mac, expected) { }  // Good: constant-time
// Same types, different security properties
4. Configuration Cliffs

One wrong setting creates catastrophic failure, with no warning.

Detection patterns:

  • Boolean flags that disable security entirely

  • String configs that aren't validated

  • Combinations of settings that interact dangerously

  • Environment variables that override security settings

  • Constructor parameters with sensible defaults but no validation (callers can override with insecure values)

Examples:

# One typo = disaster
verify_ssl: fasle  # Typo silently accepted as truthy?

# Magic values
session_timeout: -1  # Does this mean "never expire"?

# Dangerous combinations accepted silently
auth_required: true
bypass_auth_for_health_checks: true
health_check_path: "/"  # Oops
// Sensible default doesn't protect against bad callers
public function __construct(
    public string $hashAlgo = 'sha256',  // Good default...
    public int $otpLifetime = 120,       // ...but accepts md5, 0, etc.
) {}

See config-patterns.md for detailed patterns.

5. Silent Failures

Errors that don't surface, or success that masks failure.

Detection patterns:

  • Functions returning booleans instead of throwing on security failures

  • Empty catch blocks around security operations

  • Default values substituted on parse errors

  • Verification functions that "succeed" on malformed input

Examples:

# Silent bypass
def verify_signature(sig, data, key):
    if not key:
        return True  # No key = skip verification?!

# Return value ignored
signature.verify(data, sig)  # Throws on failure
crypto.verify(data, sig)     # Returns False on failure
# Developer forgets to check return value
6. Stringly-Typed Security

Security-critical values as plain strings enable injection and confusion.

Detection patterns:

  • SQL/commands built from string concatenation

  • Permissions as comma-separated strings

  • Roles/scopes as arbitrary strings instead of enums

  • URLs constructed by joining strings

The permission accumulation footgun:

permissions = "read,write"
permissions += ",admin"  # Too easy to escalate

# vs. type-safe
permissions = {Permission.READ, Permission.WRITE}
permissions.add(Permission.ADMIN)  # At least it's explicit

Analysis Workflow

Phase 1: Surface Identification
  1. Map security-relevant APIs: authentication, authorization, cryptography, session management, input validation

  2. Identify developer choice points: Where can developers select algorithms, configure timeouts, choose modes?

  3. Find configuration schemas: Environment variables, config files, constructor parameters

Phase 2: Edge Case Probing

For each choice point, ask:

  • Zero/empty/null: What happens with 0, "", null, []?

  • Negative values: What does -1 mean? Infinite? Error?

  • Type confusion: Can different security concepts be swapped?

  • Default values: Is the default secure? Is it documented?

  • Error paths: What happens on invalid input? Silent acceptance?

Phase 3: Threat Modeling

Consider three adversaries:

  1. The Scoundrel: Actively malicious developer or attacker controlling config

    • Can they disable security via configuration?

    • Can they downgrade algorithms?

    • Can they inject malicious values?

  2. The Lazy Developer: Copy-pastes examples, skips documentation

    • Will the first example they find be secure?

    • Is the path of least resistance secure?

    • Do error messages guide toward secure usage?

  3. The Confused Developer: Misunderstands the API

    • Can they swap parameters without type errors?

    • Can they use the wrong key/algorithm/mode by accident?

    • Are failure modes obvious or silent?

Phase 4: Validate Findings

For each identified sharp edge:

  1. Reproduce the misuse: Write minimal code demonstrating the footgun

  2. Verify exploitability: Does the misuse create a real vulnerability?

  3. Check documentation: Is the danger documented? (Documentation doesn't excuse bad design, but affects severity)

  4. Test mitigations: Can the API be used safely with reasonable effort?

If a finding seems questionable, return to Phase 2 and probe more edge cases.

Severity Classification

SeverityCriteriaExamples
CriticalDefault or obvious usage is insecureverify: false default; empty password allowed
HighEasy misconfiguration breaks securityAlgorithm parameter accepts "none"
MediumUnusual but possible misconfigurationNegative timeout has unexpected meaning
LowRequires deliberate misuseObscure parameter combination

References

By category:

By language (general footguns, not crypto-specific):

See also references/language-specific.md for a combined quick reference.

Quality Checklist

Before concluding analysis:

  • [ ] Probed all zero/empty/null edge cases

  • [ ] Verified defaults are secure

  • [ ] Checked for algorithm/mode selection footguns

  • [ ] Tested type confusion between security concepts

  • [ ] Considered all three adversary types

  • [ ] Verified error paths don't bypass security

  • [ ] Checked configuration validation

  • [ ] Constructor params validated (not just defaulted) - see config-patterns.md

Files

references/config-patterns.md

Configuration Security Patterns

Dangerous configuration patterns that enable security failures.

Zero/Empty/Null Semantics

The Lifetime Zero Problem
# What does 0 mean?
session_timeout: 0    # Infinite timeout? Immediate expiry? Disabled?
token_lifetime: 0     # Never expires? Already expired? Use default?
max_attempts: 0       # No attempts allowed? Unlimited attempts?

Real-world failures:

  • OTP libraries where lifetime=0 means "accept any OTP regardless of age"

  • Rate limiters where max_attempts=0 disables rate limiting

  • Session managers where timeout=0 means "session never expires"

Detection: Any numeric security parameter that accepts 0.

Fix: Explicit constants, validation, or separate enable/disable flag.

# BAD
def verify_otp(code: str, lifetime: int = 300):
    if lifetime <= 0:
        return True  # What??

# GOOD
def verify_otp(code: str, lifetime: int = 300):
    if lifetime <= 0:
        raise ValueError("lifetime must be positive")
Empty String Bypass
# Passwords
if user_password == stored_hash:  # What if stored_hash is ""?

# API keys
if api_key == config.api_key:  # What if config is empty?
    grant_access()

# The empty string equals the empty string
"" == ""  # True - authentication bypassed

Detection: String comparisons for authentication without empty checks.

Null as "Skip"
// DANGEROUS: null means "skip verification"
function verifySignature(data, signature, publicKey) {
    if (!publicKey) return true;  // No key = trust everything?
    return crypto.verify(data, signature, publicKey);
}

// DANGEROUS: null means "any value"
function checkRole(user, requiredRole) {
    if (!requiredRole) return true;  // No requirement = allow all?
    return user.roles.includes(requiredRole);
}

Boolean Traps

Security-Disabling Flags
# Every one of these has caused real vulnerabilities
verify_ssl: false
validate_certificate: false
check_signature: false
require_auth: false
enable_csrf_protection: false
sanitize_input: false

Pattern: Any boolean that disables a security control.

The typo problem:

verify_ssl: fasle   # Typo - what does the parser do?
verify_ssl: "false" # String "false" - truthy in many languages!
verify_ssl: 0       # Integer 0 - falsy, but is it valid?
Double Negatives
# Confusing
disable_auth: false      # Auth enabled? Let me re-read...
skip_validation: false   # Validation runs? Think carefully...

# Clear
auth_enabled: true
validate_input: true

Magic Values

Sentinel Values in Security Parameters
# What do these mean?
max_retries: -1      # Infinite? Error? Use default?
cache_ttl: -1        # Never expire? Disabled?
timeout_seconds: -1  # Wait forever? Use system default?

# Real vulnerability: connection pool with max_connections: -1
# meant "unlimited" - enabled DoS via connection exhaustion
Special String Values
# Dangerous patterns
allowed_origins: "*"       # CORS wildcard
allowed_hosts: "any"       # Bypass host validation
log_level: "none"          # Disable security logging
password_policy: "disabled" # No password requirements

Detection: String configs that accept wildcards or "disable" keywords.

Combination Hazards

Conflicting Settings
# Both true - which wins?
require_authentication: true
allow_anonymous_access: true

# Both specified - conflict
session_cookie_secure: true
force_http: true  # HTTP can't use Secure cookies

# Mutually exclusive
encryption_key: "..."
encryption_disabled: true
Precedence Confusion
# In config file
verify_ssl: true

# But overrideable by environment?
VERIFY_SSL=false  # Which wins?

# And command line?
--no-verify-ssl   # Now there are three sources

Fix: Document precedence clearly; warn on conflicts; fail on contradictions.

Environment Variable Hazards

Sensitive Values in Environment
# Common but problematic
export DATABASE_PASSWORD="secret"
export API_KEY="sk_live_xxx"

# Risks:
# - Visible in process listings (ps aux)
# - Inherited by child processes
# - Logged in error dumps
# - Visible in container inspection
Override Attacks
# Application trusts environment
debug = os.environ.get("DEBUG", "false") == "true"

# Attacker with environment access:
export DEBUG=true  # Enables verbose logging of secrets

Detection: Security settings controllable via environment without validation.

Path Traversal via Config

Unrestricted Path Configuration
# User-controlled paths
log_file: "../../../etc/passwd"
upload_dir: "/etc/nginx/conf.d/"
template_dir: "../../../etc/shadow"

# Even "read-only" paths can leak secrets
config_include: "/etc/shadow"
certificate_file: "/proc/self/environ"

Fix: Validate paths; restrict to allowed directories; resolve and check.

Unvalidated Constructor Parameters

Configuration/parameter classes that accept security-relevant values without validation create "time bombs" - the insecure value is accepted silently at construction, then explodes later during use.

Algorithm Selection Without Allowlist
// DANGEROUS: Accepts any string including weak algorithms
readonly class ServerConfig {
    public function __construct(
        public string $hashAlgo = 'sha256',  // Accepts 'md5', 'crc32', 'adler32'
        public string $cipher = 'aes-256-gcm', // Accepts 'des', 'rc4'
    ) {}
}

// Caller can pass insecure values:
new ServerConfig(hashAlgo: 'md5');  // Silently accepted!

Detection: Constructor parameters named algo, algorithm, hash*, cipher, mode, *_type that accept strings without validation.

Fix: Validate against an explicit allowlist at construction:

public function __construct(public string $hashAlgo = 'sha256') {
    if (!in_array($hashAlgo, ['sha256', 'sha384', 'sha512'], true)) {
        throw new InvalidArgumentException("Disallowed hash algorithm: $hashAlgo");
    }
}
Timing Parameters Without Bounds
// DANGEROUS: No minimum or maximum bounds
readonly class AuthConfig {
    public function __construct(
        public int $otpLifetime = 120,     // Accepts 0 (immediate expiry? infinite?)
        public int $sessionTimeout = 3600, // Accepts -1 (what does this mean?)
        public int $maxRetries = 5,        // Accepts 0 (no retries? unlimited?)
    ) {}
}

// All of these are silently accepted:
new AuthConfig(otpLifetime: 0);      // OTP always expired or never expires?
new AuthConfig(otpLifetime: 999999); // ~11 days - replay attacks!
new AuthConfig(maxRetries: -1);      // Unlimited retries = brute force

Detection: Numeric constructor parameters for *lifetime, *timeout, *ttl, *duration, max_*, min_*, *_seconds, *_attempts without range validation.

Fix: Enforce both minimum AND maximum bounds:

public function __construct(public int $otpLifetime = 120) {
    if ($otpLifetime < 2) {
        throw new InvalidArgumentException("OTP lifetime too short (min: 2 seconds)");
    }
    if ($otpLifetime > 300) {
        throw new InvalidArgumentException("OTP lifetime too long (max: 300 seconds)");
    }
}
Hostname/URL Parameters Without Validation
// DANGEROUS: No format validation
readonly class NetworkConfig {
    public function __construct(
        public string $hostname = 'localhost',  // Accepts anything
        public string $callbackUrl = '',        // Accepts malformed URLs
    ) {}
}

// Silently accepted:
new NetworkConfig(hostname: '../../../etc/passwd');
new NetworkConfig(hostname: 'localhost; rm -rf /');
new NetworkConfig(callbackUrl: 'javascript:alert(1)');

Detection: String constructor parameters named host, hostname, domain, *_url, *_uri, endpoint, callback* without validation.

Fix: Validate format at construction:

public function __construct(public string $hostname = 'localhost') {
    if (!filter_var($hostname, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
        throw new InvalidArgumentException("Invalid hostname: $hostname");
    }
}
The "Sensible Default" Trap

Having a secure default does NOT protect you - callers can override it:

// Default is secure...
public function __construct(
    public string $hashAlgo = 'sha256'  // Good default!
) {}

// ...but callers can still shoot themselves
$config = new Config(hashAlgo: 'md5');  // Oops

The rule: If a parameter affects security, validate it. Defaults only help developers who don't specify a value; validation protects everyone.

Configuration Validation Checklist

For configuration schemas, verify:

  • [ ] Zero/empty rejected: Numeric security params require positive values

  • [ ] No empty passwords/keys: Empty string authentication forbidden

  • [ ] No security-disabling booleans: Or require confirmation/separate config

  • [ ] No magic values: -1 and wildcards have defined, safe meanings

  • [ ] Conflict detection: Contradictory settings produce errors

  • [ ] Precedence documented: Clear order when multiple sources exist

  • [ ] Path validation: User-provided paths restricted to safe directories

  • [ ] Type strictness: "false" string not silently converted to boolean

  • [ ] Deprecation warnings: Insecure legacy options warn loudly

  • [ ] Algorithm allowlist: Crypto algorithm params validated against safe options

  • [ ] Timing bounds: Lifetime/timeout params have both min AND max limits

  • [ ] Hostname/URL validation: Network addresses validated at construction

  • [ ] Constructor validation: All security params validated, not just defaulted

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Declares allowed tools, Needs Python

Security

What our scanner noticed· Medium risk

  • References to credential files

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Trail of Bits
Publisher
Trail of Bits (Official)
Source
trailofbits/skills · plugins/sharp-edges/skills/sharp-edges · commit e4dd0bb
Licence
Creative Commons Attribution-ShareAlike 4.0 International (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Trail of Bits.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download sharp-edges.zip