Making a bad situation worse for people already hit by the real estate downturn, thousands of Americans are facing the possibility that their homes are the equivalent of toxic-waste dumps. But while the IRS doesn’t usually spring to mind as an organization that comforts the afflicted, the agency recently took action to provide a measure of help to these taxpayers. At issue are thousands of homes — the vast majority of them in Florida, Louisiana, Mississippi, Alabama, and Virginia — built with corrosive drywall that may be eating away at at the rest of the house and harming occupants’ health. If you’re among those affected, you’ve likely already realized how difficult it can be to get remuneration from insurers or builders. But you can at least count on some relief on your taxes for fixing the problem, thanks to IRS guidance released Sept 30. Imported from China, the offending material was primarily used within walls and ceilings of homes built between 2006 and 2007, when American-made wallboard was in short supply. Over the past several years, the Consumer Product Safety Commission has logged thousands of complaints from Americans who live in homes constructed with the material, which was recently shown by Lawrence Berkeley National Laboratory to emit higher levels of hydrogen sulfide than other wallboard. Many of the complaints have noted corrosion of metal wiring in the home, as well as of the components in household appliances, creating a possible fire hazard. Consumers have also recounted a rotten egg-like odor, as well as health concerns such as rashes, itchy eyes, asthma and bloody noses. The Consumer Product Safety Commission, which has been investigating the matter, now advises affected homeowners to remove the wallboard. But the costs to do so are substantial: around $50 per square foot, says Ken Flanz, owner of contracting firm Terre Neuve Corp., which performs the task in Broward County, Florida. Given that the average size house built in 2007, when much of this wallboard was installed, was 2,479 square feet, you’re looking at a final tab of around $125,000. And that doesn’t include the costs to live elsewhere while your home is being torn to its skeleton. Homeowner’s insurance won’t cover the bill, since policies exclude problems caused by shoddy construction. (Michael Barry of the Insurance Information Institute explains it with this analogy: “If I buy a lemon at the car lot, I don’t file a claim with auto insurer.”) To boot, some insurers are dropping coverage for houses that have the drywall. Homebuilders haven’t been eager to chip in either, resulting in countless lawsuits. But the IRS’s assistance allows people who are affected to take a casualty loss deduction on schedule A of their 1040 for costs incurred to fix the problem. As with anything tax related, there are limitations: • You must take the deduction in the year the costs were incurred — though you may amend returns from the previous three years. • Your drywall must meet the terms set forth by the CPSC. • You must itemize to take the write-off. • You can only write off the loss to the extent that it exceeds two floors: The amount that is above $100, and that is also above 10% of your adjusted gross income. So if your AGI is $100,000, you can deduct the amount of the loss that is in excess of $10,100, says Melissa Labant of the American Institute of Certified Public Accountants. • If you have a pending claim for reimbursement, either with a builder or via a lawsuit, you can file for only partial reimbursement. Even with all these caveats, the deduction can be worth quite a bit of money — and it’s certainly more help than homeowners can expect from other sources. A couple with an AGI of $100,000, who live in the average size house built in 2007 and who fixed their drywall, would not owe any federal taxes, says Labant. “The casualty loss,” she says, “would have eliminated their federal liability for the year.” Find MONEY magazine on Facebook.