Since World War II, Turkey has become increasingly important ally to the West, and energy is at the heart of the alliance.

The Baku-Tbilisi-Ceyhan (BTC) pipeline has carried Azerbaijani oil across Turkish territory into Europe since 2005, and the Trans-Anatolian pipeline (TANAP) is due to start piping gas from the Turkish-Georgian border to the Turkish-Greek border in 2018. Both are key nodes in Europe's strategic Southern Corridor vision to break Russia's chokehold on European gas supplies.

But there is another side to the coin.

In a world knitted together politically and economically by a vast network of oil and gas pipelines, a terrorist group no longer needs to come to Europe or the U.S. in order to damage the their strategic and economic interests. The July 25 attack on the Turkish town of Suruç, apparently carried out by the Islamic State (ISIL), has unleashed a wave of instability. It has raised fears that Turkey may not be immune from conflict overspill in an increasingly violent neighborhood, giving Western policymakers pause for thought.

Turkey has strategically positioned itself as an energy hub connecting the hydrocarbon reserves of the Caspian (and perhaps the Gulf in the longer term) to a set of European countries looking to boost their energy security. Their quest has only been heightened by the diplomatic rift between Russia and the West provoked by the Russian-Ukrainian war.

But Turkey is heavily exposed to the intractable conflicts on its southern borders. In addition to its role as a Eurasian energy bridge, Turkey has also become a transit hub for fighters with ISIL and arms crossing into Syria and Iraq. The BTC pipeline too is exposed, running into the Mediterranean port of Ceyhan, only 100 kilometers from the Syrian border.

Until recently, Turkey had been hesitant to contribute militarily to the fight against ISIL for fear of provoking counterattacks. At the same time, Turkey's leaders have also been maintaining a fragile ceasefire, negotiated in 2013, with the militant group the Kurdistan Workers Party (PKK), who have been locked in a battle with the country's majority of Turks for decades.

However, at the end of July, in a matter of days the Turkish military launched strikes first on ISIL militants in Syria and then on PKK camps in Iraq. The attacks were prompted by an agreement made with the U.S. for U.S. military forces to use Turkey's Incirlik base for launching attacks into Syria.

Despite claims by Turkish Prime Minister Recep Tayyip Erdogan in 2013 that he was committed to reaching a peace deal "even if it costs me my political career," Turkey analysts have been quick to accuse him of a cynical move to use a military campaign against ISIL as a front for a cynical political move to roll back the Kurds' political gains in parliamentary elections earlier this year.

Suddenly, Turkey, which once proclaimed a "zero problems with the neighbors" policy, is fighting a war on two fronts. Both of the attacks made by the Turkish military were retaliatory attacks — the first instance for a suicide attack on a cultural center in the southeastern border town of Suruç that killed 32, and the second for the PKK's killing of four Turkish police officers.

The tit-for-tat attacks continue, and Turks across the country are beginning to fear reigniting the bloody civil war that saw Kurdish guerrillas sow terror across the country in the 1980s and 1990s, as well as fears of possible terrorist attacks on the capital Istanbul. The country's carefully crafted stability, and Erdogan's promising detente with the Kurds, are unraveling at the seams.

Experience in oil-producing countries from Colombia to India, Iraq and Sudan has shown that oil industry infrastructure is an easy target for terrorist groups.

Colombia's Caño Limón pipeline has been blown up so many times by guerrilla groups that it is known locally as "the flute." In 2004, Osama bin Laden specifically called for jihadists to "take their jihad to the oil industry" by attacking oil installations in Iraq. The Kurds themselves are well-practiced in meddling with strategic energy infrastructure in their battle against the Turkish state, including one that shut down the BTC pipeline for 20 days in August 2008.

This is largely because pipelines that stretch for thousands of kilometers are as easy to blow up as they are difficult to secure. The former head of the U.S. Navy Seals has even warned that the Keystone XL pipeline could be vulnerable to terrorist attacks.

A state simply cannot place security guards along the entire length of a 1,800-kilometer pipeline like TANAP. Instead, common remedies are aerial surveillance and warning systems, backed up by limited security personnel. Fearful of attacks from Russia on the BTC pipeline, pipeline investors in Georgia in 2006 rejected unmanned reconnaissance aircraft in favor of "small, roving anti-terror squads," trained of course by U.S. and SAS veterans.

We are now, however, in the age of the "smart pipeline," where sensors attached to infrastructure provide constant real-time feedback for analysis at headquarters. The builders of TANAP have more high-tech plans to secure their investment. A draft revealed plans to shield the pipeline from attacks using lasers, optical sensors, motion perception cables and advanced surveillance cameras that will link up to "control chambers" along the route.

Mercifully, the route of TANAP gas pipeline lies further to the north than the BTC oil pipeline, skirting around the less stable regions on the Syrian border. The best hope for a more secure gas supply route through Turkey lies in a de-escalation of the battle it is waging against the Kurds.

In the meantime, we can be sure that Azerbaijan, Turkey and BP the co-investors in TANAP will be throwing whatever resources necessary at securing this intensely political piece of infrastructure.