This paper examines optimal portfolio selection using quantile-based risk measures such as Value-at-Risk (VaR) and Conditional Value-at-Risk (CVaR). We address the case of a singular covariance matrix of asset returns, which leads to an optimization problem with infinitely many solutions. An analytical form for a general solution is derived, along with a unique solution that minimizes the L2-norm. We also show that the general solution reduces to the standard optimal portfolio for VaR and CVaR when the covariance matrix is non-singular.