Skip to content

Fix: Memory leaks and XSS in hosted input - #3370

Draft
TomA-R wants to merge 1 commit into
masterfrom
fix/hosted-input-memory-leak-listeners
Draft

Fix: Memory leaks and XSS in hosted input#3370
TomA-R wants to merge 1 commit into
masterfrom
fix/hosted-input-memory-leak-listeners

Conversation

@TomA-R

@TomA-R TomA-R commented Aug 24, 2026

Copy link
Copy Markdown
Member

Summary

Fixes three critical issues in hosted form iframe:

Issues Fixed

  1. Memory Leak: Missing removeEventListener calls for 'input', 'blur', 'focus' events
  2. Async Safety: Properly handle async _validateForm() calls with void operator
  3. Security: Remove template literal CSS selector injection vulnerability

Changes

  • Remove event listeners in detach() method to prevent memory accumulation
  • Use direct href comparison instead of CSS selector injection
  • Use void operator for intentionally unawaited promises

Testing

  • Build passes with NX
  • No breaking changes to API

Note

Medium Risk
Touches payment hosted-input lifecycle and DOM/CSS handling in iframes. Fixes are small and defensive, but this is a security- and PCI-adjacent path.

Overview
Hardens hosted card-field iframes: detach() now removes input/blur/focus (and related) listeners so fields don’t leak when remounted.

Font loading no longer interpolates URLs into querySelector (href is compared on existing stylesheet links). Unawaited _validateForm() calls are marked with void.

Reviewed by Cursor Bugbot for commit b0656ad. Bugbot is set up for automated code reviews on this repo. Configure here.

…input

- Remove input, blur, and focus event listeners in detach() method
- Replace template literal CSS selector with direct href comparison (security)
- Use void for intentionally unawaited promises in validation

Fixes memory leaks in hosted-form-v2 iframe when inputs are detached.
Prevents potential XSS vulnerability from unsanitized URL in selector.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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