This happened to me many years ago when I was much younger and not as enlightened. I will relay the situation, and I'd appreciate reading any follow-up Halachic insights or firm answers.
In my middle teen years, I once went to use an ATM that was in a supermarket. (Perhaps I should say that the supermarket is located in a neighborhood, surrounded by many apartment buildings in which senior citizens live.) I put in my card, requested $20 and when the money was spit out, I received my $20 PLUS another $60. The withdrawal slip only showed that $20 had been removed from my account.
I was somewhat stunned but looked around the machine on the floor to see if there were any dropped withdrawal slips, thinking that perhaps someone had dropped it and forgotten to take their money. The money had been spit out with mine; it was not in the slot when I started my transaction.
I didn't know what to do -- I'm an honest person by nature, but sometimes suspicious, and thought that if I go to the store manager and explain the situation, he might just pocket the money for himself and not contact the bank whose machine it is in his store. But then again, might one of the pensioner seniors have somehow left it behind? Or was the ATM just malfunctioning and it was my lucky day...and perhaps I should go back for some more good luck later in the day, and treat the ATM like a winning slot machine?
I took my $20 and that $60 and went home. I put away the "found" money and didn't use it for a long time. I can't remember if I used it all for personal reasons or perhaps gave some tzedaka with it.
I did get a response from a learned cousin of mine years later when I posed the question. If I recall correctly, I was told that it was sort of "open territory" money -- didn't really belong to the bank, so I was able to claim it for myself. Which I had done.
But as you can tell, I've never forgotten that experience, and still wonder about the rights and wrongs of it. If anyone can advise, thank you.