Palantir, the secretive Silicon Valley startup that is an object of popular fascination thanks to its work with US intelligence, is having a surprisingly difficult time recruiting clients among the world's largest companies - a line of business that its backers, a group that includes PayPal founder Peter Thiel, have identified as crucial to the company's long-term survival and profitability.

In one of the first looks under the company's hood, Bloomberg revealed that Palantir has never turned a profit - despite being valued at $20 billion in 2015. The company has roughly 2,000 engineers deployed at various client sites. But the company's high installation and maintenance fees have repelled several potential clients.

But in addition to details about the companies finances and business model, the sprawling piece also included several alarming examples of what can only be described as NSA-like overreach by the company. The story begins at JP Morgan, where former secret service agent Peter Cavicchia III ran special operations for the bank ensconced in an office suite in the top floors of JPM's Jersey City building.

Cavicchia's colleagues said the bank allowed the 120 Palantir engineers who worked inside its offices and Cavicchia, their leader, almost unchecked surveillance power. And pretty soon employees at the bank became paranoid that the extent of Palantir's surveillance had become too scary to ignore. Even the bank's senior executives were being watched, according to BBG's sources (who, we imagine, leaked this information despite the immense risk of being caught and fired).

Over time, however, Cavicchia himself went rogue. Former JPMorgan colleagues describe the environment as Wall Street meets Apocalypse Now, with Cavicchia as Colonel Kurtz, ensconced upriver in his office suite eight floors above the rest of the bank’s security team. People in the department were shocked that no one from the bank or Palantir set any real limits. They darkly joked that Cavicchia was listening to their calls, reading their emails, watching them come and go. Some planted fake information in their communications to see if Cavicchia would mention it at meetings, which he did. It all ended when the bank’s senior executives learned that they, too, were being watched, and what began as a promising marriage of masters of big data and global finance descended into a spying scandal. The misadventure, which has never been reported, also marked an ominous turn for Palantir, one of the most richly valued startups in Silicon Valley. An intelligence platform designed for the global War on Terror was weaponized against ordinary Americans at home.

And JPM was just the beginning. As BBG explains, Palantir's specialty is using its data analytics powers to draw connections that weaker software might miss. For example, determining that an employee is disgruntled based on the fact that he or she stopped showing up to work on time.

The company presents its findings in a graphic known as a spidergram.

Yet, despite many documented incidences of the company's tendency to abuse the trust of its clients and occasionally the government, Palantir has been allowed to grow at an unchecked rate.

In a ruling that appears to create a troubling legal precedent, Bloomberg recounts a lawsuit brought against Palantir by another data analytics firm called I2. I2 alleged that Palantir hired a private eye firm to contract with I2 to use I2's software, then turned the software over to Palantir. I2 sued Palantir for fraud and conspiring to steal intellectual property. In response, Palantir's lawyers argued that an overpowering national security interest justified Palantir's actions - and the judge agreed.

I2 sued Palantir in federal court, alleging fraud, conspiracy, and copyright infringement. In its legal response, Palantir argued it had the right to appropriate I2’s code for the greater good. “What’s at stake here is the ability of critical national security, defense and intelligence agencies to access their own data and use it interoperably in whichever platform they choose in order to most effectively protect the citizenry,” Palantir said in its motion to dismiss I2’s suit. In one adventure missing from the glowing accounts of Palantir’s early rise, I2 accused Palantir of misappropriating its intellectual property through a Florida shell company registered to the family of a Palantir executive. A company claiming to be a private eye firm had been licensing I2 software and development tools and spiriting them to Palantir for more than four years. I2 said the cutout was registered to the family of Shyam Sankar, Palantir’s director of business development. The motion was denied. Palantir agreed to pay I2 about $10 million to settle the suit. I2 was sold to IBM in 2011. Sankar, Palantir employee No. 13 and now one of the company’s top executives, also showed up in another Palantir scandal: the company’s 2010 proposal for the U.S. Chamber of Commerce to run a secret sabotage campaign against the group’s liberal opponents.

In one particularly memorable scandal involving Palantir, leaked emails released by anonymous showed the company offering to spy on progressive activists while working for the Chamber of Commerce.

