sail close to the wind
US /seɪl kloʊs tu ðə wɪnd/
UK /seɪl kloʊs tu ðə wɪnd/

1.
to do something that is risky or close to the limits of what is acceptable or legal
:
•
His business practices often sail close to the wind, but he always manages to stay out of trouble.
•
You're sailing too close to the wind with those jokes; someone might get offended.