The legal profession has a significant problem with sexual harassment, which is eroding trust in the profession and in Australia's judiciary, the chief justice of New South Wales said in a recent speech.