Skip to content

fix(security): expand filter sanitization to remaining GUID sites + LIKE wildcards#61

Merged
chriskehayias merged 1 commit into
mainfrom
fix/filter-injection-followups
May 17, 2026
Merged

fix(security): expand filter sanitization to remaining GUID sites + LIKE wildcards#61
chriskehayias merged 1 commit into
mainfrom
fix/filter-injection-followups

Conversation

@chriskehayias

Copy link
Copy Markdown
Contributor

Summary

Follow-ups to #57 covering the review notes that were not addressed in that PR:

  • Remaining GUID interpolation sites now use sanitizeGuid() for consistency with contactService.getContactByGuid():
    • userService.getUserProfile() (src/services/userService.ts:64)
    • createContactLog and updateContactLog actions (src/components/contact-logs/actions.ts:54,107)
  • LIKE wildcard escaping: new sanitizeLikeValue() escapes \, %, _, and '. contactSearch() now uses it with an ESCAPE '\' clause so user input like 50% matches a literal "50%" instead of acting as a wildcard.
  • Misleading doc comment in filter-sanitize.ts corrected — the regex accepts any UUID variant, not specifically v4 (MP GUIDs aren't guaranteed v4).
  • Test fixtures updated to valid-format GUIDs in userService.test.ts and contact-logs/actions.test.ts (required now that sanitizeGuid validates them), plus an invalid-GUID throws case for getUserProfile().
  • Renamed the not-found case fixture in contactService.test.ts to validButUnknownGuid for intent clarity.

Not addressed (out of scope)

Numeric ID interpolations in userService.ts:75,80 and contactLogService.ts:76,99,116 are TypeScript number-typed and not injectable as strings.

Test plan

  • npm run test:run — 240/240 pass
  • npm run lint — clean
  • contactSearch("100%") returns rows containing literal "100%" instead of treating % as a wildcard
  • getUserProfile("not-a-guid") throws "Invalid GUID format"

… LIKE wildcards

Follow-ups to PR #57:
- Apply sanitizeGuid() to userService.getUserProfile() and contact-logs
  actions (both User_GUID filters), bringing all GUID interpolations under
  the same validation as contactService.getContactByGuid().
- Add sanitizeLikeValue() that also escapes %, _, and \ in addition to
  single quotes. Use it in contactService.contactSearch() with an
  ESCAPE '\' clause so wildcards in user input are treated literally.
- Fix misleading "UUID v4 pattern" doc comment in filter-sanitize.ts —
  the regex accepts any UUID variant (MP GUIDs are not guaranteed v4).
- Update userService and contact-logs action tests to use valid-format
  GUID fixtures (required now that sanitizeGuid validates them) and add
  an invalid-GUID throws case for getUserProfile().
- Rename test constant in contactService.test.ts not-found case to
  validButUnknownGuid for clarity.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chriskehayias chriskehayias merged commit d080ec6 into main May 17, 2026
1 check passed
@chriskehayias chriskehayias deleted the fix/filter-injection-followups branch May 17, 2026 12:34
@codecov

codecov Bot commented May 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

1 participant