This version of the forever war in Iraq and Syria was built around the work done by local U.S. allies. The fight against ISIS was America’s, but it was also being fought by Syrians, Kurds, and Iraqis—a U.S. strategy known as “by, with and through.” It meant that local troops carried out ground fighting in battles drawn up by American war planners. It meant that they received arms, training and logistical support from the U.S. military and were backed by U.S. air strikes. Crucially, it also meant that they were getting help from special operations forces, the U.S. military’s most elite units, who work in the shadows around the world to carry out difficult and sensitive missions.

Perhaps the best known unit is SEAL Team 6, which carried out the Osama bin Laden raid in 2011. But task forces made up of SEALs and other officially classified units such as the Delta Force have carried out the dangerous work of hunting terrorists and breaking up insurgent networks since America’s forever wars began. Often they work on their own, but sometimes, as in the war against ISIS, they work with local counterterrorism units specially trained for the task. In the “by, with and through” strategy, these special operations forces, along with the better-known U.S. Army Special Forces, or Green Berets, served as a force multiplier—a relatively small number of American boots on the ground who made the war effort by local forces far more deadly.

These partnerships have proved invaluable to the war against ISIS. At the same time, they have also opened a small hole in the secrecy that typically shrouds the special operations community—by giving the local partners who work with those forces a rare and up-close view of who they are and how they do their jobs.

Related podcast:

In Syria, elite U.S. troops among the 1,000 American personnel in the country worked closely with Kurdish counterterrorism units while regular Kurdish fighters carried out most of the ground operations against ISIS. The U.S. partnership with the Kurds grew as America armed and trained them and later merged them with Arab groups under an umbrella militia called the Syrian Democratic Forces. The SDF spearheaded the fight against ISIS in Syria, rolling back its most important strongholds. It has said it lost more than 10,000 soldiers in that fight.

U.S. military officials wasted no opportunity to laud the SDF’s prowess. So President Donald Trump’s announcement of a hasty and ill-planned withdrawal of U.S. troops from Syria to allow for a Turkish onslaught, left everyone—allies, lawmakers, defense officials, but most significantly the Kurdish-led forces themselves—stunned. Fearing for their existence in the face of an invasion from NATO-allied Turkey, which considers them an enemy, the SDF have rushed to strike a deal with the Iran- and Russia-backed Bashar al-Assad regime. While the details of this arrangement remain in flux, one possibility is for SDF forces to be folded into the Syrian state, following negotiations to which they suddenly bring very little leverage. As a result, the same Kurdish counterterrorism units who have worked with U.S. special operations forces and intelligence may suddenly find themselves working for—or at the mercy of—the Syrian government’s side. This raises a vexing counterintelligence question for America: might these units be forced to spill their secrets to some of America’s foremost global adversaries in Assad, Russia and Iran?

Eric L. Robinson, a former U.S. intelligence official who worked on anti-ISIS strategy at the National Counterterrorism Center, called the fact that the SDF had been forced to seek Assad’s protection in Syria a counter-intelligence “nightmare.” He worried, in a Twitter post this week, that “given years of SDF exposure” to U.S. special operations forces and intelligence, they would “be forced to give up TTPs [tactics, techniques and procedures], names, locations, etc. What a coup for the Russian intelligence services—five years of history regarding the elite forces of NATO.”

Robinson, who was a senior civilian in the United States Special Operations Command until last year, also noted that the same elite troops who served in Syria also work around the world on America’s most sensitive national security missions. They’re “from the same community that relieves an embassy under siege, identifies [North Korean] mobile missile capacity, rescues hostages, or defends Tallinn from [a] Russian invasion,” he wrote.

“We’re now five years into a relationship that has metastasized from a handful of basically cell phone connections between American special operations forces and [Kurdish soldiers] into a robust operation,” Robinson told me by phone.

Along the way, Robinson said, the Kurds “got a close look at the way Americans fight war, and [it was] an extraordinary chance to observe segments of the American military within special operations that are not necessarily covert or clandestine but do try to keep a low profile.”

“Whether [the Kurds] like it or not, they are exposed to the way the United States conducts unconventional warfare,” he added. “Whether you’re talking about communications infrastructure, or response times for Medevac, or response times for aviations support, that stuff is all interesting.” Robinson worries that any potential deal between the Kurds and Assad will include “not just speaking with Syrian intelligence officers but Russians and Iranians,” he told me. “It’s going to turn out that all of a sudden the ways that elite American counterterrorism forces operate are known to the opposition.”

The chaotic nature of the U.S. withdrawal from Syria—following a snap decision by Trump during a phone call with the Turkish president earlier this month—is unnerving those who have been involved in all levels of the fight against ISIS.

Brett McGurk, the former senior U.S. diplomat who helped to arrange and then oversee the partnership between the U.S. military and the Kurds, told me: “The chain of reaction from Trump’s call with Erdogan to a predictably catastrophic situation on the ground led to abrupt abandonment of military posts and relationships that had been built over years,” he said by email, declining to comment on specifics about the potential intelligence ramifications. “None of these issues were thought through or prepared, no consequences considered. It’s a disaster.”

Several news outlets have reported that U.S. troops who have worked with the Kurds in Syria are “heartbroken” and “ashamed,” while senior administration officials were reportedly left scrambling to deal with the ramifications of Trump’s decision. As they made their retreat in Syria, U.S. troops were reportedly fired on by Turkish-backed fighters. U.S. fighter jets later launched air strikes to destroy ammunition that American forces had left behind amid the chaos.

