Nearly 400 Wells Fargo customers lost their homes when they were accidentally foreclosed on after a software glitch denied them the ability to modify their mortgages as they sought federal aid, the bank disclosed in a regulatory filing late Friday.

The bank apologized and has set aside $8 million to compensate those affected by the glitch, which occurred from 2010 to 2015.

"During the course of an internal review, we determined that an automated calculation error may have affected the decision on whether or not to offer or approve some mortgage modifications between April 13, 2010 and Oct. 20, 2015, when the error was corrected," Tom Goyda, senior vice president of Wells Fargo said in a statement to the Business Times. "We're very sorry that this error occurred and are providing remediation to the approximately 625 customers who may have been impacted."

Wells Fargo said the software mistake miscalculated customers' eligibility for mortgage modifications. The error caused about 625 customers to be denied loan modifications they sought from a federal program to help homeowners avoid foreclosures.

While those amounts may seem small, considering Wells originated nearly $95 billion in mortgages in 2017 and is the largest mortgage servicer in the U.S., Wells is still grappling with public trust issues since September 2016, when it revealed a settlement with banking regulators over creating 3.5 million phantom accounts without customers' knowledge, in order to meet company sales targets. The bank agreed to pay $185 million in penalties and $5 million to customers in that case and then fired 5,300 people over the scandal, including the ouster of its CEO and several top executives in consumer banking. But then the cavalcade of scandals didn't stop there.

Just last week, in a separate settlement with the U.S. Justice Department, Wells Fargo, the second-largest mortgage agreed to pay a $2.1 billion fine for issuing loans it knew were based on false income information.

Wells Fargo is operating under a Federal Reserve cap on asset growth, placed by former Fed Chairman Janet Yellen before she left office in February. The Fed ordered Wells to fix control and compliance problems involving misleading sales practices in consumer banking. Separately, the Justice Department and the Securities and Exchange Commission are investigating its wealth management division. The bank said it paid $114 million to refund wealth management customers who had been overcharged in the last seven years, and $171 million for foreign-exchange clients.

Last year, Wells Fargo & Co. disclosed that it charged 570,00 auto-loan borrowers for insurance they did not ask for or need. That practice ran from 2012 to 2017. About $80 million was set aside by the bank for refunds and to compensate victims.

More from San Francisco Business Times:

Wells Fargo parts with four risk-management execs as shake-up continues

The feds are investigating Wells Fargo again, this time for retirement account rollovers from 401(k)s to bank IRAs

Beleaguered Wells Fargo hit with $2 billion fine over mortgages