From -- http://sfgate.com/cgi-bin/article.cgi?f=/c/a/2005/06/05/BUGG5D3FNS1.DTL&feed=rss.business
Foreclosure taxes: Suppose your house becomes worth less than you owe, you can't keep up the mortgage payments and the lender forecloses on the property.
You may be liable for two types of taxes: capital gains and cancellation of debt income. The same holds true if you abandon the property or voluntarily turn it over to the lender.
These taxes depend on whether you have a recourse or non-recourse loan.
Non-recourse generally means that if the lender takes over your house, your debt is satisfied and the lender can't go after your other assets, even if the proceeds from the foreclosure sale are less than the debt.
In California, if you take out a loan to buy a house or a building with up to four units and you live in the house or one of the units, the loan is non-recourse.
A recourse loan generally means the borrower is personally liable for repayment. If the lender takes over the house that is worth less than the debt, the lender can go after the borrower's other assets to pay the difference.
A home equity loan or line of credit is a recourse loan. So are consumer loans secured by your house.
In most instances, if you refinance your house, the new loan is a recourse loan, says Michael Pfeifer, a real estate attorney with Pfeifer & Reynolds.
However, Roger Bernhardt, a professor at Golden Gate University School of Law, says there is no California case law that definitively establishes this as fact.
If you borrow money to buy investment property, it is generally a recourse loan unless it was financed by the seller, in which case it is typically a non-recourse loan.
-- Non-recourse loans. If you default on a non-recourse loan, you could be subject to tax on capital gains, but you won't be taxed on the cancellation of debt.
When a lender takes over a property, it's treated as a sale. Your "sales" price is the outstanding debt.
Advice to homeowners. Get your Realtor or lawyer to put their claims in writing? There will be law suits when next years tax bills come due.
2/04/10 --- Update.
The rules have changed a bit since this post was first made.
For non recourse loans you want to look at CCP 580b.
For recourse loans your best protection may be CCP 726 - one action rule for the foreclosing lender (watch out for second loans)
IRS Taxes - look at non recourse loans or the mortgage debt forgivness act
CA Taxes - look at non recourse
Exclusions -- think about cap gains, insolvency - and for recourse loans you may wish to convert to a rental.
Finally beware that foreclosure anti deficiency laws may not necessarily be applied to short sales