I used to do a lot of freelance work. I learned real fast to get everything in writing before you proceed...on both ends. Includes statements of work (most important paper ever) and things like NDAs signed and make sure you get prior approval on your project plan and timeline before even touching a system. Make sure it's absolutely clear what your job is. This heads off easily 90% of these types of problems.
I remember several times having the people hire me, then 2 weeks later, howling that it was my job to part the red sea and repair every system and environment under the sun in 40 seconds(or something equally ridiculous). At which point I calmly pull my SOW out of my bag and ask them "Where do you see that?".