One possibility is that the person submitting the thesis can have their degree revoked. This is not strictly a legal matter, rather it is a matter between the student and their university, where the university can, after a process, revoke the degree. The grounds would be a violation of university rules pertaining to requirements for the degree, specifically the part where the student must submit a thesis representing "independent research". The exact wording of the requirement is obviously institution-dependent, and of course no university requires completely autonomous and isolated research and writing in the production of a thesis. It would be rather off-topic though fascinating to collects anecdotes on variation between institutions on what degree of collaboration is deemed acceptable. From the legal perspective, the student whose degree is revoked could attempt to sue the university for the revocation, since the student has a property interest in the degree, but generally university proceedings are held by the courts to be valid.
Another way to "claim" a work as your own is with respect to copyright. In that case, though, there has to be more than vague collaboration, there has to be actual co-authorship. The basic legal idea is that when multiple authors write a work, they jointly own the work (the work is called a "joint work"). The basic definition of a joint work under 17 USC 101 is "a work prepared by two or more authors with the intention that their contributions be merged into inseparable or interdependent parts of a unitary whole". Sharing of ideas or lab results doesn't make something a joint work, there has to be actual co-writing.
The US Copyright Office interprets that as meaning that authors have equal rights to the work (an undivided ownership share): in other words, any author can grant permission to publish, and a copyright license of transfer of rights does not have to be agreed on by both authors. However, profits are to be shared equally among the authors, in the same way that joint partners in a business venture share the profits of their business. This is so even if one author writes 90% of the work and the other one writes 10%.
This can then lead to a legal problem between the publisher and the non-signatory author. Typically, when a work is published, the publisher obtains from the contributor either a license to reproduce, or else a transfer of copyright, which allows the publisher to reproduce the work. Such agreements typically contain a clause where the contributor warrants that they have the right to transfer / license and that they are the sole author, or else the co-authors have been identified in the agreement (in which case the publisher pursues each author to get a signature on an agreement form). And there is almost surely an indemnification clause, saying that the contributor will indemnify the publisher against any infringement claims. Which is another way of saying, if it turns out that the contributor does not have the right to fully assign copyright to the work and the publisher gets sued, the contributor must cover the publisher's legal costs and possible losses from a judgment. As a co-author, you cannot grant an exclusive license (as some publishers will require).