From Project Abacus: FAQ (mirrored on InfoTomb, I couldn't find the original)
Q: What is Project Abacus?
A: [...]. After 6 months of using the research phone, the Nexus 5 will update itself to stop collecting data. It will be yours to keep as a regular phone.
Q: Can I decide to opt-out during the study?
A: Yes. To opt out, please contact MFour and notify us that you no longer wish to participate. [...]. You will also be required to return your Research Phone.
Q: At the end of the study do I have to use the compensation phone?
A: No, at the end of the study you aren't required to use the compensation phone. While we hope you'll love your Nexus 5 at the end of the study, we understand if you want to share it with another. [...].
From reading the FAQ, since you bought the phone from someone else, I'd assume that the seller has completed the study without opting-out, so he has the right to "share" (or "sell", in this case) it to other. Therefore, what you have is already a regular Nexus 5 phone, which I believe you can do whatever you want on it, including rooting and flashing it.
Note: You might need to clarify the matters with the seller first, whether he has finished the study or not. Otherwise, you are doing the research for him, which I'm afraid it might violate their T&C. You might not using it for 6 months first to make it regular phone, but IANAL.