Selling ships is slightly different than selling missiles. While it can come back on you, it likely won't be an issues, since the old ship can usually be identified easily enough, and whatever systems were on it back in the day are either obsolete, or have been stripped and replaced with whatever the locals put on them. An 40 year old American crusier was a threat to the Royal Navy in the Falklands for a tiny bit. And Taiwan and many other countries have older American ships. Some sold after their service to the United States, and some build for sale to begin with. Or even build locally using the American designs (Australia I think was building American frigates for a time). Iran almost got four destroyers the Americans were building for hem before 1979 (Taiwan now has them after they served the United State for 25 years). Iran did get several F-14 Tomcats and Phoenix missiles prior to 1979. They were the only country to purchase those systems outside the USA. This was a reason why the US Navy didn't use the F-14 over Iraq all that much. The Iraqi were too use to them from fighting the Iranians for eight years.
Starfleet can likely make sure the ship's transponder is set so that they can easily check on old ships. And also keep weapons tech out of the hands of races that generall don't already have access to said weapons. Though they aren't above pushing a few weapon improvements that help Federation interests (they did aid the Cardassians in improving weapons technology against the Klingons and later helped the rebellion against the Dominion. More aid than they gave Bajor at first).
Indeed, and "The Next Phase" has a situation like this. The Romulans want a computer to replace their damaged one, and Riker and Worf privately agree that they should only have access to one three or four decades old that they're already somewhat familiar with. I can't recall if there are any other such mentions at the moment, but there probably are. I think SicOne has some valid concerns about letting potential enemies get too familiar with technology, but I'm also inclined to think that can be easily controlled by the owner's government.
I suppose one potential concern is what happens when a group that is poorer in arms or resources nonetheless comes up with a clever solution to turn an antiquated design into something more powerful. That happened during Prohibition when many rum runners took advantage of engines that had originally been commissioned for WWI fighters that were no longer in service, and they put these engines into boats so they could head offshore to international waters. Those engines allowed them to outrun anything that law enforcement had for a time, until the police started doing the same thing.