Safe ambients: control flow analysis and security