To safeguard your devices from harmful cables, you should consider using a data blocker, which is a device that disables data transfer through a USB connection ensuring only charging to the device. Such devices cost around $5 on Amazon. In addition, do not ever use cables that you did not buy yourself or that you cannot identify their origin.