Fix bug in SecurityManager

- Stack was traversed in wrong order.