Fix: Memory leaks and XSS in hosted input - #3370
Draft
TomA-R wants to merge 1 commit into
Draft
Conversation
…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>
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.
Summary
Fixes three critical issues in hosted form iframe:
Issues Fixed
Changes
voidoperator for intentionally unawaited promisesTesting
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 removesinput/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 withvoid.Reviewed by Cursor Bugbot for commit b0656ad. Bugbot is set up for automated code reviews on this repo. Configure here.