The Social Security Administration receives billions in free money each year from an unexpected source: undocumented immigrants. This group paid an estimated $25.7 billion in Social Security taxes in 2022, according to a recent analysis from the Institute on Taxation and Economic Policy, a left-leaning tax research group. Since unauthorized workers cannot collect retirement and other Social Security benefits without a change to their immigration status, the billions they pour into the program effectively act as a subsidy for American beneficiaries. President-elect Donald J. Trump has vowed to carry out the nation’s largest mass deportation program to date, and restrict legal pathways to immigration. It’s hard to predict whether the incoming administration will be able to follow through with its most aggressive promises, among them sending home the estimated 11 million undocumented immigrants currently in the United States, most of whom are of working age. But if the White House does follow through, economists project a broad drag on the economy — and it could cost Social Security roughly $20 billion in cash flow annually, according to actuaries at the Social Security Administration, which sends benefits to 68 million Americans each month, totaling $1.5 trillion last year. Social Security has faced a financing shortfall for years, partly because of demographic shifts. Falling birthrates mean fewer people are paying into the program, thousands of baby boomers are retiring daily, and retirees are collecting benefits for longer periods. “America’s demographic realities are increasingly challenging for financing programs like Social Security,” said Shai Akabas, executive director of the economic policy program at the Bipartisan Policy Center, a nonprofit. “Net immigration into the country is one factor that has positively pushed against that trend and helped fill the gap left by an aging work force.” The trust fund that pays Social Security’s retiree benefits is expected to run dry in 2033, when tax revenue will be enough to pay 79 percent of scheduled benefits. That means beneficiaries’ checks would be reduced by 21 percent if Congress did nothing. (Legislators are expected to do something, though there is a debate about the best approach to shore up the program.) Major shifts to immigration policy could have ripple effects on Social Security. The net immigration rate was projected to drive population growth — and account for all population increases beginning in 2040 because American fertility rates are so low, according to a 2024 report from the Congressional Budget Office. “If the immigrant work force declines, that will likely worsen Social Security’s financial picture in the near term and require more significant reforms elsewhere,” said Mr. Akabas of the Bipartisan Policy Center, which recently studied the issue. “That said, the broader questions of immigration policy and border security require careful thought that goes beyond their impact on the Social Security program.” To get a sense of how different levels of immigration — both lawful and otherwise — can alter the program’s finances over the long term, we can look at the Social Security Administration’s latest annual trustees report, which forecasts the financial health of the combined trust fund for retiree and disability benefits over a 75-year period starting in 2024. (Social Security’s shortfall is often measured as a percentage of the total payroll covered by the program, or all the wages subject to payroll taxes, the program’s dedicated funding source.)