You're completely right, what do we do ?
How do we address the situtation without making things even worse ?
Well, you could write a book on this topic but I will try and cover what I think needs to be done immediately or this is going to explode into a unstoppable problem. (No pun intended)
First I think the United States needs to pull out of the U.N. and other countries should follow suit. The U.N. is a failed body that does little more than waste money, perpetuate corruption, and bicker with little action. In almost every prior human rights violation (Rwanda) to current problems with Israel and Lebanon (U.N. was stationed there for decades and did not prevent the terrorists from moving in) did nothing or prevented nothing. The United States funds around 25% of the U.N. budget a year, yet has its proposals blocked by Russia and China who obviously have other agendas.
Once the United States is out; the U.S. and its allies need to find which countries actually, truly, want to help curb terrorism and open the diplomatic channels with these countries to start gathering and sharing all information that these countries have on terrorists and the like. Possibly even start a computer based system that makes this easier. Hell, all the money the U.S. spends on the U.N could more than fund this.
Secondly the U.S. and its allies (allies referring to countries that are 100% for removing terrorism and not playing politics) need to come to a understanding that this might require military force and that if that should happen a international force could be assembled. Something similar to a NATO force. But there must be international planning and strategy to assure that the best people are running the show, so we don't have another Iraq war.
I know this sounds a lot like the U.N., but its vastly different. Here we don't have a huge paper pushing body centrally located somewhere. What I am talking about is having summits, like what happened after WW2, where the top dogs from each country meet and hammer out an action plan. It would take as long as possible; days, weeks, months.
But the absolute key to this is human intelligence, which requires that we have middle eastern allies. And not just good intelligence, but the sharing of everything; not just the intelligence, but how it was obtained so that you can have the entire international body working as efficient as it can But with how the U.S. has been doing business in the middle east, that may be hard. And I know this is all wishful thinking, but sometimes that what it takes to get the job done.