A credit default swap is a risk management device that functions like an insurance policy against an investment (e.g. a bond). It is used to hedge the default risk in the bond.
In the aggregate, however, credit default swaps are a suicide pact/hostage situation, as they create a chain of economic ties throughout the financial system that insures that the detonation of any sizeable institution will blow up more and more institutions back up the CDS daisy chain, wrecking all the financial institutions and the CDS holders don't get fully paid, either. It is the reason for the "tanks in the streets" threat of Hank Paulson when he demanded Congress pass the TARP bailout. The argument for the bailout was basically that the interconnectedness (in no small way through CDS) of the financial system made certain "systemically important" institutions "too big to fail".
The reason why this happens is that sellers of CDS very rarely hold onto that risk, they pass it on to hedge their own risk, and so on down the line until no one can be found to hold the financial bomb it represents. If the contract expires and the insured security didn't blow up, then all is good. If the security did blow up, then the CDS seller has to pay out in a big way. If they just don't have the money (and few do), then the CDS seller blows up, and then everyone who wrote CDS against that company has to pay up, and so on and so forth.
The chaining of risk works like this:
Bondholder hedges his risk by buying a CDS from Bank A
Bank A buys a CDS from Bank B at a slightly lower price, pawning off the risk and pocketing the difference as free money.
Bank B buys a CDS from Bank C, as above.
Bank C buys a CDS from Bank D, as above.
Bank D buys a CDS from Bank E, as above.
Bank E buys a CDS from Bank F, as above.
Bank F buys a CDS from Bank G, as above.
Bank G can't find a CDS seller at a lower price and is stuck with the net liability should the security default.
Now the security defaults.
Bondholder goes to Bank A and says "pay up".
Bank A goes to Bank B for the money to pay Bondholder, as per the terms of the CDS.
Bank B goes to Bank C for the money to pay Bank A, as above.
Bank C goes to Bank D for the money to pay Bank B, as above.
Bank D goes to Bank E for the money to pay Bank C, as above.
Bank E goes to Bank F for the money to pay Bank E, as above.
Bank F goes to Bank G for the money to pay Bank E, as above.
But Bank G doesn't have it. Barring intervention, Bank G goes tits up.
Bank G going tits up means Bank F is now on the hook for the CDS they wrote - and they didn't expect to be since their paper risk was a technical zero (according to a badly flawed, but quite popular theory).
Bank F doesn't have the money, so they go tits up, leaving Bank E on the hook.
Bank E doesn't have the money, so they go tits up, leaving Bank D on the hook.
Bank D doesn't have the money, so they go tits up, leaving Bank C on the hook.
Bank C doesn't have the money, so they go tits up, leaving Bank B on the hook.
Bank B doesn't have the money, so they go tits up, leaving Bank A on the hook.
Bank A doesn't have the money, so they go tits up, and Bondholder doesn't get paid, and any number of banks were just wiped off the face of the planet.