The U.S. wars in Iraq and Afghanistan have been declared officially over, but America has barely begun to pay the bill, says a new study. That could make defending the nation and paying the government's bills even tougher to do in the future.

The Iraq and Afghanistan wars will together cost $4 to $6 trillion, according a new study from Harvard University's Kennedy School. A large share of those bills has yet to be paid: the study finds that the U.S. has spent around $2 trillion thus far on the two controversial wars, and that growing commitments to spending on military personnel and veterans will drive much of the spending in the decades to come. The study notes that the Veterans' Affairs budget has tripled since the start of the wars.

"Assuming this pattern continues, there will be a much smaller amount of an already-shrinking defense budget available for core military functions," writes Linda Bilmes, senior lecturer in public policy at Harvard and the study's author.

Bilmes has been studying the costs of the two wars for years, and she says that the estimates of the total cost continue to climb as the cost of continuing care for veterans mounts.

"What has happened is the number of injuries and the number of claims and the complexity of claims...in these conflicts has been much higher than in previous wars," she says. She notes that after Vietnam, veterans averaged around two and a half to three conditions per claim, whereas veterans now have over eight conditions per claim.

Of the nearly 1.6 million troops that have been discharged from the wars, over half have received Veterans' Affairs medical treatment and will also receive benefits for the rest of their lives. Those costs will stack up as more troops are discharged and need benefits. The study finds that providing medical and disability benefits to vets will eventually cost over $836 billion.

This long tail of spending follows a well-established historical trend, writes Bilmes: disability spending on World War I veterans hit its peak in 1969, and spending on World War II veterans was at its highest in the late 1980s.

There are other factors at play here, however: the military must also spend on replacing worn-out equipment and on interest on the cost of the wars. In addition, Congress ramped up spending on personnel and veterans during the wars, increasing pay for troops to counteract difficulties in recruitment and expanding the military's TRICARE healthcare system. Bilmes believes that spiraling costs may have the potential to change spending on veterans from a "sacred cow" to an area with real potential for deficit reduction.

"If you look at some of the costs that are baked into the system as a result of the wars—military pay raises, military health benefits, expanding the TRICARE system—it's more expensive to have personnel in the Defense Department," which could pressure lawmakers to target that area for cuts in the future. There has already been a glimpse of that in the willingness of some on Capitol Hill to accept the forced cuts of sequestration, which did not exempt the military.

While this study puts the total cost of the wars at $4 trillion to $6 trillion, assessments of the wars' costs do differ from source to source. While the Harvard study puts the cost of the two wars thus far at around $2 trillion, the Congressional Budget Office as of October 2012 said that only $1.4 trillion had been appropriated, though they do not account for some areas, like Social Security Disability Insurance, Bilmes points out. In addition, while she estimates the total cost of the two wars at $4 to $6 trillion, the Costs of War project at Brown University estimates it at around $4 trillion.