Repository navigation
fix: sanitize forms, validate API routes and staking balances, and re… - #1046
Merged
ayshadogo merged 1 commit intoOct 22, 2026
Merged
Conversation
|
@Unclebaffa 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! 🚀 |
…funder#943, Dfunder#940, Dfunder#941, Dfunder#942) - Dfunder#943: add iterative fixed-point sanitization and email validation - Dfunder#940: add Zod validation and rate limiting for artist/marketplace APIs - Dfunder#941: enforce balance checks in staking and delegation forms - Dfunder#942: replace filter:invert() with light-dark() and CSS custom properties Closes Dfunder#943, Closes Dfunder#940, Closes Dfunder#941, Closes Dfunder#942
Unclebaffa
force-pushed
the
fix/contact-form-sanitization-943
branch
from
October 21, 2026 08:49
3893d59 to
354b8eb
Compare
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request: Comprehensive Security, Validation, Staking & Theming Fixes
Linked Issues
Executive Summary
This pull request delivers complete fixes and regression test suites for four distinct issues across security, parameter validation, contract transaction safety, and accessibility theming:
api/artist/[id],api/marketplace/[id],api/portfolio/[id]) against path traversal (../,%2f, null bytes) and SQL injection using strict Zod schemas, HTTP 400 Bad Request error handling, rate limiting (HTTP 429), and parameterized database access patterns.StakeForm,UnstakeForm,DelegateStakeForm, andCompoundStakeFormwith the exact required error format:"Insufficient balance. You have X tokens, trying to stake Y."filter: invert()and establishing native CSScolor-scheme: light dark, thelight-dark()CSS function, and custom properties (--color-bg,--color-text) acrossThemeToggle,Header, andLayout.Detailed Issue Breakdown & Solutions
1. Issue #943: Contact Form Lacks Sanitization
src/lib/sanitize.tswith an iterative fixed-point loop (do ... while (current !== prev)) to completely remove recursive tags (e.g.<<<script>script>), script blocks,javascript:/vbscript:/data:pseudoprotocols, and event handler attributes (onerror=,onload=).bot_field) withtabIndex={-1}andaria-hidden="true"toContactForm.tsx,NewsletterForm.tsx, andQueryForm.tsxto drop spam submissions silently.CommissionRequestModal.tsxandProfileEditPage.tsx.src/test/Form.test.tsx(25 tests covering recursive sanitization, honeypot traps, rate limiting, and email formatting).2. Issue #940: API Routes Lack Input Validation
idinapi/artist/[id].tsxand companion marketplace/portfolio routes lacked format validation, opening the system to path traversal and SQL injection payloads.src/validators/artist-id.validator.tswith Zod schemas (artistIdSchema,marketplaceIdSchema,portfolioIdSchema) validating that IDs are strictly positive integers (/^[1-9]\d*$/) or standard RFC 4122 UUIDs...,/,\,%2f, null bytes) and SQL injection signatures (--,/*, quotes, semicolons, stacked queries).GET(req, { params })) and Pages Router / Express (handler(req, res)) patterns in:api/artist/[id].tsxapi/marketplace/[id].tsxapi/portfolio/[id].tsxsrc/test/artist-api.test.ts(16 tests verifying positive integers, UUIDs, negative IDs, path traversal, SQL injection, and rate limiting).3. Issue #941: Staking Form Lacks Balance Validation
src/hooks/useStellarBalance.tsto manage real-time wallet balances, staked totals, and claimable rewards withgetBalance.validateStakeBalanceand contract-level guardrequireBalanceenforcing the required message format:"Insufficient balance. You have ${availableBalance} tokens, trying to ${action} ${amount}."StakeForm.tsx(prevents staking more than available balance)UnstakeForm.tsx(prevents unstaking more than staked balance)DelegateStakeForm.tsx(validates available balance and validator address)CompoundStakeForm.tsx(validates claimable rewards balance)src/test/staking.test.tsx(14 tests asserting boundary limits, error message strings, "Max" buttons, and submission guards).4. Issue #942: Theme Toggle Uses Color Inversion
filter: invert(), which inverted photographs, artwork, brand gradients, and icons, creating visual distortion, halation, and contrast degradation.:rootwithcolor-scheme: light darkinsrc/index.css.light-dark():--color-bg: light-dark(var(--color-bg-light), var(--color-bg-dark));--color-text: light-dark(var(--color-text-light), var(--color-text-dark));src/lib/theme.tsto synchronizedocument.documentElement.style.colorSchemeand safely guardwindow.matchMediaandlocalStorage.ThemeToggle.tsx,Header.tsx, andLayout.tsx.src/test/DarkMode.test.ts(6 tests asserting zerofilter: invert(), clean theme toggling, image/gradient preservation, and WCAG AAA > 10:1 contrast ratios).Acceptance Criteria Matrix
foo,@bar,missing@domain)Form.test.tsxForm.test.tsxForm.test.tsxForm.test.tsxForm.test.tsxForm.test.tsxForm.test.tsxapi/artist/[id].tsxvalidates theidparameter formatartist-api.test.tsartist-api.test.tsartist-api.test.tsartist-api.test.tsartist-api.test.tsartist-api.test.tsartist-api.test.tsartist-api.test.tsstaking.test.tsx"Insufficient balance. You have X tokens, trying to stake Y."staking.test.tsxstaking.test.tsxstaking.test.tsxstaking.test.tsxstaking.test.tsxlight-dark()or CSS variables instead offilter: invert()DarkMode.test.tsDarkMode.test.tsDarkMode.test.tsDarkMode.test.tsDarkMode.test.tsDarkMode.test.tsAutomated Test Verification
All 61 automated tests across all four test suites pass completely:
$ npx vitest run src/test/artist-api.test.ts src/test/DarkMode.test.ts src/test/staking.test.tsx src/test/Form.test.tsx RUN v4.1.12 C:/Users/hp/OneDrive/Desktop/GrantFox/stellarAid-web ✓ src/test/artist-api.test.ts (16 tests) ✓ src/test/DarkMode.test.ts (6 tests) ✓ src/test/staking.test.tsx (14 tests) ✓ src/test/Form.test.tsx (25 tests) Test Files 4 passed (4) Tests 61 passed (61) Duration 16.00s