Skip to content

docs(security): add input sanitization and output encoding guidelines - #1193

Open
MJ-RWA wants to merge 1 commit into
Dfunder:mainfrom
MJ-RWA:docs/1148-input-sanitization-output-encoding
Open

MJ-RWA wants to merge 1 commit into
Dfunder:mainfrom
MJ-RWA:docs/1148-input-sanitization-output-encoding

Conversation

@MJ-RWA

@MJ-RWA MJ-RWA commented Nov 23, 2026

Copy link
Copy Markdown

Summary

Adds a section to docs/security.md on handling untrusted user-generated content (campaign and donation text, names, links, file names): validate at the API boundary, store as typed, and encode per output context, using the project's NestJS / class-validator / Prisma stack.

Related Issue

Closes #1148

Changes Made

  • New "Untrusted content: input sanitization and output encoding" section: principles, DTO rules with a shared cleanText transform example, storage rules (parameterized queries only), a per-context output encoding table (HTML, attributes, URLs, script, CSV, email, logs), rich text rules, file name handling, and a review checklist for new content fields.
  • Added OWASP references. Docs only; no code or dependency changes. Sanitizer libraries are described as not installed yet.

Testing Performed

  • npm run lint (N/A, docs only)
  • npm run build (N/A, docs only)
  • npm test (N/A, docs only)
  • npm run test:e2e (N/A, docs only)
  • npm run security:secrets: no secrets detected
  • Verified the example regex behaves as documented and that the referenced config, anchors, and files exist

Accessibility and Client Impact

  • Error messages are clear and actionable (N/A)
  • Response fields are explicit and self-describing (N/A)
  • API docs, Swagger descriptions, and examples were updated for any contract change (N/A, no contract change)
  • Client impact was considered (N/A, documentation only)

Checklist

  • Changes are focused on the related issue
  • No unrelated files or dependencies were changed

Document how untrusted user-generated content (campaign and donation text,
names, links, file names) must be validated at the API boundary, stored, and
encoded per output context, using the project's NestJS/class-validator/Prisma
stack. Includes a shared DTO transform example, a per-context encoding table,
rich text rules, and a review checklist for new content fields.

Closes Dfunder#1148
@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@MJ-RWA Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add input sanitization and output encoding guidelines for future content fields

1 participant