A control flow analysis for safe and boxed ambients