uwu / shelter

an attempt to prepare for the worst
https://shelter.uwu.network/
Creative Commons Zero v1.0 Universal
365 stars 12 forks source link

Exfiltrate React using `useId` instead of `useRef` #26

Closed SpikeHD closed 7 months ago

SpikeHD commented 7 months ago

Recently, due to an update to... something, I assume, a project of mine has been having trouble rendering Shelter-based elements while another client mod is loaded. This is kinda bad (but not Shelter's fault! Just a wonky incompatibility) since the whole frontend-backend communication runs via Shelter :P

After some testing, I boiled it down to the fact that the other client mod would call defineProperty to define useRef, which is how Shelter finds React. For some reason, the object that was getting useRef defined also had most properties set to undefined, which would cause calls to things like createElement from Shelter plugins to fail.

I came to this solution by making an assumption that, while useId will probably always exist on Discord's React, other client mods will likely never have a reason to redefine it themselves, meaning the exfiltration has a much lower chance of picking up an object it's not supposed to.