Masturbation is forbidden according to the view of the Hanbali School of jurisprudence. Whoever practices it deserves a punishment. It is permissible only at the time of necessity. Necessity means the time when one fears to commit Zina (adultery/fornication) or when one fears disease from the gathering of sperm and he is not able to get married.
Was pretty sure reading somewhere that masturbation was haram in Islam. Went looking. Most sites were pretty clear. Yup. Forbidden.
Except this one site (https://islamweb.net/en/fatwa/82271/masturbation-at-the-time-of-necessity) added a teeny, little loophole:
You gotta pay attention to the fine-print.
So it’s forbidden, unless you’re really horny. Then it’s okay.