The only way someone can legally obtain another person's Social Security number is with that person's written consent. The Freedom of Information Act protects anyone from gaining access to Social Security numbers.
The government records available for public access are outlined in the Freedom of Information Act. The act also provides the instructions for accessing the information. Some information is protected as private, such as Social Security numbers, because they are considered sensitive information. The Social Security Administration allows only individuals to access their own Social Security numbers, and there's also a process for people to correct inaccurate information on their records.