In this paper, we propose an enhanced model for pricing vulnerable options. Specifically, our model assumes that parameters such as interest rates, jump intensity, and asset value volatility are governed by an observable continuous-time finite-state Markov chain. We take into account European vulnerable options that are exposed to both default risk and rare shocks from underlying and counterparty assets. We also consider stochastic default barriers driven by a regime-switching model and geometric Brownian motion, thus improving upon the assumption of fixed default barriers. The risky assets follow a related jump-diffusion process, whereas the default barriers are influenced by a geometric Brownian motion correlated with the risky assets. Within the framework of our model, we derive an explicit pricing formula for European vulnerable options. Furthermore, we conduct numerical simulations to examine the effects of default barriers and other related parameters on option prices. Our findings indicate that stochastic default barriers increase credit risk, resulting in a decrease in option prices. By considering the aforementioned factors, our research contributes to a better understanding of pricing vulnerable options in the context of counterparty credit risk in over-the-counter trading.