Causality Analysis for Evaluating the Security of Large Language Models