I agree with you that at a glance rightfulness / lawfulness / legality look the same. But to determine the most appropriate answer, you may deduce from the elements of the question. The main element is contract. Contract is the product of legal activity, a legal document. Thus, it certainly has something to do with law.
Rightful means correct, right, or legal (in a general sense)
Lawful means allowed or recognized by law. But this term tends to be used in technical or literary contexts.
Legal means connected with the law.
Based on the above, legality is the most suitable answer.
A penny from me
Student or Learner