Illustration by Jim Cooke

Palantir is one of the most secretive tech firms in Silicon Valley. Its clients include the FBI, the NSA, and the CIA, as well as companies like JPMorgan Chase, Walmart, and Credit Suisse. The 12-year-old big data firm has received $2.7 billion in funding, and at a valuation of $25 billion, it's considered the fourth most valuable startup in the world behind Uber, Xiaomi, and Airbnb.

But as Buzzfeed reported last month, Palantir has lost top-tier clients including Coca-Cola, which backed away from a five-year contract in part because the beverage giant had a "difficult" working relationship with Palantir's young staff. Coke reportedly admitted it needed "to get better at working with millennials."

Coke isn't the only one that had trouble working with Palantir's fun-loving millennials. Gizmodo has obtained a legal demand letter and internal emails written by a former senior technical writer named Bernie Cohen, who was fired in July of 2009, describing Palantir as a frat-house environment so out of control that he twice had to seek medical treatment from alcohol-related workplace incidents.

The emails document a series of complaints Cohen lodged in 2009 to Palantir co-founder Joe Lonsdale and other senior staffers, shortly before he was fired. While some of Cohen's claims may sound like something out of Office Space, they include allegations that Palantir's deadly serious work for intelligence agencies, law enforcement, and financial institutions took place in an environment that tolerated office drinking and juvenile behavior.

Cohen describes how he was injured when he was slammed by a door as an apparently drunk coworker rushed to make his shot in a game of office beer pong. He also says he suffered from hives after an apparent office prank in which another (also apparently drunk) coworker placed dog hair around Cohen's work station, scattered vinyl gloves across the room, and stole snacks out of his filing cabinet.

(Peter Thiel, a Palantir cofounder, has admitted to bankrolling lawsuits against Gizmodo's parent company Gawker Media in an effort to silence the company. Gizmodo began reporting on this story long before Thiel's vendetta became known.)

In the emails obtained by Gizmodo, Cohen says the beer pong incident left him with bruises to a piece of cartilage under the sternum and that he suffered weeks of dizziness as a result. He was allergic to dog hair, and the prank allegedly caused what a medical clinic described as the "worst case of hives" they had ever seen.

A July 1, 2010 letter threatening a lawsuit from Cohen's attorney James D. Rush, claims that Cohen, who is now 67, was wrongfully terminated, was the "victim of a hostile workplace due to his age," and that his complaints about on-site drinking parties "did not sit well with co-workers or supervisors."

The letter also makes the surprising allegation that Palantir engaged in improper business practices by using both Bloomberg data feeds and software from an IT firm called ANB without the appropriate licenses. Neither Palantir, Bloomberg, nor ANB responded to requests for comment. In the July 2010 letter, Cohen's attorney states that his client was retaliated against for speaking out about these practices. From the letter:

Mr Cohen was retaliated against for…complaining about issues such as Palantir's illegal use of third party copyrighted and trademarked icons and Bloomberg data feeds without adequate licenses. In addition, Mr. Cohen was retaliated against for complaining about the illegal use of open source code without crediting authors, and the illegal use of ANB software development kit without ANB's authorization.

According to an email from an operations staffer to Cohen, an internal investigation into the dog hair prank found that the hair most likely belonged to "Bailey," an Australian Shepherd that was a "regular" on Cohen's floor. Lonsdale also replied to Cohen via email and said the employee responsible for the prank was drinking "offsite on his own accord" but had been dismissed from the firm for "various reasons." Lonsdale said the incident was "entirely unacceptable" but also suggested Cohen was overreacting about being hit by a door during office beer pong:

Frankly, I think that you were exaggerating in anger and making a larger deal in response to what was a legitimate one-off situation here, a situation that we have very promptly acted to address. As you now know, you were incorrect in linking this to Palantir's drinking policy. However, this doesn't mean that we can't be especially careful and use this an excuse to be as smart as possible about all of our safety policies.

Lonsdale said he hadn't heard about Cohen being "slightly injured" in the beer pong incident but was "taking this seriously and looking into it."

"As you know, we'd already put up signs there—is there anything else you'd recommend?" Lonsdale asked.

Cohen replied with a litany of health issues he suffered after the beer-pong incident (a doctor, he claimed, recommended that he check his stool for blood to monitor for any internal bleeding). "This was an extremely trying experience," Cohen wrote, "both emotionally and physically, and I don't want it to be minimized."

Palantir and Lonsdale did not respond to requests for comment.

Cohen's attorney demanded $240,000 and 80,000 vested shares of Palantir stock for his client or he would "have no choice but to advise [Cohen] to immediately pursue a lawsuit." Rush refused to comment but said on a phone call with Gizmodo that the suit was never filed. Cohen did not return multiple requests for comment.

Palantir prides itself on secrecy—it does, after all handle massive amounts of sensitive data from the world's biggest companies and, according to CNBC, between 30 and 50 percent of its business is from the public sector. But it hasn't escaped controversy entirely. Last year, Lonsdale, who is also a partner at venture capital firm 8VC, was accused of rape by a recent Stanford grad he dated as her Stanford mentor. The suit was later dropped.

Additional reporting by Tommy Craggs