Rules for affiliation for student doing unpaid research in his/her free time?
I don't think there are any "official rules".  (I can't even find a clause in my employment contract that officially requires me to list my university on my papers.)

But as long as you are a student, it's a good idea to list your university as an affiliation.  Even if the university isn't paying you, you do benefit indirectly from the intellectual environment and resources that the university provides: professors, fellow students, library, internet, health insurance, nearby coffee shops, and so on.  It costs you nothing to be generous.  Also, for better or worse, readers will take your paper more seriously.