They are only really allowed to ask questions to confirm your identity, name and last name, and citizenship status (if you are a US citizen). For non-US citizens, they can ask anything they want.
However, if you don't answer other questions as a us citizen, you may end up for hours in secondary inspection.