Hacked emails released by the group Anonymous indicated that Palantir and two other defense contractors pitched outside lawyers for the organization on a plan to snoop on the families of progressive activists, create fake identities to infiltrate left-leaning groups, scrape social media with bots, and plant false information with liberal groups to subsequently discredit them. After the emails emerged in the press, Palantir offered an explanation similar to the one it provided in March for its U.K.-based employee’s assistance to Cambridge Analytica: It was the work of a single rogue employee. The company never explained Sankar’s involvement. Karp issued a public apology and said he and Palantir were deeply committed to progressive causes. Palantir set up an advisory panel on privacy and civil liberties, headed by a former CIA attorney, and beefed up an engineering group it calls the Privacy and Civil Liberties Team. The company now has about 10 PCL engineers on call to help vet clients’ requests for access to data troves and pitch in with pertinent thoughts about law, morality, and machines. One might expect, given its unparalleled snooping prowess, that Palantir's services would be in-demand in corporate America. However, the company has had only "mixed" results with corporate clients. Its work for the government occupies a much larger share of the organization's manpower. The company’s early data mining dazzled venture investors, who valued it at $20 billion in 2015. But Palantir has never reported a profit. It operates less like a conventional software company than like a consultancy, deploying roughly half its 2,000 engineers to client sites. That works at well-funded government spy agencies seeking specialized applications but has produced mixed results with corporate clients. Palantir’s high installation and maintenance costs repelled customers such as Hershey Co., which trumpeted a Palantir partnership in 2015 only to walk away two years later. Coca-Cola, Nasdaq, American Express, and Home Depot have also dumped Palantir. Karp recognized the high-touch model was problematic early in the company’s push into the corporate market, but solutions have been elusive. “We didn’t want to be a services company. We wanted to do something that was cost-efficient,” he confessed at a European conference in 2010, in one of several unguarded comments captured in videos posted online. “Of course, what we didn’t recognize was that this would be much, much harder than we realized.”

In a development that could very well make or break Palantir's business, the company is in the process of launching a new product called Foundry that is already being used by Airbus and a handful of other corporate clients. But Foundry's success is critical for pulling Palantir out of a slump that has inspired some of its backers to write down the value of their stakes.

Palantir’s newest product, Foundry, aims to finally break through the profitability barrier with more automation and less need for on-site engineers. Airbus SE, the big European plane maker, uses Foundry to crunch airline data about specific onboard components to track usage and maintenance and anticipate repair problems. Merck KGaA, the pharmaceutical giant, has a long-term Palantir contract to use Foundry in drug development and supply chain management. Deeper adoption of Foundry in the commercial market is crucial to Palantir’s hopes of a big payday. Some investors are weary and have already written down their Palantir stakes. Morgan Stanley now values the company at $6 billion. Fred Alger Management Inc., which has owned stock since at least 2006, revalued Palantir in December at about $10 billion, according to Bloomberg Holdings. One frustrated investor, Marc Abramowitz, recently won a court order for Palantir to show him its books, as part of a lawsuit he filed alleging the company sabotaged his attempt to find a buyer for the Palantir shares he has owned for more than a decade.

But Palantir has also enabled the LAPD to build an expansive gang database that, while effective at aiding in arrests, has also inadvertently led some people to be wrongly profiled as gang members.

In 2016, Rios was sitting in a parked car with an Eastside 18 friend when a police car pulled up. His buddy ran, pursued by the cops, but Rios stayed put. “Why should I run? I’m not a gang member,” he says over steak and eggs at the IHOP near his home. The police returned and handcuffed him. One of them took his picture with a cellphone. “Welcome to the gang database!” the officer said. Since then he’s been stopped more than a dozen times, he says, and told that if he doesn’t like it he should move. He has nowhere to go. His girlfriend just had a baby girl, and he wants to be around for them. “They say you’re in the system, you can’t lie to us,” he says. “I tell them, ‘How can I be in the hood if I haven’t got jumped in? Can’t you guys tell people who bang and who don’t?’ They go by their facts, not the real facts.”

While Bloomberg presents Palantir as a struggling business, we have a sneaking suspicion that the US government wouldn't allow one of its favorite contractors to go under. Even at an immense cost to taxpayers, we imagine Palantir will endure - and our standards of digital privacy will be all the worse for it.