“We’re running out of appendages in which to shoot ourselves,” Brian Katz, a former CIA official who recently took a post as a fellow at the Center for Strategic and International Studies, told me. “Understanding how the U.S. military, special operations and intelligence community operates is going to be very valuable for Russia and Iran if not in Syria now then wherever we’ll be competing and fighting in the coming years. They’ll have a playbook for how we operate.”

A U.S. military official with experience on special forces missions pushed back against the idea that Kurdish counterterrorism units will reveal sensitive information. “It’s not a huge concern if they go and play ball with somebody else, because the relationship that we have at the tactical level endures over time,” he told me on condition of anonymity because he wasn’t authorized to discuss the issue publicly. He added that “there’s a counterintelligence risk whenever you work with a partner force,” and the U.S. military is accustomed to mitigating it.

I asked whether he was concerned about the identities of special operations forces being exposed. “I would say that’s by and large an individual’s responsibility,” he said. “I look about 15 years older and like a wild man when I have my beard [in the field], and I’m assuming that the majority of these guys are probably in similar fashion. There are ways that guys protect their identities when they’re down-range. It’s not like we’re giving our social security cards and bank information to the [Kurds].”

A spokesman for the U.S. military, Commander Sean Robertson, declined to comment on the issue in detail. “We take information security and operational security seriously. It is integral to our partnerships, and we plan for it regularly,” he said in an emailed statement.

The Kurdish militants who partnered with the U.S. military in Syria hail from the YPG—an offshoot of a separatist group, the PKK, that has waged a decades-long insurgency in southeastern Turkey and is labeled a terrorist group by the U.S. State Department. The U.S. relationship with the YPG was controversial from the start, and a major source of friction between America and Turkey.

While regular YPG forces carried out the various ground offensives, its specialized counterterrorism units worked with U.S. special operations forces to disrupt ISIS networks and target its leadership, Nicholas Heras, a fellow at the Center for a New American Security who briefs the U.S. military on Syria, told me. That work continued even after the demise of ISIS’s so-called territorial caliphate; in fact, it became arguably even more important as ISIS returned to its roots as an underground insurgency. YPG counterterrorism forces worked with U.S. troops to capture the Tabqa Dam from ISIS, Heras said, and conducted “other discrete operations to capture and kill ISIS targets.”

Heras traveled to SDF-held Syria this summer and met with Kurdish commanders who oversaw the YPG’s counterterrorism units. He learned how they worked not just with U.S. intelligence and special operations forces, but also with those from Britain and France. “This was a major line of effort that was quietly being done to improve the capabilities of the SDF and prevent the reemergence of ISIS,” he said. “It means U.S. special operations forces considered certain elements of the YPG to be so trustworthy that they can go on these sensitive missions.”

Heras stressed that it’s still unclear what will become of the YPG and its counterterrorism units under a deal with Assad, though he noted that integration into the Syrian security forces is one likely possibility. Even setting aside the potential counterintelligence risk that would come with the YPG switching sides, he added, the U.S. will suffer a major intelligence setback with the loss of a crucial partner.

“This kind of hasty withdrawal creates a collapse in our intelligence collection on ISIS,” Katz, the former CIA official, told me. “People sometimes think there’s this magical intelligence button that the military and intelligence community hits—boom, start collection now. But building an accurate and active intelligence picture of a terrorist group,and one as savvy and sophisticated as ISIS,is a tedious and years-long enterprise.”

All of that is now at risk of being lost. “It’s human intelligence that gives the U.S. government its best ability to understand the strategic plans and intentions of terrorist groups—not only their movements on the ground, but their plotting of extremist attacks,” Katz said. “And human intelligence requires proximity and access and trust and building relationships with sources on the ground.”

Another potential ramification for the U.S. intelligence community is the potential for mass escapes of ISIS prisoners. The SDF holds thousands of suspected ISIS militants, including many foreign fighters, in its territory. Some prison breaks have already been reported, and the fate of those prisoners who remain in SDF hands is uncertain. Heras, the CNAS expert, told me that the possibilities are grim: more could escape, or all could be handed over to the Assad regime, which could torture and execute them, or perhaps seek to co-opt them, as it did in sending jihadis against U.S. troops during the Iraq War.

Regardless, U.S. investigators will likely lose access to a vital source of information about ISIS. One former U.S. military officer who worked at senior levels of the anti-ISIS campaign told me he doubted that U.S. investigators had managed to interview all of the ISIS prisoners, especially those captured more recently. “We’ll lose out on interrogations that didn’t happen and on follow-on interrogations that won’t happen,” he said, asking to speak on condition of anonymity due to the sensitivity of the issue. “The historical knowledge that’s resident there would take years to get through. And that’s knowledge that we’re probably not going to have access to.”

Anne Speckhard, who directs the International Center for the Study of Violent Extremism, has interviewed dozens of the suspected ISIS prisoners held in SDF prisons. She told me that many had turned against ISIS and are powerful voicesin convincing others not to join militant groups. “Most of the people that we interviewed got disillusioned by ISIS—and got disillusioned because they felt ISIS is un-Islamic, corrupt and really brutal,” she told me. “We’re just losing a gold mine of data.”