A recent ruling by the Supreme Court of Canada on the environmental obligations of energy firms is a negative for the big banks and may curb lending, says Moody’s Investors Service in a new report.

Last week’s Supreme Court decision overturned lower court rulings that allowed a bankrupt energy firm to abandon failed oil wells.

“The decision effectively grants priority to costs associated with environmental cleanup over the claims of banks and other creditors, thereby reducing recovery rates for banks in the event that an oil and gas producer goes into default,” the report says. “[T]his decision will increase loss-given defaults in cases of bankruptcy of energy producers, particularly non-investment-grade borrowers.”

As it stands, Moody’s estimates that about 65% of loans to the energy sector are to investment grade firms. “The majority of Canadian banks’ corporate loan exposures in the energy sector are to strong and well-capitalized borrowers, often exploration and production companies that are better able to survive an extended period of low oil prices than oil field services companies and other non-investment-grade borrowers,” it says, adding that these firms also “largely possess effective environmental, social and governance practices.”

Still, Moody’s also suggests that the ruling could also have the unintended consequence of restricting the amount of credit that’s available to smaller energy producers.