Every year, the Social Security Administration collects billions of dollars in taxes that it doesn’t know who paid. Whenever employers send in W-2 forms that have Social Security numbers that don’t match with anyone on record, the agency routes the paperwork to what’s called the Earnings Suspense File, where it sits until people can prove the wages were theirs, allowing them to one day collect retirement benefits.

The Earnings Suspense File now contains Social Security tax forms that date back to 1937 and are linked to the taxes that were paid on nearly $1.3 trillion in wages. Some of the W-2s in it belong to people who got married and never reported changing their name. Others are people who filled out their tax forms incorrectly. As of 2014, efforts to track these taxpayers down allowed the Social Security Administration to match 171 million tax forms to their rightful owners.

But there are still about 340 million unclaimed tax forms recorded in the file, compared to 270 million nearly a decade ago. A good portion of those forms were filed by employers on behalf of some of the most unlikely funders of Social Security: undocumented immigrants. In fact, illegal immigration is considered largely responsible for the mushrooming of the file, with undocumented workers paying billions in taxes for retirement benefits they will likely never receive.

It works like this: Many immigrants who aren’t authorized to work in the United States buy fake Social Security cards and present them to their employers, who either don’t know they are fake or don’t look too closely. When the employer submits a W-2 form and a tax payment on those workers’ behalf to the Social Security Administration, the federal government holds onto those payroll taxes, even if the Social Security number isn’t linked to anyone on file. And then, a large chunk of that money ends up in the Social Security trust funds, from which retirement benefits are doled out to aging Americans.

The Social Security system has grown increasingly reliant on this stream of revenue, particularly as aging Baby Boomers start to retire. Stephen Goss, the chief actuary of the Social Security Administration, estimates that about 1.8 million immigrants were working with fake or stolen Social Security cards in 2010, and he expects that number to reach 3.4 million by 2040. He calculates that undocumented immigrants paid $13 billion into the retirement trust fund that year, and only got about $1 billion in benefits. “We estimate that earnings by unauthorized immigrants result in a net positive effect on Social Security financial status generally, and that this effect contributed roughly $12 billion to the cash flow of the program for 2010,” Gross concluded in a 2013 review of the impact of undocumented immigrants on Social Security.

Ironically, it was a piece of legislation aimed at curbing the hiring of undocumented immigrants that created this steady source of revenue for the Social Security system. In 1986, the Immigration Reform and Control Act set penalties for employers who knowingly hired undocumented immigrants. It was the first time the federal government had made it a crime to employ undocumented workers. Yet instead of destroying the underground labor market, this new law just made it more sophisticated, producing a thriving market for fake U.S. birth certificates, IDs and social security cards, which undocumented workers presented to their employers when asked for their papers. Undocumented workers started filling out W-2 forms, and the federal government began receiving and holding onto payroll taxes, even though the fake social security numbers didn’t match anyone in the system. The Social Security Administration sends no-match letters to employers to alert them of the problem and urge them to resolve it.

As rhetoric about illegal immigration dominates this election cycle, it’s hard to argue that undocumented immigrants drain the system. It’s true that not all undocumented workers pay federal income and social security taxes; many are still paid in cash and never fill out W-2 forms, so it’s unclear how many of them independently file tax returns as self-employed contractors. The Institute on Taxation and Economic Policy, a Washington, D.C., think tank, estimates that about half of undocumented workers in the United States pay income taxes. They also help fund public schools and local government services by paying sales and property taxes like any other resident. This added up to about $10.6 billion in state and local taxes in 2010, according to an analysis by the institute.

And in the past 20 years, the Internal Revenue Service has made it easier for workers to pay taxes if they don’t have a social security number (or a fake one, for that matter). Workers who are paid illegally in cash can still pay their taxes with an Individual Tax Identification Number (ITIN), filing a return just like any other taxpayer; having a history of paying taxes can be an important step in securing legal status. In 2010, about 3 million people paid over $870 million in income taxes using an ITIN, and according to the IRS, ITIN filers pay $9 billion in payroll taxes annually. (The IRS says it does not share ITIN information with immigration authorities.)

Tanya Gonzalez, the executive director of the nonprofit Sacred Heart Center in Richmond, Virginia, organized the first federally-funded, bilingual tax-assistance program in the region, which sits in one of the two states that have seen increases in the number of undocumented immigrants since the recession. She kept hearing that undocumented immigrants in the Richmond area were getting ripped off by tax preparers, and a friend at the IRS told her about the federal grants offered to open free tax-assistance centers in low-income areas.

At Sacred Heart’s tax-assistance site, she has helped hundreds of immigrants apply for a taxpayer identification number, which allows them to file their taxes as contractors. The use of ITIN has grown popular among immigrant workers in Richmond, she says, as many await comprehensive immigration reform. Past legalization efforts have required undocumented immigrants to prove how long they’ve been living in the United States, and to pay the taxes they owe before receiving legal status. “They want to show that they’ve been paying taxes and have their papers in order as much as they can.” says Gonzalez, adding that some people are on payment plans, while others simply can’t afford to pay taxes at all.

One undocumented worker from Central Mexico who gets help with his taxes at Sacred Heart told me that he began paying taxes four years ago, after learning that it might one day help him stay in the United States. (He asked not to be named because of his legal status.) A 31-year-old landscape worker, he moved to Richmond in 1999 and now makes up to $1,700 a month maintaining golf courses seven days a week. Workers at Sacred Heart told him that if he filed taxes with an ITIN, it could help him gain legal status in the United States if Congress passes comprehensive immigration reform. As those efforts remain stalled in Washington, D.C., his wages are recorded into the Earnings Suspense File, and his taxes go into the Social Security trust funds. “So many people say we are here burdening the country, but we are paying their retirements,” he told me. For now, he doesn’t mind supporting the social security system, he says, but hopes one day he can reap the benefits too.