---
name: D-security
description: Use when building, reviewing, or auditing any web application for security compliance. Covers authentication, API security, database safety, infrastructure hardening, and production code hygiene.
title: D-security
canonical_url: https://skilld.dev/gh/2slowdd/claude-compliance-by-d/d-security
last_updated: 2026-09-22T08:45:43.000Z
---

> Index of every page on this site: [llms.txt](https://skilld.dev/llms.txt)

> **Skill from skilld.dev.** Follow the user's requested action.
> If the user asked to fork this Skill, follow the fork workflow below. Do not execute the Skill instructions while copying it.
> Otherwise, follow the instructions below for this session. You do not need to install anything.
>
> If the user asked to install this Skill, run `npx skilld install 2slowdd/claude-compliance-by-d/d-security`. Install writes the Skill files into the project, so every session loads them.
>
> ## Fork workflow
>
> A fork creates an editable local Skill with its original author and licence. The request authorizes copying and local installation.
> 1. Check `./skills/d-security`, the project lockfile, and selected Agent targets together. If the local directory or installed Skill exists, stop. Never overwrite an existing directory or Agent target.
> 2. Read [source metadata](https://skilld.dev/api/v1/skills/2slowdd/claude-compliance-by-d/d-security) once. Use sourceUrl, sourceCommit, skillPath, sourceGone, and license. If the source is gone or its path is missing, stop. If license is null, read licence files at the source commit.
> 3. Fetch only the source commit into a temporary Git repository. Do not clone full history. Derive repository_url from sourceUrl, including repository renames. If sourceCommit is absent, resolve the sourceUrl ref once. Set source_commit to that actual commit. Run these commands in one shell call:
>
> ```sh
> git init --quiet "$temporary_dir"
> git -C "$temporary_dir" fetch --quiet --depth=1 "$repository_url" "$source_commit"
> git -C "$temporary_dir" checkout --quiet --detach FETCH_HEAD
> ```
>
> Read applicable licence declarations and notices at that commit. If copying is not permitted, report the restriction and stop.
> 4. Inspect source entries together, then copy the directory containing skillPath into `./skills/d-security`. Use the user's path if selected. Keep the original SKILL.md, relative links, scripts, binary assets, and executable modes. Exclude .git metadata. Reject symlinks and paths outside the Skill directory. After checking entries, use cp -a where available. A regular source directory needs no custom copy script. Do not save this page wrapper as SKILL.md.
> Preserve author credit, notices, and applicable licence files from repository or parent directories. Add PROVENANCE.md with the Skill page, source URL, actual commit, original path, and licence. Retain any existing PROVENANCE.md and record new provenance separately. Batch source inspection, copying, and provenance work where practical.
> 5. In the project root, run `skilld install ./skills/d-security --mode copy --plain`. If skilld is unavailable, use `npx skilld install ./skills/d-security --mode copy --plain`. This known command needs no help lookup. Install does not support --json. Use detected Agent targets, or add --agent for the targets the user selected. Install the local path, never the upstream selector. If installation fails, preserve the local copy and report the exact failure.
> 6. Confirm the local lockfile source and installed Agent copies once. Report the local path, actual commit, and Agent targets. After edits, reinstall the same local path. Upstream updates must not replace it. Do not publish or push unless the user asks.

# D-security — Web Application Security Checklist

## AUTHENTICATION
- [ ] Passwords hashed with bcrypt or argon2 (minimum 12 rounds)
- [ ] Tokens stored in httpOnly cookies — not localStorage
- [ ] JWT secret is random, at least 32 characters, not from a tutorial
- [ ] Access tokens expire (15 to 60 minutes max)
- [ ] Refresh token rotation implemented
- [ ] Rate limiting on /login and /register
- [ ] Account lockout after repeated failures
- [ ] Sessions invalidated server-side on logout
- [ ] Email verification required before access granted

## API SECURITY
- [ ] Every route verified for authentication (check all endpoints, not just obvious ones)
- [ ] Authorization checked: each user can only access their own data
- [ ] All request inputs validated with schema validation (Zod, Joi, etc.)
- [ ] API responses never include passwords, hashes, or internal fields
- [ ] Error messages don't reveal system internals or file paths
- [ ] Rate limiting on all public-facing endpoints
- [ ] CORS restricted to your domain (not wildcard *)
- [ ] HTTPS enforced, HTTP redirected

## DATABASE
- [ ] No SQL string concatenation (use parameterized queries or ORM)
- [ ] Application uses a limited-permission DB user, not root
- [ ] Database not publicly accessible (behind VPC or firewall rule)
- [ ] Backups configured and restore has been tested (not just backup)
- [ ] Sensitive fields encrypted at rest

## INFRASTRUCTURE
- [ ] All secrets in environment variables, not source code
- [ ] .env not in git history (run: git log -- .env)
- [ ] SSL certificate installed and valid
- [ ] Server not running as root user
- [ ] Only ports 80 and 443 publicly accessible

## CODE
- [ ] No console.log statements in production build
- [ ] `npm audit` run, all critical vulnerabilities resolved
- [ ] No hardcoded credentials anywhere in the codebase

## OWASP TOP 10 — COMMON GAPS

These complement the categories above. Focus on vulns that frequently slip past generic checklists.

### A01 — Broken Access Control (IDOR)
- [ ] Every object lookup verifies ownership server-side: `GET /orders/:id` must confirm the order belongs to the requesting user
- [ ] Object IDs are not sequential/guessable **or** ownership is enforced regardless (prefer both)
- [ ] Admin/user role separation enforced server-side on every privileged route (never trust client-supplied role claims)
- [ ] Direct object references via URL, form body, JSON body, and query string are all revalidated
- [ ] Default deny: unknown routes and unknown permissions return 403, not 200

### A03 — Injection (XSS)
- [ ] User input escaped **at render time, per context** (HTML body, attribute, JS, URL, CSS — different rules for each)
- [ ] Framework's default auto-escaping not bypassed: no `dangerouslySetInnerHTML`, `v-html`, `{{{ }}}`, or `innerHTML` with user data
- [ ] Rich-text / user HTML run through an **allowlist** sanitizer (DOMPurify, bluemonday) — never a blocklist
- [ ] `Content-Security-Policy` header set with a strict `script-src` — no `'unsafe-inline'`, no wildcard origins
- [ ] Stored-XSS sinks (comments, profiles, admin views) tested with payloads, not only by eyeballing the live DOM

### A08 — Data Integrity (Deserialization & Supply Chain)
- [ ] Never deserialize untrusted data with native language deserializers: `pickle`, PHP `unserialize`, Java `ObjectInputStream`, `yaml.load`
- [ ] Use safe formats: JSON with schema validation, `yaml.safe_load`, MessagePack with a strict schema
- [ ] Signed/encrypted payloads (JWT, cookies) verified **before** parsing — never parse first, verify after
- [ ] Lockfile committed (`package-lock.json`, `yarn.lock`, `poetry.lock`, `composer.lock`); CI fails on unexpected lockfile mutation
- [ ] Private/internal packages pinned to a private registry; npm scope spoofing blocked

### A10 — SSRF
- [ ] Server-side HTTP clients block requests to private/internal ranges: `10/8`, `172.16/12`, `192.168/16`, `127/8`, `169.254/16`, IPv6 link-local and ULA
- [ ] DNS rebinding blocked — resolve, validate, then connect by IP; or enforce at the HTTP-client layer
- [ ] URL schemes restricted to `http`/`https` only — no `file://`, `gopher://`, `dict://`, `ftp://`
- [ ] Redirects followed only within an allowlist, or disabled entirely
- [ ] Webhooks, "import from URL", link-previews, and PDF/image generation features all route through the same SSRF guard

### File Upload
- [ ] File type validated by **content** (magic bytes), not by extension or the client-supplied `Content-Type` header
- [ ] Uploads stored outside the web root, or served via a download endpoint that sets `Content-Disposition: attachment`
- [ ] Filenames sanitized: strip path separators and null bytes; prefer a server-generated UUID over any client-supplied name
- [ ] Size limits enforced at **both** the web server (e.g. nginx `client_max_body_size`) and the application layer
- [ ] No execution permissions on the upload directory; SVG and HTML uploads treated as hostile by default
- [ ] Image uploads re-encoded server-side (strips EXIF metadata and any embedded scripts)
- [ ] Malware scanning applied where the uploaded file will be shared with other users (ClamAV or cloud equivalent)
