Unfortunately there are employers in NYC who do call previous employers to verify salary. Remember that most white-collar employees are in much less demand than developers and have to deal with far more employer bullshit.
Before you're hired? If I found out that a prospective employer was calling my current employer, I would decline to continue interviewing and tell them exactly why.
How can it be legal for an employer to disclose a specific employees salary to a third party?
Is there any express reason it is illegal?
It would be odd if that were illegal. There are some well-known "radical transparency" startups that publicly post all employees' salaries.
This has me thinking, if that is legal, what is to stop any old random person who wants to know what you make from calling your employer posing as a recruiter/hiring manager looking for current salary?
I've had prospective employers call for reference/jobs description check and ask this question. It's really easy to not answer, or to answer "market rates".