4. As shown in Figure $3, \odot O$ has a chord $AB \perp CD$, with the foot of the perpendicular being $G$. A square $CGFE$ is constructed with $CG$ as one side, and point $E$ lies on $\odot O$. If the radius of $\odot O$ is 10, and the distance from the center to the chord $AB$ is 5, then the side length of the square $CGFE$ is
4. $2 \sqrt{19}-4$.

As shown in Figure 13, draw $O M \perp C E$ at point $M$, intersecting $A B$ at point $H$, draw $O N \perp C D$ at point $N$, and connect $O B$ and $O D$. It is easy to see that
$$
\begin{array}{l}
O H=5, \\
O B=O D=10, \\
B H=5 \sqrt{3} .
\end{array}
$$

Assume the side length of the square $C G F E$ is $2 x$. Then
$$
C M=M E=G H=H F=O N=x \text {. }
$$

By the intersecting chords theorem, we have
$$
A G \cdot G B=C G \cdot G D \text {, }
$$

which is $(5 \sqrt{3}-x)(5 \sqrt{3}+x)=2 x G D$.
$$
\begin{array}{l}
\text { Also, } G D=2 N D-C G \\
=2 \sqrt{O D^{2}-O N^{2}}-2 x \\
=2\left(\sqrt{100-x^{2}}-x\right) .
\end{array}
$$

Substituting equation (2) into equation (1) and simplifying, we get
$$
\begin{array}{l}
x^{4}-46 x^{2}+225=0 \\
\Rightarrow\left(x^{2}+4 x-15\right)\left(x^{2}-4 x-15\right)=0 .
\end{array}
$$

Since $0<x<5$, we take $x=\sqrt{19}-2$, so the side length of the square $C G F E$ is $2 x=2 \sqrt{19}-4$.