AGENT SKILL

security-and-hardening

Use when auditing security, implementing authentication or authorization, handling secrets, or validating data across external trust boundaries.

License 许可
MIT
最近更新
2026-08-20
Stars
★ 0
Forks
0

01 前言 Front Matter

name
security-and-hardening
description
Use when auditing security, implementing authentication or authorization, handling secrets, or validating data across external trust boundaries.

03 SKILL.md 正文

Security and Hardening

Iron Laws

<EXTREMELY-IMPORTANT>

  • Validate every external boundary. Decode unknown into a trusted domain type.
  • Authn is not authz. Identity never implies permission.
  • Deny and minimize by default. Least privilege, short retention, explicit access.
  • Secrets never enter code, logs, or git.
  • Use layered controls. Application checks and persistence constraints cover different failures. </EXTREMELY-IMPORTANT>

Boundary Matrix

Boundary Required control
HTTP path/query/body Schema decode, limits, reject unknown fields
Job queue message Versioned schema; never assume the producer validated
User file or third-party response Treat as untrusted bytes/data
Config / env Validate presence, type, range, and allowed values at startup
DB read into a domain type Validate current invariants; stored data may be stale
Internal typed function call Trust types unless the call changes trust/domain
Database write Parameterized query plus database constraints (NOT NULL, UNIQUE, CHECK, FK)

Validate at boundaries, not randomly inside business logic. Service code enforces domain preconditions; the database protects invariants and races. Return validation failures as typed errors, not unclassified exceptions.

Security Controls

  • Injection: parameterized queries; never concatenate untrusted SQL or shell input.
  • Authentication: Argon2/bcrypt, MFA where sensitive, rate limit by account and IP.
  • Sessions: random signed identifiers, httpOnly, secure, short expiry, refresh rotation.
  • Authorization: check every action and object; test that user A cannot access user B.
  • XSS/CSRF: output encoding, CSP, safe templating, appropriate same-site/CSRF protection.
  • Dependencies: lock versions, review advisories and major upgrades; do not apply audit fixes blindly.
  • Logging: record failed auth, denials, and anomalous access; redact credentials and tokens.
  • Headers: HSTS, CSP, nosniff, frame protection, and restrictive referrer policy.

Secrets

Use local environment variables, CI secret stores, and a production vault. Rotate on exposure. Never print secrets during debugging or transmit them to tools without explicit authorization.

Verification

Test negative paths: malformed boundary input, missing permission, cross-tenant access, replay/rate-limit behavior, invalid queue payload, invalid environment configuration, and persistence constraint violations.

Red Flags

as any at a boundary; trusting frontend IDs; validation only in the controller; unvalidated queue/DB/env data; plaintext or fast-hashed passwords; permissive CORS; secrets in logs; default credentials; auth “later”; database invariants enforced only in application code.

04 同仓库更多 Skills

MinhDuyDEV
MinhDuyDEV/md-pikit

writing-skills

Use when creating new skills, editing existing skills, or verifying skills work before deployment - applies TDD to process documentation by testing with subagents before writing, iterating until bulletproof against rationalization. Includes complete pressure testing methodology.

★ 0
MinhDuyDEV
MinhDuyDEV/md-pikit

verification-before-completion

Use when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always

★ 0
MinhDuyDEV
MinhDuyDEV/md-pikit

typescript-coding-standards

Use when writing, refactoring, or reviewing TypeScript code that needs strong domain modeling, typed errors, schema parsing, safe adapters, test seams, or maintainable module boundaries.

★ 0
MinhDuyDEV
MinhDuyDEV/md-pikit

test-driven-development

Use when implementing a feature, bugfix, or behavior-changing refactor — require a failing behavior test before production code, then make the smallest change that passes.

★ 0
MinhDuyDEV
MinhDuyDEV/md-pikit

source-driven-development

Use when unfamiliar libraries, dependency internals, external APIs, framework behavior, migrations, or current ecosystem guidance require official documentation, version-matched source, read the tests, and cited evidence.

★ 0
MinhDuyDEV
MinhDuyDEV/md-pikit

prototype

Use when the user wants to prototype, sanity-check a data model or state machine, mock up a UI, explore design options, or says "prototype this", "let me play with it", "try a few designs".

★ 0