Unintentional Security Flaws in Code: Automated Defense via Root Cause Analysis