Cuba objects based on the Vienna Convention treaty on treaties from the Carter era, but that explicitly states it doesn't apply retroactively. Cuba doesn't like it, it's likely unethical, and it would be illegal if it went into effect today, but as it stands it's not illegal under international law.
The same would also apply to Puerto Rico and other islands won from Spain.
That original treaty with Cuba was renegotiated later (to be more in Cuba's favor) and in any event requires that both sides agree or the US vacate the area in order to annul the treaty. Obama tried to close down the prison (one of the best things he tried to do as president), but Congress stopped him.
Every article starts with the Trump administration framing, and only afterward tells you WTF actually happened. I'm so tired of it.