Facebook (NASDAQ:FB) has come under fire over an option in its ad targeting platform that lets advertisers exclude certain ethnicities from seeing certain ads. The potential flaw in the ad-buying system was discovered by ProPublica. While, Facebook’s targeted advertising is designed to exclude people who wouldn’t be interested in a product or service, discriminating ads based on ethnicity alone is illegal.

To test the limits of Facebook’s “ethnic affinity” ad-targeting option, ProPublica purchased an ad that targeted home owners. The ad platform then displayed an option to pick which ethnicities to target in the campaign. The ad for a housing-related event that excluded African Americans, Asian Americans, and Hispanics was then placed.

Facebook representative Christian Martinez, wrote an a response to the ProPublica article saying, “A nonprofit that’s hosting a career fair for the Hispanic community can use Facebook ads to reach people who have an interest in that community. And a merchant selling hair-care products that are designed for black women can reach people who are most likely to want its products.”

His statement continued, “That merchant also may want to exclude other ethnicities for whom their hair care products are not relevant—this is a process known in the ad industry as “exclusion targeting.” This prevents audiences for community-specific ads from seeing a generic ad targeted to a large group and helps avoid the offensive outcome that traditional advertising can often create for people in the minority.”

Facebook says it bans advertisers from using “Ethnic Affinities” to discriminate against racial or ethnic groups. Martinez said, “Our ad policies strictly prohibit this kind of advertising, and it’s against the law. If we learn of advertising on our platform that involves this kind of discrimination, we will take aggressive enforcement action.”

Facebook generates nearly all of its revenue from advertising. Many advertisers use the ad platform because they can use the data Facebook collects on its 1.71 billion users to target very specific audiences. Facebook says that its multicultural targeting is designed to make advertising more relevant and inclusive to diverse communities. Multicultural ad targeting is pretty common in the industry and is not illegal.

However, excluding specific racial and ethnic groups when placing housing ads is a potential violation of federal anti-discrimination housing laws. Rigel Oliveri, a professor of law at the University of Missouri, said in an interview, “There’s a part of the Fair Housing Act that makes it illegal to have discriminatory advertising. That part applies to both the person taking out the ad and also the publisher of that ad.” Some are now saying that Facebook should give housing and employment ads a greater degree of scrutiny to ensure they are not being targeted based on race.

Get Analysts' Upgrades and Downgrades Daily - Enter your email address below to receive a concise daily summary of analysts' upgrades, downgrades and new coverage with MarketBeat.com's FREE daily email newsletter.