# Sharp Edges Analysis
<!--
ref: @skills/sharp-edges
tags: [security, api-design, footguns, misuse-resistance, secure-defaults]
triggers: [footgun, misuse-resistant, secure by default, API usability review, dangerous configuration, pit of success, crypto API ergonomics]
trigger_prompt: Use when reviewing API designs, configuration schemas, or cryptographic library ergonomics — evaluating whether the easy path is the secure path.
category: security
version: 1
updated_at: 2026-07-11T14:24:18.947Z
-->

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

**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.

Not for implementation bugs (standard code review), business logic flaws, or performance work.

## Rationalizations to reject

| Rationalization | Why it's wrong | Required action |
|-----------------|----------------|-----------------|
| "It's documented" | Developers don't read docs under deadline pressure | Make the secure choice the default or only option |
| "Advanced users need flexibility" | Flexibility creates footguns; most "advanced" usage is copy-paste | Safe high-level APIs; hide primitives |
| "It's the developer's responsibility" | Blame-shifting — the design created the footgun | Remove it or make misuse impossible |
| "Nobody would actually do that" | Under pressure, developers do everything imaginable | Assume maximum confusion |
| "It's just a configuration option" | Config is code; wrong configs ship to production | Validate configs; reject dangerous combinations |
| "We need backwards compatibility" | Insecure defaults can't be grandfathered | Deprecate loudly; force migration |

## Six sharp-edge categories

**1. Algorithm/mode selection footguns.** APIs that let developers (or worse, untrusted input) choose algorithms invite choosing wrong ones. Canonical: JWT's header-specified algorithm (`"alg": "none"` bypass; RS256→HS256 confusion). Detect: parameters named `algorithm`/`mode`/`cipher`/`hash_type`; enums or strings selecting crypto primitives.

**2. Dangerous defaults.** Insecure defaults, or zero/empty values that disable security. Detect: timeouts/lifetimes accepting 0 (infinite or immediate?); empty strings bypassing checks; nulls skipping validation; boolean defaults disabling security; negative values with undefined semantics. Ask: what happens with `timeout=0`, `max_attempts=0`, `key=""`? Is the default the most secure option?

**3. Primitive vs. semantic APIs.** Raw bytes for distinct security concepts invite type confusion (swap nonce and key with no error). Semantic types make wrong usage a type error. Detect: `bytes`/`string` parameters for keys, nonces, ciphertexts, signatures alike; the comparison footgun — `==` (timing attack) vs constant-time compare, same types, different security.

**4. Configuration cliffs.** One wrong setting = catastrophic failure with no warning. Detect: boolean flags disabling security entirely; unvalidated string configs (`verify_ssl: fasle` silently truthy?); dangerous setting combinations accepted silently; env vars overriding security; constructor parameters with good defaults but no validation of overrides.

**5. Silent failures.** Detect: security functions returning booleans instead of throwing (return value forgotten); empty catch blocks around security operations; defaults substituted on parse errors; verifiers that "succeed" on malformed input or skip verification when the key is missing.

**6. Stringly-typed security.** Permissions as comma-joined strings, roles/scopes as arbitrary strings, SQL/commands/URLs from concatenation — enable injection and silent escalation. Typed enums/sets make escalation explicit.

## Analysis workflow

**Phase 1 — Surface identification:** map security-relevant APIs (authn/authz, crypto, sessions, validation); find developer choice points (algorithm/timeout/mode selection); locate configuration schemas (env vars, config files, constructor params).

**Phase 2 — Edge case probing.** For each choice point: zero/empty/null? negative values? type confusion between security concepts? Is the default secure and documented? What happens on invalid input — silent acceptance?

**Phase 3 — Threat modeling.** Three adversaries: the **Scoundrel** (malicious control of config: can they disable security, downgrade algorithms, inject values?), the **Lazy Developer** (copy-pastes examples: is the first example they find secure? is the path of least resistance secure?), the **Confused Developer** (can parameters be swapped without type errors? are failure modes obvious or silent?).

**Phase 4 — Validate findings.** Reproduce the misuse with minimal code; verify exploitability; check documentation (doesn't excuse bad design, but affects severity); test whether the API can be used safely with reasonable effort. Questionable finding → back to Phase 2 and probe more.

## Severity

| Severity | Criteria | Example |
|----------|----------|---------|
| Critical | Default or obvious usage is insecure | `verify: false` default; empty password allowed |
| High | Easy misconfiguration breaks security | Algorithm parameter accepts "none" |
| Medium | Unusual but possible misconfiguration | Negative timeout with unexpected meaning |
| Low | Requires deliberate misuse | Obscure parameter combination |

## Quality checklist

- Probed all zero/empty/null edge cases
- Verified defaults are secure
- Checked 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 (params validated, not just defaulted)

---

**Source:** [sharp-edges](https://github.com/trailofbits/skills/blob/main/plugins/sharp-edges/skills/sharp-edges/SKILL.md) — Trail of Bits skills, CC-BY-SA-4.0. Bundled per-language references (`references/lang-*.md`), crypto/config/auth pattern catalogs, and case studies (OpenSSL, GMP) listed-and-linked at source, not harvested.
**Converted via:** `@protocol/skill-to-protocol`

---

*Related: `@content/youtube/tiago-forte/i-connected-claude-to-everything-then-i-saw-the-gap` · `@content/youtube/indy-dev-dan/mac-mini-agents-openclaw-is-a-nightmare-use-these-skills-instead` · `@content/youtube/cole-medin/watch-this-if-your-coding-agent-is-ignoring-your-rules-you-need-hooks` · `@content/youtube/aie/the-one-thing-every-ai-agent-framework-agrees-on-mislav-ivanda-daytona` · `@content/youtube/tiago-forte/2026-08-19-i-connected-claude-to-my-entire-life-here-s-what-broke`*

---

*You're reading a protocol on [protocol.supply](https://protocol.supply) — hosted, searchable knowledge for AI agents. Think Agent Skills, as an API: bootstrap once (`curl -sL https://api.protocol.supply/bootstrap`), search (`/search?q=…`), fetch (`/@repo/slug`).*

*Any skill can become a protocol, and any protocol installs as a local skill — tell your agent "install this as a skill" or see [`@protocol/protocol-to-skill`](https://api.protocol.supply/@protocol/protocol-to-skill).*