I'll give this a shot, since the only two people that already answered as I'm typing this ignored your question completely. He didn't ask if it is within his legal right, which is what you seem to be stuck on. He even mentioned that their lawyers assured them there would be no legal ramifications. The question (s)he asked is whether or not this is ETHICAL.

As to the person that suggested he "do whatever is in his best interest within legal limits": there are other things in life besides money. This may not be true for everyone, but it's clearly at least somewhat true for OP, since (s)he asked this question in the first place.

Now, as a freelancer, I have been in your shoes a few times before, when I could have easily adapted the client's project and published it as a SaaS. I imagine it may be even easier for you, since you represent a company, that probably has the funds to also properly promote and advertise a SaaS project, not just develop it.

So, it may go against the collective opinion, and the term "ethical" can be somewhat subjective, but I will argue that no, it's NOT ethical, despite you being well within your legal rights. When somebody pays for a project, they are already taking the huge risk that the project will fail spectacularly. For them having to worry that their contractor will also just take their project, repackage it, and come into direct competition with them, well, this is simply not fair. Reusing code is one thing, simply tweaking their project and releasing it on your own is quite another.

Also, not only do I think what't you're doing is wrong towards your client, I think what you're doing is actually hurting all of us. Freelancers and software companies alike. If every software contractor would start repackaging their customers' products, pretty soon no one would have enough trust in any of us, and for good reason.

Now, you may say, as others have already said in this thread, "If they don't want this to happen to them, they should protect themselves in the contract", and this is a valid argument, as formal logic goes. However, the relation between customer and contractor shouldn't be one where both sides have to always stay on their guard, always expecting for the other side to screw them somehow.

Somebody might also argue that it's also not fair towards you if, for every project you develop for a customer, you close a door in your potential future, and this is also a valid argument, but it's not what I'm saying. Again, there is a substantial difference between applying the things you learned about the client's business in a project in a different segment within the same market (I am using very vague terms, I know, but it's only because I don't know the details of this particular project), and using their own project to compete with them, after they paid you to develop it.

We sure love hating on soulless corporations that will stop at nothing for profit, yet when it's us that are doing it it's suddenly ok. How about we treat each other with some basic dignity for a change? If you think a customer's idea is worth implementing for yourself, don't use the guy simply as a way to fund your own projects. Refuse their project if you think you would like to do something similar yourself. And if you already developed it for them, move on, there will be other ideas.