Hmm...the problem that I have with this is that you don't define the parameters enough. Are we talking universally or just certain countries like the United States? If the United States, are we talking anyone except U.S. citizens or everyone? You have to be more specific in what you're talking about. I will approach it from the way I think you are trying to do, which is just the U.S. Now, in that regard, I believe the Constitution directly addersses this subject, though somewhat a little vaguely:
The United States ConstitutionQuote:
Amendment 5 - Trial and Punishment, Compensation for Takings. Ratified 12/15/1791.
No person shall be held to answer for a capital, or otherwise infamous crime, unless on a presentment or indictment of a Grand Jury, except in cases arising in the land or naval forces, or in the Militia, when in actual service in time of War or public danger; nor shall any person be subject for the same offense to be twice put in jeopardy of life or limb; nor shall be compelled in any criminal case to be a witness against himself, nor be deprived of life, liberty, or property, without due process of law; nor shall private property be taken for public use, without just compensation.
Quote:
Amendment 6 - Right to Speedy Trial, Confrontation of Witnesses. Ratified 12/15/1791.
In all criminal prosecutions, the accused shall enjoy the right to a speedy and public trial, by an impartial jury of the State and district wherein the crime shall have been committed, which district shall have been previously ascertained by law, and to be informed of the nature and cause of the accusation; to be confronted with the witnesses against him; to have compulsory process for obtaining witnesses in his favor, and to have the Assistance of Counsel for his defense.
Quote:
Article III - The Judicial Branch/Section 3 - Treason
Treason against the United States, shall consist only in levying War against them, or in adhering to their Enemies, giving them Aid and Comfort. No Person shall be convicted of Treason unless on the Testimony of two Witnesses to the same overt Act, or on Confession in open Court.
The Congress shall have power to declare the Punishment of Treason, but no Attainder of Treason shall work Corruption of Blood, or Forfeiture except during the Life of the Person attained.
I believe these are the three best parts of the Constitution that address your question. The trick here is that this only applies to you
if, and
only if you are an actual U.S. citizen. If you aren't, your are in some serious ####. But, if you are a U.S. citizen, then the Constitution guarantees you the right to a fair trial and speedy trial, that excessive bail not be imposed or levied on you, that you don't have to be a witness against yourself, and that you don't have to submit to a search and seizure without a warrant. That being said, there is also the section in Article III on Treason, the only offense to be defined in the Constitution. That deals, of course, with people who knowingly help an enemy of the United States.
But what does all that gobbledygook above have to do with your question. A lot. As it pertains to your question, the only people affected are non-U.S. citizens (e.g. Guantanamo Bay detainees, terrorists, etc.) Anyone who doesn't have citizenship is not protected by the Constitution and can really be treated any way the retainers see fit.
Now I'm not saying that detaining someone against their will is right. I agree with you that it isn't and really shouldn't be allowed. But, as the law stands, anyone the United States catches and considers an enemy with good reason can be kept pretty much for however long the U.S. feels. Movie example,
The Rock. Sean Connery's character is captured and held captive for an indefinite amount of time by the United States for attempting to steal microfilm holding some of the nation's greatest secrets. He is not allowed to leave or to have a trial as he is not a U.S. citizen and won't cough up the film. In the end, it's all good cause he escapes and leaves the film behind. Another movie example,
Saving Private Ryan. In the film, the squad captures a German machine gunner after a long struggle and with a dead medic to boot. The men want to kill the man, but the captain has compassion and sets him off to hopefully turn himself in to the next Allied checkpoint. Later on, that same man kills the captain at the end of the movie. The point in my eyes comes down to this. Detention without a trial may seem horrible and unjust, but, if it is in the nation's best interest to detain someone for wanting to attack or hurt the United States, than so be it. I'd rather have them kept in prison where they can't do any harm rather than let go with the possibility of hurting the United States. If it was a U.S. citizen getting their rights taken away, that's on thing. But, if it is an enemy of the United States who can possibly be a threat and especially isn't a U.S. citizen, then I have no problem with indefinite detainment.

Paraphrase for light readers and skimmers: The United States should be allowed to indefinitely detain non-U.S. citizens
only if it's in the best interests of national security and with the proper just cause (evidence).