Is $xx^T$ the Hessian of anything?

Note that if such an $f$ exists, it must be $C^3$, so mixed third-order partial derivatives must be equal. When $i\ne j$ we have $$f_{iij} = 0 \quad\text{but}\quad f_{iji} = x_j.$$


There is no such function in general. Consider the 2D case. We have $H=\begin{bmatrix}x^2 &xy\\ xy &y^2\end{bmatrix}$, therefore $\frac{\partial^2 f}{\partial x\partial y}=\frac{\partial^2 f}{\partial y\partial x}=xy$ and $\frac{\partial^2 f}{\partial^2 x}=x^2,\frac{\partial^2 f}{\partial^2 y}=y^2$. We have

$$\frac{\partial^2 f}{\partial^2 x}=x^2\Rightarrow f(x,y)=\frac{x^4}{12}+xg(y)+h(y)\Rightarrow \frac{\partial^2 f}{\partial^2 y}=xg''(y)+h''(y)=y^2\Rightarrow h(y)=\frac{y^4}{12}\\,g''(y)=0$$

Thus $f(x,y)=\frac{x^4}{12}+\frac{y^4}{12}+xg(y)$, now there is the finishing touch $\frac{\partial^2 f}{\partial x\partial y}=g'(y)=xy$ which is contradiction, because we are only expecting a funcyion of $y$ but we have $xy$. If you start integrating with respect to $y$ first, you arrive at $\frac{\partial^2 f}{\partial x\partial y}=l'(x)=xy$ for some function $l(x)$ (the problem is symmetric, order of integration is not important).