To describe the joint dynamics of prices of crude oil and refined products we extend two-factor models to a multidimensional setting. The new model captures directly the general correlation structure between the different commodities in the form of certain covariance matrix. Since the associated state-space formulation makes use of such correlations, the feasible set of the resulting estimation problem includes the cone of positive semidefinite matrices. Tractability is ensured by means of an interior point method, specially tailored for nonlinear semidefinite programming problems. For different sets of historical prices of crude oil, heating oil, and gasoline, the empirical out-of-sample forecasts obtained with the approach proposed in this work systematically provide an excellent fit to data.