This is a conversation that's been a long time coming. It's not at all an easy discussion to have, but it's more relevant now with the concept of "cryptojacking".
If you're not familiar with this concept, cryptojacking is a script run on a webpage that takes advantage of a user's processing power to mine cryptocurrency, thereby acting as a passive form of income for any company that utilizes this. In the age of ad blocking, this seems like the only viable alternative to what is quickly becoming unsustainable for smaller websites and less profitable for the larger ones.
So how do we decide what's morally right or wrong? Web design has almost always been a matter of science where things were either designed well or not. We've never thought about whether or not they were developed in a morally correct way.
We have to start this conversation somehow.
Where Do We Draw the Line?
When does a design become unethical? Where do we go from being designers to opportunists and snake-oil salespeople? These are difficult questions that, at the moment, don't have any concrete answers. There isn't a board of ethics of web design like there is for legal practice. That means it's up to us to start drawing these lines and making decisions about what's right and what's wrong.
IF IT DOESN'T BENEFIT USERS
This is perhaps the most obvious place to start. Every decision made by a designer should be informed solely by the user experience. We implement techniques to improve usability and take advantage of our knowledge of human psychology.
Where we become unethical is if we implement something that is not done to benefit the user, but rather done to subvert them in some way. Cryptojacking is the most explicit form of this; it doesn't offer any benefits for the user's experience and only serves to increase your revenue. If we can't make a moral appeal, we can at least say that anything that slows down the user without providing a benefit should be considered bad design.
IF WE THINK "CAN" MATTERS MORE THAN "OUGHT"
There may not be a better example of this line of thought than in Jurassic Park. Just because something is possible does not mean it is necessary or morally right. If we find ourselves rushing to justify design decisions based on the fact that we can do things, whether or not our users like it. When we find ourselves in this headspace, it's a good idea to start making serious considerations about the actions we're close to taking.
How Do We Know Where To Stop?
Humans are notoriously bad at this part, actually, so this is going to be trial and error. It's hard to understand the limitations of any art form until we see it coming from someone else. Web design, like it or not, is an art just as much as it is a science. The best way to know if you've gone too far is this: consider the response you'd have if you encountered your decision as a user.
It won't be a perfect system, but it'll be an excellent place to start knowing where to stop.