According to who?
The right of conquest. See
https://en.wikipedia.org/wiki/Right_of_conquest"This meant that there had to be military occupation followed by a peace settlement, and
there was no reasonable chance of the defeated sovereign regaining the land. While a formal peace treaty "makes good any defects in title",[2] it was not required.
Recognition by the losing party was not a requirement, "the right of acquisition vested by conquest did not depend on the consent of the dispossessed state".[3] However, the alternative was annexation (part or in whole) which if protested as unlawful, a peace treaty was the only means to legitimize conquest in a time of war. Essentially, conquest itself was a legal act of extinguishing the legal rights of other states without their consent. Under this new framework, it is notable that conquest and subsequent occupation outside of war was illegal."
Conventions of war. History. Real life.