The Caste system in Hinduism in the times of the Vedas was not fixed. It was common for people to move from one caste to another depending on personal skills and ability's. The Chandogya Upanishad is a very old book it was (pre buddha). It is also from the Vedas' Hinduism's most holy scripture. This story shows that a son of a low caste prostitute could become a Brahmin. ( the highest caste )
From the Chandogya Upanishad
Long ago, in the Chandogya Upanishad, sage Gautama accepted Satyakama (a lad with lowly social status and son of a sudra prostitute) as his student for becoming a brahmin based on certain important qualities, which still remain valid today and can be used for selecting and training present-day non-brahmin priests and temple worshippers.
One day the boy Satyakama came to his mother and said, Mother, I want to be a religious student. What is my family name?
My son, replied his mother, I do not know. In my youth I was a servant and worked in many places. I do not know who was your father. I am Jabala, and you are Satyakama. Call yourself Satyakama Jabala.
Thereupon the boy went to Gautama and asked to be accepted as a student. Of what family are you, my lad? inquired the sage.
Satyakama replied, I asked my mother what my family name was, and she answered: I do not know. In my youth I was a servant and worked in many places. I do not know who was your father. I am Jabala, and you are Satyakama. Call yourself Satyakama Jabala! I am therefore Satyakama Jabala, Sir.
Then said the sage, None but a true brahmin would have spoken thus. Go and fetch fuel, I will teach you. You have not swerved from the truth.
The Chandogya Upanishad translated by Swami Prabhavananda
This shows that caste in the Vedic times did not always depend on birth.