How to put a square inside a commutative diagram?

The right way with tikz-cd is to use a "phantom" arrow as in

\arrow[dr, phantom, "\square"]

MWE (I've used some code to reproduce the picture and not yours):

\documentclass{article}
\usepackage{amssymb}
\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}
X'' \arrow[r, "g'"] \arrow[d] & X' \arrow[r, "g"] \arrow[d] \arrow[dr, phantom, "\square"] & X \arrow[d] \\
S'' \arrow[r, "f'"']          & S' \arrow[r, "f"']                                         & S
\end{tikzcd}

\end{document} 

enter image description here


Two solutions: one with pstricks and a psmatrix environment, the other with tikz-cd, in which I use the short syntax for arrows:

\documentclass{article}
\usepackage{mathtools, amssymb}
 \usepackage{pst-node, auto-pst-pdf}
\usepackage{tikz-cd}

\begin{document}

\texttt{psmatrix solution: }
 \[ \psset{arrows=->, arrowinset=0.15, linewidth=0.6pt, nodesep=3pt, rowsep=0.6cm, colsep = 1cm}
 \everypsbox{\scriptstyle}
 \begin{psmatrix}
%%% nodes
  X'' & X' & X \\%
S'' & S' & S
 %%% horizontal arrows
\ncline{1,1}{1,2}\naput{g'} \ncline{1,2}{1,3}\naput{g}
 \ncline{2,1}{2,2}\nbput{f'} \ncline{2,2}{2,3}\nbput{f}
 %%% vertical arrows
\ncline{1,1}{2,1} \ncline{1,2}{2,2}\ncline{1,3}{2,3}
\ncline[linestyle =none, arrows=-]{1,2}{2,3}\ncput{\textstyle\square}
 \end{psmatrix}
 \]
\vskip 1cm

\texttt{tikz-cd solution: }
\[ \begin{tikzcd}[arrows={-Stealth}]
  X''\rar["g'"]\dar & X'\rar["g"]\dar\drar[phantom, "\square"] & X\dar \\%
S''\rar[swap, "f'"] & S'\rar[swap, "f"] & S
\end{tikzcd}
\]

\end{document} 

enter image description here