The X-valuation adjustment (XVA) problem, which is a recent topic in mathematical finance, is considered and analyzed. First, the basic properties of backward stochastic differential equations (BSDEs) with a random horizon in a progressively enlarged filtration are reviewed. Next, the pricing/hedging problem for defaultable over-the-counter (OTC) derivative securities is described using such BSDEs. An explicit sufficient condition is given to ensure the non-existence of an arbitrage opportunity for both the seller and buyer of the derivative securities. Furthermore, an explicit pricing formula is presented in which XVA is interpreted as approximated correction terms of the theoretical fair price.