Reference

Security & identity

Look up identity, access checks, browser defenses, secrets and safe input boundaries.

Scope and conventions

Web/API security patterns, not a complete authentication implementation or security certification. Sequences are labeled sketches. Use maintained framework/provider libraries for identity and cryptography; adapt policies to your trust boundaries. Primary sources accompany each entry.

Input & outbound access

Validate structure, limits and domain rules at entry

Web & API security

Parse with a format-aware parser, validate types and allowed fields, and bound size/depth/record counts. Then enforce domain rules. Client-side validation helps users but does not protect the server boundary.

Protocol / decision sketch

Sequence or decision sketch; not executable code.

Web & API security · Validate structure, limits and domain rules at entry
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
bytes → size limit → parser → schema/type checks
      → domain constraints → authorized operation

Bind SQL values and allowlist structural choices

Web & API security

Use the database driver’s bound parameters for values. Parameters generally cannot stand in for table/column names or arbitrary ORDER BY syntax; map those choices to server-owned SQL fragments.

Protocol / decision sketch

Sequence or decision sketch; not executable code.

Web & API security · Bind SQL values and allowlist structural choices
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
query shape: SELECT id FROM items WHERE name = ?
value:       user-supplied text bound by the driver
sort column: chosen from a fixed server-owned allowlist

Pass subprocess arguments without invoking a shell parser

Web & API security

Use the process API’s argument list for fixed executables. Separately constrain executable choice, flags, paths and argument semantics; avoiding a shell does not make arbitrary command arguments safe.

Protocol / decision sketch

Sequence or decision sketch; not executable code.

Web & API security · Pass subprocess arguments without invoking a shell parser
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
fixed executable + separate validated argument values
no concatenated shell command
constrained working directory, environment, duration and output

Constrain server-side fetch destinations and redirects

Web & API security

For a known integration, prefer a destination allowlist plus network egress controls. Validate scheme/host and resolved addresses; revalidate every permitted redirect or disable following. DNS changes and alternate IP representations defeat naive URL checks.

Protocol / decision sketch

Sequence or decision sketch; not executable code.

Web & API security · Constrain server-side fetch destinations and redirects
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
untrusted URL → canonical parser + destination policy
resolved address → network-range policy + egress restriction
redirect target  → repeat validation before connecting

A hostname regex or a single preflight DNS lookup is not a complete SSRF defense. Connection-time enforcement matters.

Validate uploads and separate their storage

Web & API security

Authorize the upload, bound size and processing work, check allowed types using more than the supplied MIME header, and generate storage names. Serve through an authorization-aware path; isolate content from executable application files.

Protocol / decision sketch

Sequence or decision sketch; not executable code.

Web & API security · Validate uploads and separate their storage
Follow appearance
GitHub Light
GitHub Dark
Rosé Pine
Catppuccin Mocha
VS Code Dark+
request → authenticated upload limits
        → type/content validation and required scanning
        → generated storage identity outside executable web content