Make it only apply to paid software or that used commercially. Then, you get what you pay for more often. ;)
Also, the liability of companies pushing open-source software for commercial use might be a way to get contributions to it improving quality. The companies can get sued. They're financially benefiting from it. So, they might invest some money into companies developing the code to make sure it meets whatever the standard is. It's not the best, incentive structure but it's a incentive structure. Right now, most can freeload off code which also might be shoddy enough to affect their users.
It might work to put the onus on those deploying the software. You can still freely publish what you want because free speech, and the legal responsibility starts exactly where it should: when the bugs have a chance to hurt someone other than the deployer. Said deployers, however, will be more highly motivated to ensure their software is secure, and will probably wind up with some sort of homegrown software certification process.
This would be a disaster for open source. Who wants to write software for free if you can get sued for a bug?