Imagine attending an open house and stepping into a newly remodeled master bathroom complete with brand-new Carrara marble tiling and a luxurious free-standing tub. Home improvements like this are enough to make potential home buyers fall in love, and it may even motivate you to make an offer on the spot.

But what may seem like a dream perk at an open house can turn into an expensive nightmare if there’s no permit paper trail and the home improvements were done without the proper authorizations. Why? Because, depending on where you are in the buying process, unpermitted work could leave you (yes, you) on the hook for way more than you bargained for.

Want to save yourself from this predicament? Read on for everything you need to know about buying a home with work done without a permit.

How do you know if work was done without a permit?

“All sellers have to give buyers something called a property disclosure,” says Andrew Hillman, a broker at Hillman Real Estate, in Boston. “This will list information about what the current owners have done to the property during ownership, including work done without a permit.”

As an extra precaution, you can also cross-check with your local building department to see if the owners pulled permits. Many municipalities, such as New York City, have the status of permits online. Otherwise, you can call or visit the local buildings department for information. Remember, building codes and permit requirements vary with every city and town.

What is your responsibility as the home buyer?

The last thing you want to do as a home buyer is get your own hands dirty with sourcing permits or paying fees. But your responsibility in the matter all depends on where you are in the closing process. If you haven’t signed the purchase agreement yet, the seller can be held accountable for obtaining and closing out permits. But that’s easier said than done. It could take weeks or even months to close out permits.

Your best bet is to put language in the contract before signing stating that the seller has to take care of pulling a permit and having the local building inspector sign off on a certificate of occupancy before closing.

“Your attorney can draft the amendment to the contract for you,” says Beth Jaworski of Shorewest Realtors, in Wauwatosa, WI.

But once the contract is signed, the buyer assumes all responsibility for work done without permits.

“Buying a home without performing due diligence is as irresponsible as the homeowner who doesn’t pull permits,” says Hillman.

Still, all hope is not lost if your contract is already signed. There may be contingencies that can halt the transaction and give you some leverage.

How your appraiser and home inspector can help

One of the main contingencies all contracts have is the inspection period. A professional home inspection can identify unpermitted construction, work not completed to code, and other potential surprises before you commit to buy the property.

“The inspector can also check with the local permitting department to see what permits have been obtained,” says Brad English, a real estate professional with First Team Real Estate, in San Clemente, CA.

Your appraiser will help. “When I do a walk-through of a dwelling, I ask about the legality of a deck, living space, or an extra bathroom not found on the property record card,” says Ginna Currie, a New York state general appraiser at C.T. Appraisals.

Depending on the language in your contract, you have the right to terminate the transaction if you are not satisfied with the results of your home inspection or appraisal.

What’s the worst that can happen?

The worst-case scenario: Your city can “fine you for having unpermitted work, force you to remove the improvements, and you’ll have to start the process over to have the work done legally,” says Currie.

Keep in mind pulling a permit can cost hundreds of dollars. And having the work brought to code by a contractor will be an additional expense. But if you don’t pull permits during this transaction, the issue can arise again if you choose to sell your home later on.

“If the unpermitted work isn’t allowed at all, the city inspectors can make the homeowner tear down or remove the renovation or addition,” says Hillman. And if the inspectors don’t make the homeowner tear something out, you can at least expect a tax assessment for any improvements.