This issue was addressed through improved state management. This issue is fixed in Safari 18.6, macOS Sequoia 15.6. Processing maliciously crafted web content may lead to universal cross site scripting.
https://support.apple.com/en-us/124152
https://support.apple.com/en-us/124149