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 may arise due to potential multicollinearity and strong correlations. This 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 -norm. We show that the general solution reduces to the standard optimal portfolio for VaR and CVaR when the covariance matrix is non-singular. We also provide a brief discussion of the efficient frontier in this context. Finally, we present a real-data example based on the weekly log returns of assets included in the S&P 500 index.