According to news reports, as per Snowden revealation, the flaws are sometimes created to make the s/w vulnerable. So that system can be compromised for hacking & spying.
This is done at the time of coding with the help from IT companies like Microsoft. Initiative is taken at the time of proposing international standards & bugs are planted in the model itself. This is evident from recent revealation about bugs planted in hard disk BIOS system.
In case of open standard software, undercover coders from NSA are involved to guide the development strategy.