If in the UK, it would come under the Computer Misuse Act 1990. Accessing a computer by illegal means (hacking), accessing a computer (system) illegally in order to commit further illegal activity, modifying data stored on a computer without permission.
Computer Misuse Act (1990) - Ethical, legal and environmental impact - CCEA - GCSE Digital Technolog...
Computer Misuse Act 1990 (legislation.gov.uk)
*DISCLAIMER Not a lawyer.
Some additional thoughts:
The internet doesn't work like TV and legislation has taken a while to catch up. All the stuff about cookies (small text files) that keep website data is only fairly recent thing (ie. in the last 25 years or so) but amassing and selling data is a relatively new phenomenon due to technological advancement. As it sped up, massive amounts of data (and not knowing sources) can be sent around the world quickly with comparative ease, a problem the general public have basically sleepwalked into. The internet is now used for things it was never intended for, and it has never been fit for purpose IMO. ⚠️ Be careful about your data and be aware of whom you are sending it to.